Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: chart.options.data.push() error #28885

    Ok, now I’m going somewhere. Thanks a lot Manoj.
    I did have to replace the line “chart.data.push(data[i]);” with this “chart.options.data.push(data[i]);” and I got exactly what I was looking for. Thanks again

    in reply to: chart.options.data.push() error #28839

    I’ve tried to recreate my situation here jsfiddle
    I am getting my series from ajax and database but here my dataseries in the ajax file were filled manually to represent what it’s returning. And what it is returning is 5 sets of multiple series (here, each set has 5 data series, but it can be more or less). I want to create a chart that will display one set of data series at a time depending on what the user selects in a select tag. Thank you so much for your help

    in reply to: chart.options.data.push() error #28805

    Thanks a lot for your help Manoj.
    The JSFiddle I created was a simplified version of my code and, while I do understand your answer (object vs string), I still have a hard time implementing this solution in my actual code. I think I’m going down the wrong path and need to be shown the right way to do that. Let me try to explain what I’m doing:
    I’m actually getting my series from ajax. The value returned by my ajax query contains a set of different series and looks like that:

    {type: “column”, name: “2016”, showInLegend: true, markerType: “square”, markerSize: 5, yValueFormatString: “#,##0.##\” miles\””, dataPoints: [{“label”:”january”,”y”:0},{“label”:”february”,”y”:0},{“label”:”march”,”y”:0},{“label”:”april”,”y”:0},{“label”:”may”,”y”:0},{“label”:”june”,”y”:0},{“label”:”july”,”y”:0},{“label”:”august”,”y”:34.62},{“label”:”september”,”y”:83.38},{“label”:”october”,”y”:62.35},{“label”:”november”,”y”:60},{“label”:”december”,”y”:0}]},{type: “column”, name: “2017”, showInLegend: true, markerType: “square”, markerSize: 5, yValueFormatString: “#,##0.##\” miles\””, dataPoints: [{“label”:”january”,”y”:12.2},{“label”:”february”,”y”:76.13},{“label”:”march”,”y”:52.05},{“label”:”april”,”y”:53.64},{“label”:”may”,”y”:121.1},{“label”:”june”,”y”:161.47},{“label”:”july”,”y”:138.4},{“label”:”august”,”y”:62.85},{“label”:”september”,”y”:83.79},{“label”:”october”,”y”:105.8},{“label”:”november”,”y”:46},{“label”:”december”,”y”:9.35}]},
    {type: “column”, name: “2018”, showInLegend: true, markerType: “square”, markerSize: 5, yValueFormatString: “#,##0.##\” miles\””, dataPoints: [{“label”:”january”,”y”:26.41},{“label”:”february”,”y”:30.69},{“label”:”march”,”y”:36.24},{“label”:”april”,”y”:0},{“label”:”may”,”y”:46.24},{“label”:”june”,”y”:234.75},{“label”:”july”,”y”:120.01},{“label”:”august”,”y”:90},{“label”:”september”,”y”:33.05},{“label”:”october”,”y”:58.11},{“label”:”november”,”y”:70.8},{“label”:”december”,”y”:52.84}]},
    {type: “column”, name: “2019”, showInLegend: true, markerType: “square”, markerSize: 5, yValueFormatString: “#,##0.##\” miles\””, dataPoints: [{“label”:”january”,”y”:42.11},{“label”:”february”,”y”:7.29},{“label”:”march”,”y”:45.55},{“label”:”april”,”y”:76.4},{“label”:”may”,”y”:112.1},{“label”:”june”,”y”:312.27},{“label”:”july”,”y”:122.1},{“label”:”august”,”y”:13.53},{“label”:”september”,”y”:50.63},{“label”:”october”,”y”:72.14},{“label”:”november”,”y”:166.51},{“label”:”december”,”y”:73.95}]},
    {type: “column”, name: “2020”, showInLegend: true, markerType: “square”, markerSize: 5, yValueFormatString: “#,##0.##\” miles\””, dataPoints: [{“label”:”january”,”y”:68.73},{“label”:”february”,”y”:135.42},{“label”:”march”,”y”:114.8},{“label”:”april”,”y”:0},{“label”:”may”,”y”:0},{“label”:”june”,”y”:0},{“label”:”july”,”y”:0},{“label”:”august”,”y”:0},{“label”:”september”,”y”:0},{“label”:”october”,”y”:0},{“label”:”november”,”y”:0},{“label”:”december”,”y”:0}]},

    Here, I have a set of 5 series, but it can be more or it can be less.
    What I want to do is to update my chart with those series. My limited coding skills are getting me nowhere

    $.ajax({
    url: “testAjax.php”,
    type: “POST”,
    data: {
    activityType: activityTypeSelected
    },
    success: function (data) {
    var result = JSON.parse(data);
    }
    });

    From there, how do I use “result” to update my already existing chart?

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