mnowotny

[FusionTime] How to use setChartAttribute?

Recommended Posts

Hi,

I'm playing around with the FusionTime library and stumbled across the setChartAttribute function:
https://www.fusioncharts.com/dev/fusiontime/api/fusiontime-methods

How can I use this function with nested properties?
I tried it like this:

chart.setChartAttribute('navigator', {enabled : false});
chart.setChartAttribute('navigator.enabled', false);
chart.setChartAttribute({navigator : {enabled : false}});

but nothing worked out.

I'd also like to know how to set certain properties, like 'type'.
https://www.fusioncharts.com/dev/fusiontime/fusiontime-attributes#chart-configuration-and-root-json-attributes
Since the documentation states that 'type' expects a number, I tried this:

chart.setChartAttribute("type", 1);
chart.setChartAttribute("type", 0);
chart.setChartAttribute("type", "1");
chart.setChartAttribute({type: 1});

And I also tried using 'area' or 'column' instead of the number, but that didn't work out either.

How do I use this function?
Can I even use this without reloading everything?


Kind regards
mnowotny

Share this post


Link to post
Share on other sites

Hi,

 

The API method setChartAttribute() updates a chart's attributes with a new attribute-value pair of the chart object of the dataSource.

The "navigator" object or any other object that is not part of the chart object cannot be updated using setChartAttribute() API method.

 

To update the "navigator" or any object that belong to the dataSource, you need to use setChartData() API method to update the entire dataSource in which the navigator belongs.

 

Thanks,

Akash.

Share this post


Link to post
Share on other sites

Thank you for your reply!

The chart object isn't documented, is it?

Maybe I'm misunderstanding the reference here:
https://www.fusioncharts.com/dev/fusiontime/fusiontime-attributes#chart-configuration-and-root-json-attributes

I thought that all of these attributes would be placed right under the dataSource object. It'd be great if you could update the docs.

For now I'm updating the chart like this:

let data = chart.getChartData();
data.navigator.enabled = false;
chart.setChartData(data);
chart.render();

is there a better approach to do this?

 

What about my second question? How does setChartAttribute('type', ?) work and what is type in this context?

 

Kind regards
mnowotny

Share this post


Link to post
Share on other sites

Hi,

 

 We would check with the documentation of the Chart configurations and Root JSON attributes.

However, you can check the navigator configuration details in the below link :
https://www.fusioncharts.com/dev/fusiontime/fusiontime-component/time-navigator#show-hide-time-navigator

As mentioned, to update the "navigator" or any object that belong to the dataSource, the setChartData() method need to be used.

 

For FT charts, the chart "type" is always "timeseries". For different type of plots, you can set the "type" within the "yAxis" object of the dataSource.

Plot type documentation link : https://www.fusioncharts.com/dev/fusiontime/getting-started/change-plot-type-in-fusiontime

Since, the "type" for yAxis object is part of the dataSource, so to change the plot type you need to modify the dataSource and then update it using setChartData() API method.

Please note : setChartAttribute() API method would not work to change the plot type.

 

Thanks,

Akash.

Share this post


Link to post
Share on other sites

Thanks for your reply.

I wish there was a better/easier way to update certain properties that are describing the chart, not the data. 

I'm looking forward to your next FT update!

Kind regards
mnowotny

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now