You must be logged in to post your query.
Home › Forums › Chart Support › Passing the data to Canvas -Javascript+html
Tagged: Javascript html canvas
Hi,
I am trying to build a small page, where I will connect to the MS access data base using javascript and the results will be displayed in a grid format and canvas as well. I was able to generate the data points in the required format for the graph, but the graph is not getting generated. Can some one help for this. ————————————————————————————-
<form> <body background="Common/BG.jpg" leftmargin=0 rightmargin=0 topmargin=0 <div> <Table><tr><td width=33%><font face="helvetica" size=2 color=navy><b>Count<input type="text" id="count" value="" /></tr> <tr><td><input type="Submit" value="Search" style="width: 175px" onclick="return GetSearchData2('count')"/></tr> </table> </div> <div id="dvResults" style="width: 2000px; height: 1000px;></div> <div id="chartContainer" style="height: 800px; width: 100%;"></div> </form> <! Begin server side script here> <script type="text/javascript" src="Common/Database/CommonJs.js"></script> <script type="text/javascript" src="Common/Database/canvasjs.min.js"></script> <script type="text/javascript"> // function GetSearchData2(count) { var strHtml="sql query results in table format"; document.getElementById("dvResults").innerHTML = strHtml; // This is to show the data in table format var finaldata; // this is the data input for the chart in the format from the query . Ex:- { x: 10, y: 71 }, { x: 20, y: 55}, { x: 30, y: 50 } //Now passing this data to the chart to render it in the same function var chart = new CanvasJS.Chart("chartContainer", { data: [ { type: "column", [dataPoints: finaldata ] } ] }); document.getElementById("dvResults").innerHTML = strHtml; chart.render(); } </script>
——————————————————————–
Just to add more info , the chart is taking my data as input . When I alerted before chart.render(); , I can see [object Object]. But the chart is not getting rendered in the page. Can some one please help.
Same issue. Any update on this how to solve this
@Bydbest,
Can you please create JSFiddle representing the issue using some sample data, if possible? In case you can’t, we’d need to take a look at your project to understand the issue in a better way and help you out.
—- Bivek Singh, Team CanvasJS
You must be logged in to reply to this topic. Login/Register