Jump to content
JChartFX Community
  • 0

Full JSON support


Question

Hello,

We have just started to evaluating your production for our BI dev team.

When working with the chart plugin I haven't seen a way to create a chart completely with a JSON object.

It seems that you can set the data source with a JSON object but can you initial the entire chart properties (including styles , series , datapoint ect.) using JSON object like other 3rd party vendor offer ?

We would like to generate the complete chart in the server side and initialize it in the client in a single line of code.

One more this , the Auto axis scroll seems not to be working. I have used chart1.getAxisX().setAutoScroll(true); without any luck (your sample under the documentation section , Axis Scrolling" does not work either.

Thx

Sagi

Software eng.

Intel Corp.

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello,

Yes. There is full support for JSON when it comes to initializing the chart. You can simply use the setOptions method of the chart and pass the JSON as the parameter:

 chart1.setOptions({
gallery: cfx.Gallery.Bar,
                       axesStyle: cfx.AxesStyle.Math,
                       allSeries: {
                           pointLabels: {
                              visible: true
                           }
                       },
                       axisY : {
                           grids: {
                               major: {
                                   visible: false,
                                   tickMark: cfx.TickMark.None
                               },
                               minor: {
                                   visible: false,
                                   tickMark: cfx.TickMark.None
                               }
                           },
                           customGridLines: [{value:20, text:"Avg"}],
                           sections: [{from:0, to:15}]
                      },
                      titles : [{text: "My Chart"}],
                      dataSource: items
});

In regards to the scrolling issue, we are still working on optimizing this functionality and the final API may change . Temporarily, please use clientScroll method in addition to AutoScroll:

            chart1.getData().setPoints(100);
            chart1.getAxisX().setAutoScroll(true);
            chart1.getAxisX().setClientScroll(true);


Thanks for using jChartFX!

TT

Link to post
Share on other sites
  • 0

THE TEXT IN YOUR EDITOR IS BEING CONVERTED INTO SINGLE LINE TEXT AND BEING CUT. I CANT SEND YOU THE COMPLETE MESSAGE CORRECTLY.....

the setOptions it what I was looking for .

thx.

However the scroll does not show even when adding the code you sent.

The code which results a chat that is being cut in Category22 (so you cant see the rest of the chart from category 23 to category 50).

Should I change something in the code ?

var chart1;

function loadChart(divid)

{

chart1 = new cfx.Chart();

chart1.setGallery(cfx.Gallery.Bar);

chart1.getLegendBox().setVisible(false);

chart1.getData().setSeries(10);

//chart1.getAllSeries().setStackedStyle(cfx.Stacked.Normal);

var points = new Array();

for (var i = 0; i < 50; i++) {

points = new Object();

points.Month = "Category" + i;

points.Val1 = Math.floor(Math.random() * 11);

points.Val2 = Math.floor(Math.random() * 11);

points.Val3 = Math.floor(Math.random() * 11);

points.Val4 = Math.floor(Math.random() * 11);

points.Val5 = Math.floor(Math.random() * 11);

points.Val6 = Math.floor(Math.random() * 11);

points.Val7 = Math.floor(Math.random() * 11);

points.Val8 = Math.floor(Math.random() * 11);

points.Val9 = Math.floor(Math.random() * 11);

points.Val10 = Math.floor(Math.random() * 11);

}

var data = points;

chart1.setDataSource(data);

chart1.getData().setPoints(100);

chart1.getAxisX().setAutoScroll(true);

chart1.getAxisX().setClientScroll(true);

var divHolder = document.getElementById(divid);

chart1.create(divHolder);

}

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...
×
×
  • Create New...