Jump to content
JChartFX Community
  • 0

Clear data from chart?


nz1975
 Share

Question

3 answers to this question

Recommended Posts

  • 0

Hello,

You can clear the data by assigning an empty item to the
DataSource, take a look at the following code:

var
items = [];
chart1.setDataSource(items);

Using arrays is a quick way of passing data to the chart,
please refer to the sample below:

var
items = [
   
{"Value": 9}, 
    {"Value":
15}, 
    {"Value":
21}, 
    {"Value":
26}, 
    {"Value":
35}

];

chart1.setDataSource(items);



I
hope this helps.

Link to comment
Share on other sites

  • 0

 OK,this is a clear,but I need a refresh data so i have this function and she works:

" function onLoadDoc() {
     var vl1;
    var vl2;
    var vl3;
    var val1;
    var val2;
    var val3;
    var chart1;
    chart1 = new cfx.Chart();
    chart1.setGallery(cfx.Gallery.Lines);
    chart1.getLegendBox().setDock(cfx.DockArea.Bottom);
      val1 = document.getElementById('v1').value;      <-v1,v2,v3 are text input (number)
     val2 = document.getElementById('v2').value;
     val3 = document.getElementById('v3').value;
     vl1 = parseInt(val1);
     vl2 = parseInt(val2);
     vl3 = parseInt(val3);
   
     var data=[{
        "Label": "+18",
        "text": vl1
      
    }, {
        "Label": "0",
        "text": vl2
  
    }, {
        "Label": "-15",
        "text": vl3
 
    }];
     chart1.setDataSource(data);
        var chartDiv = document.getElementById('ChartDiv1');
     chart1.create(chartDiv);  
     }
    //*****END OF FUNCTION***** """"

This function works but I need next:User change V1,V2 AND V3 (number value) and press a button,then i need just to refresh data in same chart

Link to comment
Share on other sites

  • 0

helo this is a function I wrote for cleaning the chart ..
hope this helps ..



"

 

function PlotClear(chart) {
    var items = [{
        "Series 1": "0,0"
    }];
    chart.setDataSource(items);
    chart.update();
}
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.

Guest
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.

Loading...
 Share

×
×
  • Create New...