0

this is the chart code. I am using highchart php to do that. But it is not plotting any line. Even i am not getting any error I am not able to resolve this issue . Might be any one can suggest some for what i am doing wrong.

    chart1 = new Highcharts.Chart({
    "chart": {
    "renderTo": "container",
    "type": "line",
    "marginRight": 130,
    "marginBottom": 25
    },
    "title": {
    "text": "Nos ",
    "x": -10
    },
    "subtitle": {
    "text": "Source:MyPromo ",
    "x": -10
    },
    "xAxis": {
    "categories": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
    },
    "yAxis": {
    "title": {
        "text": "Series"
    },
    "tickInterval": 200,
    "plotLines": [{
        "value": 0,
        "width": 1,
        "color": "#808080"
    }]
    },
    "legend": {
    "layout": "vertical",
    "align": "right",
    "verticalAlign": "top",
    "x": -10,
    "y": 100,
    "borderWidth": 0
    },
    "series": [{
    "name": "-1",
    "data": ["24", "6", "39", "180", "146", "1551", "4869", "2169", "1561", "737", "1252", "572", "646", "605", "651", "397", "657", "360", "422", "465", "2718", "2493", "159"]
    },
    {
    "name": "1",
    "data": ["37", "11", "76", "97", "150", "2206", "4946", "2271", "867", "482", "1021", "487", "292", "329", "286", "319", "473", "272", "368", "340", "1584", "1595", "178"]
    },
    {
    "name": "2",
    "data": ["34", "16", "60", "89", "124", "1180", "2949", "1383", "680", "528", "839", "352", "269", "281", "258", "295", "565", "244", "313", "219", "277", "399", "93"]
    },
    {
    "name": "3",
    "data": ["55", "1", "32", "3", "83", "476", "1058", "489", "285", "228", "370", "93", "97", "127", "145", "140", "322", "132", "222", "92", "114", "187", "9"]
    },
    {
    "name": "4",
    "data": ["4", "0", "44", "3", "60", "582", "1167", "604", "333", "305", "350", "144", "82", "113", "94", "128", "184", "116", "190", "118", "190", "126", "9"]
    },
    {
    "name": "5",
    "data": ["0", "0", "31", "15", "37", "408", "923", "373", "302", "212", "312", "99", "71", "107", "192", "145", "245", "221", "120", "95", "75", "209", "9"]
    },
    {
    "name": "1",
    "data": ["37", "11", "76", "97", "150", "2206", "4946", "2271", "867", "482", "1021", "487", "292", "329", "286", "319", "473", "272", "368", "340", "1584", "1595", "178"]
    },
    {
    "name": "6",
    "data": ["0", "2", "17", "7", "36", "241", "824", "337", "193", "109", "267", "60", "89", "56", "32", "98", "59", "95", "108", "114", "59", "111", "10"]
    },
    {
    "name": "7",
    "data": ["0", "0", "21", "3", "27", "156", "393", "172", "115", "71", "135", "33", "20", "25", "15", "44", "44", "22", "61", "29", "48", "59", "12"]
    },
    {
    "name": "8",
    "data": ["0", "0", "21", "10", "17", "184", "411", "205", "126", "91", "185", "35", "14", "26", "19", "79", "59", "34", "68", "20", "47", "71", "9"]
    },
    {
    "name": "9",
    "data": ["0", "0", "19", "1", "24", "211", "788", "366", "235", "233", "308", "47", "66", "41", "20", "67", "77", "67", "86", "43", "64", "60", "6"]
    },
    {
    "name": "99",
    "data": "0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0"
    }],
    "tooltip": {
    "formatter": function () {
        return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y + ' Series';
    }
    }
});

Thanks in advance!

1 Answers1

1

Always try to use latest version of Highcharts. If you will use 3.07 version, you will have in javascript console explanation why your chart doesn't work. Culprit is that your data contains strings, while should be numbers:

    "data": ["4", "0", "44", "3" ...]

While should be:

    "data": [4, 0, 44, 3 ...]

Error reference.

Paweł Fus
  • 44,795
  • 3
  • 61
  • 77
  • You are very right @Pawel, but when i am passing array to Highchart php like this way `$chart->series[] = array( 'name' => 'name99', 'data' => $chartArr[1] );` it automatically adding double quotes on array value. –  Dec 05 '13 at 06:03
  • Use `json_encode()`. There is a lot of example for it over SO ;) Like [this one](http://stackoverflow.com/questions/13523729/how-to-json-encode-php-array-but-the-keys-without-quotes). – Paweł Fus Dec 05 '13 at 10:57