Skip to content Skip to sidebar Skip to footer

Update Array Values To Chart Based On Timeframe - Javascript

I need to update the chart based on time period. currently chart is updating all values. Now i need to update the chart by 3 months 6 months 9 months 12 months 15 months 18 months

Solution 1:

See http://jsfiddle.net/Yq3DW/99/

I changed the value of options to indicate how many months each should show and in the change event I slice the original array. I use + 1 to include the 3rd, 6th, etc. item in the array.

$("#SelectPeriod").change(function (evt) {
    var chartSelection = $("#SelectPeriod").val();
    var chart = c3.generate({
        data: {
            rows: calculation.slice(0, parseInt(chartSelection) + 1),
            type:'bar'
        }
    });
});

Post a Comment for "Update Array Values To Chart Based On Timeframe - Javascript"