Highcharts: 使滚动条仅覆盖绘图区域

huangapple go评论116阅读模式
英文:

Highcharts: Make scrollbar only cover the plot area

问题

这是一个示例图表的演示,基于highcharts文档中的滚动条教程:https://jsfiddle.net/zao68u2k/1/
我对默认演示唯一的更改是通过以下方式移除了遮罩:

scrollablePlotArea: {
  opacity: 1,
}

现在遮罩已经消失了,滚动条占据整个图表的宽度就没有意义了。我想缩短滚动条,使其只占据绘图区域的宽度,不包括坐标轴,就像我在图片中模拟的那样。这个是否可能?

Highcharts: 使滚动条仅覆盖绘图区域

英文:

Here's a fiddle of a sample chart, based on the scrollbar tutorial on highcharts' docs here: https://jsfiddle.net/zao68u2k/1/
The only changes I made to the default demo were to remove the mask via:

scrollablePlotArea: {
  opacity: 1,
}

Now that the mask is gone, it does not make sense for the scrollbar to take up the entire width of the chart. I would like to shorten the scrollbar so that it is only the width of the plot itself and does not include the axis, as I have mocked up in the picture. Is this possible?

Highcharts: 使滚动条仅覆盖绘图区域

答案1

得分: 1

在这种情况下,您应该使用xAxis.scrollbar属性而不是chart.scrollablePlotArea,并设置xAxis.minxAxis.max

xAxis: {
    min: Date.UTC(2023, 6, 1),
    max: Date.UTC(2023, 6, 1, 3),
    scrollbar: {
        enabled: true
    }
}

然而,这是Stock提供的功能,因此需要拥有此产品的许可证,并在项目中导入适当的库:

<script src="https://code.highcharts.com/stock/highstock.js"></script>

演示: https://jsfiddle.net/BlackLabel/rvm1s67w/
API: https://api.highcharts.com/highstock/xAxis.scrollbar

英文:

In this case instead of chart.scrollablePlotArea you should use the xAxis.scrollbar property with xAxis.min and xAxis.max:

xAxis: {
    min: Date.UTC(2023, 6, 1),
    max: Date.UTC(2023, 6, 1, 3),
    scrollbar: {
        enabled: true
    }
}

However, this is a functionality offered by Stock, so it is necessary to have a license for this product and import the appropriate library in the project:

&lt;script src=&quot;https://code.highcharts.com/stock/highstock.js&quot;&gt;&lt;/script&gt;

Demo: https://jsfiddle.net/BlackLabel/rvm1s67w/ <br/>
API: https://api.highcharts.com/highstock/xAxis.scrollbar

huangapple
  • 本文由 发表于 2023年6月30日 03:42:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76584171.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定