Jump to content
JChartFX Community
  • 0

How do I use the Crosstab Data Provider with the jQuery/JavaScript object syntax?


DanielL_550

Question

How would I convert this Javascript example from the "Programmer's Guide"/"Passing Data"/"Using the Crosstab Data Provider" to use the jQuery/JavaScript object syntax?



var items = [


{ "Name": "John", "Year": 2008, "Sales": 49027},


{ "Name": "John", "Year": 2009, "Sales": 45815},


{ "Name": "Robert", "Year": 2008, "Sales": 51489},


{ "Name": "Robert", "Year": 2009, "Sales": 55652},


{ "Name": "Mark", "Year": 2008, "Sales": 51924},


{ "Name": "Mark", "Year": 2009, "Sales": 55075},


{ "Name": "Kelly", "Year": 2008, "Sales": 55227},


{ "Name": "Kelly", "Year": 2009, "Sales": 36160},


{ "Name": "Brenda", "Year": 2008, "Sales": 54457},


{ "Name": "Brenda", "Year": 2009, "Sales": 51719}


];



chart1.setGallery(cfx.Gallery.Bar);



var fields = chart1.getDataSourceSettings().getFields();


var field1 = new cfx.FieldMap();


field1.setName("Name");


field1.setUsage(cfx.FieldUsage.RowHeading);


fields.add(field1);


var field2 = new cfx.FieldMap();


field2.setName("Year");


field2.setUsage(cfx.FieldUsage.ColumnHeading);


fields.add(field2);


var fieldVal = new cfx.FieldMap();


fieldVal.setName("Sales");


fieldVal.setUsage(cfx.FieldUsage.Value);


fields.add(fieldVal);


var crosstab = new cfx.data.CrosstabDataProvider();



crosstab.setDataSource(items);


chart1.setDataSource(crosstab);



Thank you.

post-2107-13939743188069_thumb.gif

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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