Jump to content
JChartFX Community
  • 0

Chart updated from table



4 answers to this question

Recommended Posts

  • 0

It is possible to have a chart that reflects changes in a table. At this moment I do no think we have a sample, as soon as we have one we will post a link here.

Basically the sample has to detect changes on a table, figure out the row/column and use chart.getData().setItem(series, point) to change the appropriate value in the chart.


Link to comment
Share on other sites

  • 0

It would be something like this (using jQuery), it would obviously need code to handle an invalid number entry, in this sample I am hardcoding a table with 3 numbers, on a real page this table would be generated dynamically to control number of items.

<!DOCTYPE html>
    <link rel="stylesheet" type="text/css" href="Include/jchartfx.css" />
    <script type="text/javascript" src="Include/jquery.js">
    <script type="text/javascript" src="jchartfx.system.js">
    <script type="text/javascript" src="jchartfx.coreVector.js">
Handle Data Change

<div id="myDiv" style="width:600px;height:400px;display:inline-block"></div>


  <input class="target" type="text" data-row="0" value="10.5" />
  <input class="target" type="text" data-row="1" value="14.5" />
  <input class="target" type="text" data-row="2" value="8.5" />
<script language="javascript">
    var chart1;
    $(document).ready(function($) {
        chart1 = new cfx.Chart();
        var data = chart1.getData();
        data.setItem(0, 0, 10.5);
        data.setItem(0, 1, 14.5);
        data.setItem(0, 2, 8.5);
        var divHolder = document.getElementById('myDiv');
        $('.target').change(function() {
            var row = $(this).data("row");
            var value = $(this).attr("value");
            data.setItem(0, row, value);


Hope this helps.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...