Jump to content
JChartFX Community
  • 0

x-axis labels rounded and some are not displayed


timp

Question

Hi, I have the following dataset

 

var pItems = [{"Xdata":305, "Ydata":6},{"Xdata":1196, "Ydata":40}, {"Xdata":1889, "Ydata":2}, {"Xdata":1995, "Ydata":16}, {"Xdata":2006, "Ydata":113}, {"Xdata":2071, "Ydata":1}, {"Xdata":3343, "Ydata":11}, {"Xdata":3631, "Ydata":69}, {"Xdata":3697, "Ydata":913}, {"Xdata":5555, "Ydata":1}];

 

which I use to create a bar chart with,


 ChartDetail = new cfx.Chart();

    ChartDetail.getData().setSeries(1);

    ChartDetail.getDataSourceSettings().getFields().clear();

    ChartDetail.setDataSource(pItems);

  xAxis.setStep(1);

    xAxis.setLabelValue(1);

    ChartDetail.setGallery(cfx.Gallery.Bar);   

    var sb = new cfx.SimpleBorder();

    ChartDetail.setBorder(sb);

    ChartDetail.getAllSeries().setMarkerShape(cfx.MarkerShape.None);

    ChartDetail.getLegendBox().setVisible(false);

    ChartDetail.getAxisY().setAutoScale(true);

    ChartDetail.getAxisY().getGrids().getMajor().setVisible(true);

    ChartDetail.getAxisX().getGrids().getMajor().setVisible(true);

    ChartDetail.getAxisX().setStyle(ChartDetail.getAxisX().getStyle() | cfx.AxisStyles.ShowEnds);

    var divHolder = document.getElementById(pDivDetail);

    ChartDetail.create(divHolder);

However, the labels on the xaxis are somehow rounded such that 305 becomes 400, 1196 becomes 1200 etc. Additionally, some labels are not displayed, i.e. 1889, 2006 and 3631. Any ideas how to fix this? Any help much appreciated.

 

  • Like 1
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I was going to try to help you but I've had several problems with your code you submitted and I am not sure exactly what you want. 

 

 

Is this the code that you meant to submit? I have copied it exactly as you wrote and tried running it. Firstly I needed to comment out the following lines because you do not include how you got xAxis.

xAxis.setStep(1);
xAxis.setLabelValue(1);

Secondly from what you are saying it sounds like my graph is rendering differently from what your intentions were. I included a screenshot of my results and as you can see your code is rendering 1-10 on the xAxis. This contradicts what you stated in your description.

post-46655-0-90474200-1406577655_thumb.png

 

Just as a side note when I hover over the bars I am getting the correct values in the popups. 

 

 

Edited by ottodude125
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...