简体   繁体   English

让Highcharts重新绘制

[英]getting Highcharts to redraw

I've created a form that will allow me to edit parts of my chart. 我创建了一个表格,使我可以编辑图表的各个部分。 One of them is the subtitle but for some reason the chart.redraw() isn't working and I'm not getting an error message back. 其中之一是字幕,但由于某种原因,chart.redraw()无法正常工作,并且没有收到错误消息。 The chart needs to redraw once the input field has changed. 输入字段更改后,图表需要重绘。 The chart already updates with a redraw every minute so I know it works otherwise but for some reason in this single function it won't call redraw(). 该图表已经每分钟更新一次,因此我知道它可以正常工作,但是由于某些原因,在此单个函数中它不会调用redraw()。 This is very important because another option is to hide/show the legend and that will need a redraw(). 这非常重要,因为另一种选择是隐藏/显示图例,这需要redraw()。

HTML: HTML:

<input type="text" placeholder="Sub Title" data-chart="chart_3972002" data-action="chartSub">

JavaScript: JavaScript:

$('input[data-action="chartSub"]').change(function(){           
    $('.unSaved').html('Saving').css('color','#669900').delay(800).fadeOut();
    var key = $(this).data('chart');
    var chart = JSON.parse(localStorage.getItem(key));
    chart.subTitle = $(this).val();
    localStorage.setItem(key, JSON.stringify(chart));

    var Chart = $('#'+key).highcharts();
    Chart.setTitle(null, {text: chart.subTitle});
    Chart.redraw();
});

Set title function redraws chart automatically, so you don't need to use redraw() function. 设置标题功能会自动重绘图表,因此您无需使用redraw()函数。

http://api.highcharts.com/highcharts#Chart.setTitle() http://api.highcharts.com/highcharts#Chart.setTitle()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM