Home Forums Chart Support Changing options after creating the chart.

Changing options after creating the chart.

Viewing 13 posts - 1 through 13 (of 13 total)
  • #5922

    Hi,

    I’m trying to change some of the chart options after creating the object.

    The title works great:
    chart.options.title.text=”another title”;

    But theme doesn’t:
    chart.options=”theme2″;

    http://jsfiddle.net/dreamfalcon/ravXa/

    Is this possible?
    I want to create a form where the user could change some of the charts options.

    Br,
    Daniel

    #5924

    Its chart.options.theme=”theme2″;
    Still doesn’t work :/

    #5925

    Daniel,

    I can confirm the issue. Am currently working towards fixing the same. Will get back at the earliest with a new build – probably in a day or two.


    Sunil Urs

    #5926

    If we could change any of the options and them call render would be great :)

    Thanks

    #5930

    Daniel,

    Here is an intermediate build with the fix – allows updating all attributes. Please have a look and let me know if its working as expected.


    Sunil Urs

    #5934

    Hi,
    In the example I give is working great.
    Then I tried to send all options by json to PHP, alter the theme, return also by json, change the chart options,render the chart, and the theme is not altered.

    JS:

    var chart = new CanvasJS.Chart("content",
    {
    	theme: "theme1",
    	title:{
    		text: "Changing Theme"
    	},
    	data: [
    	{
    		type: "column",
    		dataPoints: [
    		{ x: 10, y: 71 },
    		{ x: 20, y: 55},
    		{ x: 30, y: 50 },
    		{ x: 40, y: 65 },
    		{ x: 50, y: 95 },
    		{ x: 60, y: 68 },
    		{ x: 70, y: 28 },
    		{ x: 80, y: 34 },
    		{ x: 90, y: 14}
    		]
    	}
    	]
    });
    chart.render();
    var json=JSON.stringify(chart);
    
    success = function(jsonObject) {
    	chart.options=JSON.parse(jsonObject.chartOptions);
    	chart.render();
    };
    jsonRequest(json,success);

    PHP:

    $s=json_decode ( $_REQUEST['json'] ,true);
    $s['options']['theme']="theme2";
    $response->chartOptions=json_encode ($s);

    Br,
    Daniel

    #5949

    Is possible to change the options object by another or I have to change the attributes one by one?
    Thanks

    #5959

    Daniel,

    By design it is not allowed to set the options object itself but you can change its attributes. But we’ll reconsider this for upcoming versions.


    Sunil Urs

    #5960

    Hi,

    An alternative for what I need is saving the original object used to create the chart, modify this object, destroy the old chart and creating a new chart with the new object.
    But that will increase memory in case of dashboards with many charts.

    Thanks

    #5976

    Daniel,

    We have decided to implement this feature. Am already half way through. You can expect this feature in a day or two.


    Sunil Urs

    #5977

    Daniel,

    Here is an intermediate build with the above mentioned feature. Please have a look and let me know if its working as expected.


    Sunil Urs

    #5997

    It’s working great, many thanks.
    Unfortunately I had to stop the development of the reports because of another project, but I expect to buy and migrate all charts to CanvasJS in a few weeks.

    Br,
    Daniel

    #6000

    Thats great.. Thanks for choosing us… :-)

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.