gpt4 book ai didi

javascript - 在用户更新标签后呈现 Highcharts

转载 作者:数据小太阳 更新时间:2023-10-29 05:55:51 27 4
gpt4 key购买 nike

我正在尝试创建图表生成器。我有一个标题和图例位置的用户输入。我希望用户输入标题,然后点击关闭(模糊)图表以他们输入的内容更新。

问题是图表第一次呈现,但是我再也无法让 char 再次呈现。以下是代码的简要摘要。

$('#legendlocation-select').blur(function updateChartLegend(){
console.log($('#legendlocation-select').val());
if($('#legendlocation-select').val()==='none'){
chartData.legend.enabled = 'false';
}else{
chartData.legend.enabled = 'true';
chartData.legend.align = $('#legendlocation-select').val();
}
renderChart();
});
function renderChart(){
if(chart == undefined){
console.log("First Draw");
chart = new Highcharts.Chart(chartData);
}else{
console.log("Redraw");
chart.destroy();
chart = new Highcharts.Chart(chartData);
chart.redraw();
}
};

图表第一次呈现,然后第二次呈现为空白区域。有任何想法吗?chartData 是一个变量,其中包含正确呈现的所有选项。

这是一个显示问题 http://jsfiddle.net/zVjrb/3/ 的 JSFiddle

最佳答案

找出问题所在。详情在这里:http://highslide.com/forum/viewtopic.php?f=12&t=15255

基本上,Highcharts.charts 函数会从原始选项对象中清除系列数据。

这是我的工作代码:

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();
}
};

关于javascript - 在用户更新标签后呈现 Highcharts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9661250/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com