如何启用 Highcharts 滚动条?

发布于 2025-01-08 10:32:36 字数 150 浏览 2 评论 0原文

我尝试这样做

scrollbar: {
    enabled: true
}

但没有成功。

我尝试使用 highstocks 附带的 highcharts.js ..但这也不起作用。 我做错了什么吗?

I tried doing the

scrollbar: {
    enabled: true
}

But it didnt work.

I tried using the highcharts.js that comes with highstocks.. that did not work either.
Am I doing something wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

叹沉浮 2025-01-15 10:32:36

如果您的代码仍然不起作用,您可以尝试更改此:

<script type="text/javascript" src="js/highcharts.js"></script>

使用此:

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

并且您可以添加此:

scrollbar: {
    enabled: true
},

最后,您可以添加此以指定一次要查看的数据点数量,例如“min:6”:

xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
    min: 6   <!-- LOOK at this -->
},

If your code still doesn't work, you could try changing this :

<script type="text/javascript" src="js/highcharts.js"></script>

with this :

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

and you can add this :

scrollbar: {
    enabled: true
},

finally, you can add this for how many data points you want to view at a time, example " min: 6 " :

xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
    min: 6   <!-- LOOK at this -->
},
魂归处 2025-01-15 10:32:36

此处已经回答了类似的问题。

你可以参考这个:如何在highcharts中启用滚动条

var chart = new Highcharts.Chart({
chart: {
    renderTo: 'container'
},
xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
    min: 6
},

legend: {
    verticalAlign: 'top',
    y: 100,
    align: 'right'
},

scrollbar: {
    enabled: true
},

series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});

A similar question has already been answer here.

You can refer to this: How to enable scrollbars in highcharts

var chart = new Highcharts.Chart({
chart: {
    renderTo: 'container'
},
xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
    min: 6
},

legend: {
    verticalAlign: 'top',
    y: 100,
    align: 'right'
},

scrollbar: {
    enabled: true
},

series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
瀟灑尐姊 2025-01-15 10:32:36

在回答这个问题时,可以通过 highstock js 添加滚动条。
我成功地为我的柱形图实现了一个优雅而简单的滚动条解决方案,仅使用 highcharts js,而不使用 highstock,如下所示:

chart: {
   type: 'column',
   scrollablePlotArea: {
   minWidth: {{ count($period_interval_categories) * 70}},
        // nr of interval data x (40 + 30) where 40 are column width pixels and
        // 30 is additional distancing between columns;
        // Increase spacing pixels if needed
   scrollPositionX: 1
   }
},
plotOptions: {
   column: {
       stacking: 'normal',
       pointWidth: 40, // column width in pixels
       dataLabels: {
           // enabled: true
       }
    }
},

其中 $period_interval_categories 在我的图表中表示 x 轴上的周期,由天、周、月等组成。

在此处输入图像描述

At the time of this answer, scrollbar can be added via highstock js.
I managed to implement an elegant and simple scrollbar solution to my column chart, using only highcharts js, without highstock, as follows:

chart: {
   type: 'column',
   scrollablePlotArea: {
   minWidth: {{ count($period_interval_categories) * 70}},
        // nr of interval data x (40 + 30) where 40 are column width pixels and
        // 30 is additional distancing between columns;
        // Increase spacing pixels if needed
   scrollPositionX: 1
   }
},
plotOptions: {
   column: {
       stacking: 'normal',
       pointWidth: 40, // column width in pixels
       dataLabels: {
           // enabled: true
       }
    }
},

where $period_interval_categories represents in my chart the period on x axis consisting of days, weeks, months, etc.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文