javascript - 在绘制之前为(自定义)按钮设置初始状态 - HighCharts
问题描述
在 HighCharts 中,有没有办法在绘制图表之前定义按钮的初始/默认状态?
现在我在绘制图表后执行一个函数并禁用我的一些自定义按钮(范围按钮)
chart.exportSVGElements[X].setState(3)
但我想知道是否不可能简单地定义一些东西
states: {
hover: {
lineWidth: 2
}
},
currentState: 3
在我的“配置”对象中。
提前致谢,如果我在文档中遗漏了它,我们深表歉意
编辑:是的对不起你是对的我没有展示我如何初始化我的按钮:
exporting: {
sourceWidth: 1400,
sourceHeight: 600,
scale: 1,
buttons: {
contextButton: {
menuItems: [
'printChart',
'separator',
'downloadPNG',
'downloadJPEG',
'downloadPDF',
'downloadSVG',
'separator',
'downloadCSV',
'downloadXLS',
'separator',
{
text: 'Delete graph',
onclick: function() {
deleteGraph(this.renderTo.id);
}
}
]
},
customButton: { //Add Serie Button
onclick: function (e) {
if( $(this.renderTo).hasClass("is-monitoring") ){
toastr.error("Unable to add a new serie during monitoring.");
return false;
}
toggleFiltreWidthFromChart(this);
},
className: UI_IDs.customHighChartsAddPointButton,
symbol: 'deleteGraphe',
symbolStroke: 'red'
},
j_1: {
text: "YTD",
className: UI_IDs.customHighChartsZoomButton + " j_1",
onclick: function (event) {
if (this.series.length < 0)
return false;
var max = this.xAxis[0].dataMax,
range = 24 * 3600 * 1000; //one day
this.xAxis[0].setExtremes(max - range, max);
}
},
j_7: {
text: "Last week",
className: UI_IDs.customHighChartsZoomButton + " j_7",
onclick: function (event) {
if (this.series.length < 0)
return false;
var max = this.xAxis[0].dataMax,
range = 7 * 24 * 3600 * 1000; //7 days
this.xAxis[0].setExtremes(max - range, max);
}
},
j_30: {
text: "30 derniers jours",
className: UI_IDs.customHighChartsZoomButton + " j_30",
onclick: function (event) {
if (this.series.length < 0)
return false;
var max = this.xAxis[0].dataMax,
range = 30 * 24 * 3600 * 1000; //30 days
this.xAxis[0].setExtremes(max - range, max);
}
},
j_all: {
text: "See All",
className: UI_IDs.customHighChartsZoomButton + " j_all",
onclick: function (event) {
this.zoomOut();
}
},
remove_last_annotation: {
symbol: removeLastAnnotation,
symbolX:19,
symbolY:19,
_titleKey: "removeLastAnnotation",
className: UI_IDs.removeLastAnnotation_base64,
onclick: function (event) {
if (this.annotations.length < 1)
return false;
this.annotations[this.annotations.length-1].destroy();
this.annotations.splice(this.annotations.length-1, 1);
}
}
}
}
这是定义“默认”配置的大型 JS 对象的一部分,当用户希望创建新图形时,我调用(并存储)
charts.push(Highcharts.chart(graphId, config, function(){
...
}));
解决方案
推荐阅读
- javascript - setTimeout 中的 setState 返回令人困惑的结果
- python - 如何将每个圆圈连接到pygame的左上角?
- c++ - 用 std::move 分配一个 unique_ptr 不起作用
- sql - 如何使用具有整数列名的表?
- android - 第一个代码和第二个代码有什么区别,为什么要添加getString?
- android - EditText 中的 getText 返回空值
- django - 在 Django 模板中将 Markdown 渲染为 HTML
- python - 查找 3D numpy 数组的 y 坐标的最大值和最小值
- angular - NgRx 测试 - 订阅回调在测试期间未更新
- c# - 如何通过 UWP 中的页面传递列表