Jump to content
JChartFX Community
  • 0

Scaling seems weird please help


uberphoebe

Question

4 answers to this question

Recommended Posts

  • 0

One possibility would be that you are letting the chart to initialize with random data and after that we are not resetting the min/max to the real data scale.

Can you clarify when are you passing the data to the chart? Can you post a small sample page that duplicates the issue you are experiencing?

JuanC 

Link to comment
Share on other sites

  • 0
Ok lets say
gn="car"
gl="old,new"
pos="24,3"
neg="18,23 
 
 
 
var chart3
    function loadGroupChart(gn,gl,pos,neg)
{
var gla=gl.split(",");
var posa=pos.split(",");
var nega=pos.split(",");
var i=gla.length;
chart3 = new cfx.Chart();
chart3.setGallery(cfx.Gallery.Bar);
var data = chart3.getData();
data.setSeries(2);
data.setPoints(i);
//load data points
for(var j=0;j<i;j++)
{
data.setItem(0, j, posa[j]);
data.setItem(1, j, nega[j]);
// Series  X axis labels
chart3.getAxisX().getLabels().setItem(j,gla[j]);
}
// Series  data name
chart3.getSeries().getItem(0).setText("Positive");
chart3.getSeries().getItem(1).setText("Negative");
//recalculate scales
chart3.recalculateScale(true);

// Series  X axis labels
chart3.getLegendBox().setVisible(true);
chart3.getAxisY().getGrids().getMajor().setVisible(true);
chart3.getAxisY().getGrids().getMinor().setVisible(true);
document.getElementById('ChartDiv3').innerHTML = "";
document.getElementById('ChartDiv3').innerHTML = "Analysis by "+gn;
var divHolder = document.getElementById('ChartDiv3');
chart3.create(divHolder);      
}
Link to comment
Share on other sites

  • 0

You are passing strings in the calls to data.setItem instead of numbers, please try this

data.setItem(0, j, Number(posa[j]));

data.setItem(1, j, Number(nega[j])); 

Also, possibly a typo when creating the simplified sample, you are not using neg when splitting into nega.

Finally, you can remove the recalculateScale call as it is not needed.

JuanC 

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...
×
×
  • Create New...