简体   繁体   English

Highcharts使用css类将自定义样式应用于上下文按钮

[英]Highcharts applying custom style to context button using css class

I have a large set of Highcharts graphics that all use the exporting.js library for downloading in various formats. 我有一大堆Highcharts图形,它们都使用exports.js库以各种格式下载。 I would like to customize the context button on these charts to match the native styles of the application. 我想在这些图表上自定义上下文按钮以匹配应用程序的本机样式。

Although I have found several examples of how to achieve this within the confines of the Highcharts chart-level script (ie THIS EXAMPLE ) it seems rather repetitive to implement these styles in every chart knowing that I have a large set to be affected. 虽然我已经在Highcharts图表级脚本(即本示例 )的范围内找到了几个如何实现这一点的例子,但是在每个图表中实现这些样式似乎相当重复,因为我知道我有一大组受影响。

I realize this could potentially be achieved using a global theme in Highcharts, however I am still limited by the configuration options of the library itself. 我意识到这可能是使用Highcharts中的全局主题实现的,但是我仍然受到库本身的配置选项的限制。

For instance this would be the suggested path: 例如,这将是建议的路径:

var chartingOptions = {
exporting: {
    buttons: {
        'myButton': {
            id: 'myButton',
            symbol: 'circle',
            x: -62,
            symbolFill: '#B5C9DF',
            hoverSymbolFill: '#779ABF'
        }
    }
}

But unfortunately it does not provide a lot of expressivity. 但不幸的是,它并没有提供很多表现力。

Am I able to define a css style and pass it to the global theme or chart set using its ID or CLASS somehow? 我能够定义一个css样式并以某种方式使用其IDCLASS将其传递给全局主题或图表集吗?

Yes, you can set class or id of button using theme property. 是的,您可以使用theme属性设置按钮的classid

buttons: {
    'myButton': {
        symbol: 'circle',
        symbolFill: '#B5C9DF',
        hoverSymbolFill: '#779ABF',
        theme: {
            class: "myButton highcharts-button highcharts-button-normal",
            id: "myDiamondButton"
        }
    }
}

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

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