ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  getChartCount() = 0 issue
Posted by James on Oct-16-2019 00:26
Hello,

I have following issue.

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.

Can you help me what I am missing on the first?

Thank you,

  Re: getChartCount() = 0 issue
Posted by Peter Kwan on Oct-16-2019 12:14
Hi James,

Note that obj.innerHTML= "...." is different from injecting the content directly into the web page. In case you are not aware, innerHTML supports only HTML. It ignores the Javascript.

As you have examine the output of RnderHTML, you probably see that it contains both HTML and Javacript. The Javascript contains the data. As innerHTML ignores Javascript, so there will be no data for the chart.

If you want to use innerHTML, you need to use your own code to extract the Javascript out (eg. by using regex to look for the "<script" and </script>" tags), and then "eval" the Javascript.

Hope this can help.

Regards
Peter Kwan

  Re: getChartCount() = 0 issue
Posted by James on Oct-16-2019 21:39
Yes! that was the issue.  I use jQuery to resolve the script issue.  Thanks always.


hausfrauen porno tube