Home › Forums › Chart Support › Changing options after creating the chart. › Reply To: Changing options after creating the chart.
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