您应该能够在库存工具定义中定义signle 项目,但Highcharts 中有一个错误,此处报告:https ://github.com/highcharts/highcharts/issues/10980
作为一种解决方法,您可以将第一个元素定义为空:items: [, 'measureX']
或创建自己的按钮,而不是从列表中删除项目:
{
...,
stockTools: {
gui: {
buttons: ['indicators', 'separator', 'simpleShapes', 'lines', 'crookedLines', 'myMeasure', 'advanced', 'toggleAnnotations', 'separator', 'verticalLabels', 'flags', 'separator', 'zoomChange', 'fullScreen', 'typeChange', 'separator', 'currentPriceIndicator', 'saveChart'],
definitions: {
myMeasure: {
className: 'highcharts-measure-x',
symbol: 'measure-x.svg'
}
}
}
},
navigation: {
bindings: {
myMeasure: Highcharts.getOptions().navigation.bindings.measureX
}
},
...
}
现场演示: https ://jsfiddle.net/BlackLabel/mrj6badh/
API 参考: https ://api.highcharts.com/highstock/stockTools.gui.definitions.measure.items