gionkunz / chartist-plugin-threshold

Threshold Plugin for Chartist.js
Do What The F*ck You Want To Public License
29 stars 38 forks source link

Update Threshold with button click #22

Open MongouseIt opened 4 years ago

MongouseIt commented 4 years ago

Hello,

I'm trying update the threshold and the whole chart with a click event, but the threshold doesn't changes. The chart axys updating as expected but threshold stays at the default value.

I'm updating the chart like this:

function ChangeChart(_low, _high, _threshold){
  mychart.update({
    labels: _labels,
    series: _series
  }, {
    low: _low,
    high: _high,
    showArea: true,
    plugins: [
       Chartist.plugins.ctThreshold({
         threshold: _threshold
        })
     ]
  });
}

$(document).ready(function(){
  $('button').click(function(){
     var _threshold = 2; //default is 4
     var _low = 2.5; //default is 3.5
     var _high = 5.5; //default is 6.5
     ChangeChart(_low, _high, _threshold);
   });
});

Is there a way to update the threshold. Am I doing something wrong?