Render Highcharts after user updated labels

前端 未结 1 1224
没有蜡笔的小新
没有蜡笔的小新 2021-01-05 18:53

I am trying to create a chart builder. I have a user inputs for Title and location of the legend. I want a user to type in a title and when the click off (blur) the chart

1条回答
  •  执笔经年
    2021-01-05 19:47

    Figured out the Issue. Detailed here: http://highslide.com/forum/viewtopic.php?f=12&t=15255

    Basically the Highcharts.charts function clears the series data from the original options object.

    This is my working code:

    var chart;
    var chartData = { /* you chart data goes here */ };
    $('#legendlocation-select').blur(function updateChartLegend(){
      console.log($('#legendlocation-select').val());
      if($('#legendlocation-select').val()==='none'){
        chart.options.legend.enabled = false;
      }else{
        chart.options.legend.enabled = true;
        chart.options.legend.align = $('#legendlocation-select').val();
      }
      renderChart();
    });
    
    function renderChart(){
      //console.log(chartData);
      if(chart == undefined){
        console.log("First Draw");
        chart = new Highcharts.Chart(chartData);
      }else{
        console.log("Redraw");
        chart.options.chart.animation = false;
        chart = new Highcharts.Chart(chart.options);
        chart.render();
      }
    };
    

    0 讨论(0)
提交回复
热议问题