Jump to content
JChartFX Community
  • 0

JSON format for scatter chart datasource


flippy

Question

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

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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 

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