Javascript 以编程方式更改 highcharts 中的图表标题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7905367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 04:00:25  来源:igfitidea点击:

Programmatically change a chart title in highcharts

javascripthighcharts

提问by acullen72

I have a simple column chart that I update via AJAX, and all is working fine except I cannot change the actual title of the chart when I'm updating the data.

我有一个通过 AJAX 更新的简单柱状图,除了在更新数据时无法更改图表的实际标题外,一切正常。

I've tried the obvious -

我已经尝试过显而易见的 -

chart.title="new title";
//and
chart.title.text="New title";

etc. - to no avail, and have had no success finding a solution online.

等等 - 无济于事,也没有成功在线找到解决方案。

Any help will be greatly appreciated.

任何帮助将不胜感激。

回答by Bhesh Gurung

You can use setTitle(titleObj, subTitleObj)for that.

你可以用setTitle(titleObj, subTitleObj)它。

chart.setTitle({text: "New Title"});

See an example: jsfiddle

看一个例子:jsfiddle

See the API Ref.

请参阅API 参考