1. create RazorChartViewer in ASP.NET apicontroller using C#
2. assign viewer.RenderHtml() to a variable
3. return it as text/html when it is called from a viewer using ajax.
4. The chart image is shown fine but when getChartCount() called, it says 0 and getChart() is also null. But, the viewer = JsChartViewer.get(chartId) is not null and console.log outputs the contents fine.
document.getElementById("testChart").innerHTML = renderHtmlCodes;
var viewer = JsChartViewer.get(chartId);
console.log(viewer); // not null and has all properties
var xyChart = viewer.getChart();
console.log(xyChart); // null
var count = viewer.getChartCount();
console.log(count); // 0
But, if I do following, getChartCount() outputs correct value: 1.
1. create RazorChartViewer in ASP.NET controller using C#
2. assign it to ViewBag.chartObject upon page loading
3. do chartObject.RenderHtml() in the view.
4. Again, the chart image is shown fine and getChart() is not null and getChartCount() is 1.
I compared RenderHtml values between apicontroller and in the view and found not much differences and confirmed they all have chartModel with same data.