Home Forums Chart Support The line chart not appear when open the page

The line chart not appear when open the page

Viewing 3 posts - 1 through 3 (of 3 total)
  • #10146

    I met a strange issue. I can’t see the line chart when open the web page. Then I resize the window/browser, the line chart then can be seen and works well. The question is: why a resize is needed to see the chart?
    I suppose it is related to the getJSON, because if I put the data directly into html (instead of reading from json file) it can always work well. :)

    Below is my code: index.html

    <script type=”text/javascript” src=”canvasjs.min.js”></script>
    <script type=”text/javascript” src=”jquery-2.1.4.js”></script>
    <script type=”text/javascript”>
    $(document).ready(function() {
    var dataPointsA = []
    var dataPointsB = []

    $.getJSON(“test.json”, function (field) {
    for( var i = 0; i < field.length; i++) {
    dataPointsA.push({ x:field[i].time, y:field[i].xxx});
    dataPointsB.push({ x:field[i].time, y:field[i].yyy});

    var chart = new CanvasJS.Chart(“chartContainer”,
    text: “Test line”

    data: [
    type: “line”,
    name: “line1”,
    dataPoints: dataPointsA
    type: “line”,
    name: “line2″,
    dataPoints: dataPointsB

    <div id=”chartContainer” style=”height: 600px; width: 100%;”>

    Below is my data file: test.json

    Alben Shao


    Alben Shao,

    Kindly close the getJSON after rendering chart. Here is the working code.


    Yes. It works. Thanks very much for your help!

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

You must be logged in to reply to this topic.