flippy Posted July 16, 2013 Report Share Posted July 16, 2013 Hi, I woud like to pass a JSON datasource to a scatter chart but I could not find the proper format to set the X and Y coordinates of my points. I saw this example to setup the data via API: data.getX().setItem(0, 0, (-100)); data.getY().setItem(0, 0, (5)); What is the equivalent in a JSON format that I could pass to this function? chart1.setDataSource(jsonData); Cheers, Flippy Quote Link to comment Share on other sites More sharing options...
0 JuanC Posted July 16, 2013 Report Share Posted July 16, 2013 There is not a specific JSON format for scatter (or multi series charts), but you have to use the fields map API to tell us how to use each field, e.g. var items = [{"X":5, "Y":15},{"X":6, "Y":9},{"X":8, "Y":18}]; chart1.setDataSource(items); var fields = chart1.getDataSourceSettings().getFields(); var field1 = new cfx.FieldMap(); field1.setName("Y"); field1.setUsage(cfx.FieldUsage.Value); fields.add(field1); var field2 = new cfx.FieldMap(); field2.setName("X"); field2.setUsage(cfx.FieldUsage.XValue); fields.add(field2); Regards, JuanC Quote Link to comment Share on other sites More sharing options...
0 flippy Posted July 16, 2013 Author Report Share Posted July 16, 2013 Hi, Thanks a lot for the fast response. This is exactly what I was looking for. Cheers, Flippy Quote Link to comment Share on other sites More sharing options...
Question
flippy
Hi,
I woud like to pass a JSON datasource to a scatter chart but I could not find the proper format to set the X and Y coordinates of my points.
I saw this example to setup the data via API:
data.getX().setItem(0, 0, (-100));
data.getY().setItem(0, 0, (5));
What is the equivalent in a JSON format that I could pass to this function?
Cheers,
Flippy
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
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.