Jump to content
JChartFX Community
  • 0
Sign in to follow this  
ql_maxg

Set no format for x-axis labels

Question

Hello

I need to pass some labels for x axis in following format '2015-02-02', other words in date format. But, I don't want jchartfx to identify it as date and convert to date label in culture format. I want it to be treated as some custom text labels and preserve the order of data. Is it possible to do?

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

We try to use dates or strings using ISO 8601 format as dates, e.g. the following data will create a chart where we identify the field Date as holding dates, notice that we used lines as this gallery supports XY data so it is easier to see that the distance between the first 2 points is not the same as the last 2 points.

 

chart1.setDataSource([{"Value":12, "Date":"2016-02-15"}, {"Value":14, "Date":"2016-02-16"}, {"Value":11, "Date":"2016-02-18"}]);

chart1.setGallery(cfx.Gallery.Lines);
 
To workaround this you need to specify how each field will be used, e.g.
 
var fields = chart1.getDataSourceSettings().getFields();
var field;
field = new cfx.FieldMap();
field.setName("Value");
field.setUsage(cfx.FieldUsage.Value);
fields.add(field);
 
field = new cfx.FieldMap();
field.setName("Date");
field.setUsage(cfx.FieldUsage.Label);
fields.add(field);
 
Note that you have to assign the fields before using setDataSource, you will notice that the points in the line are equally spaced but there is a bug that will still format the dates on the user's culture. This will be fixed in our next build.
 
A workaround before this issue is fixed would be to add a character (e.g. a whitespace) in the first element's date to trick our detection code.
 
JuanC

Share this post


Link to post
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...
Sign in to follow this  

×
×
  • Create New...