javascript - 在 highcharts-react-official 上定义和应用主题

标签 javascript reactjs typescript highcharts react-highcharts

我正在尝试全局更新 higcharts 文本字体,我在文档中找不到如何使用 highcharts-react-official 应用自定义主题的任何地方。是否有 Highcharts.theme = styleHighcharts.setOption(Highcharts.theme) 的等价物?

最佳答案

Highcharts 主题是一组预定义的选项,在实例化每个图表之前,这些选项将作为默认的 Highcharts 选项应用。 highcharts.zip 包附带了一些主题,只需包含它们即可轻松应用于您的图表: https://www.highcharts.com/docs/chart-design-and-style/themes

当然,您也可以创建自己的选项。改变主题只不过是用一个新的选项调用 setOptions()。

现场演示: https://stackblitz.com/edit/highcharts-87w46s?file=Highchart.js

import DarkUnica from 'highcharts/themes/dark-unica';
DarkUnica(ReactHighcharts.Highcharts);

您还可以检查 CSS 样式方法是否适合这种情况: https://www.highcharts.com/docs/chart-design-and-style/style-by-css

关于javascript - 在 highcharts-react-official 上定义和应用主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68171578/

相关文章:

javascript - webpack < 5 默认情况下用于包含 Node.js 核心模块的 Polyfill。这已不再是这种情况

Angular 单元测试函数变量

HTML 无法更新元素位置

javascript - Chart.js 2 - 如何将数据集值垂直插入条形图中?

javascript - Node Tutorial one to Many 没有加载远程服务器 Stream Spinner 移动无穷

javascript - $.children() vs $.children ('className' ) 有什么区别?

javascript - typescript typeof 字符串无法按预期工作

javascript - 如何动态更改 jQuery 数据表高度

javascript - 未捕获的类型错误 : Cannot read properties of undefined (reading 'rendered' )

reactjs - React、Redux、React-Router?