gpt4 book ai didi

javascript - 图表 : How can I group datasets closer if I have maxBarThickness set?

转载 作者:行者123 更新时间:2023-11-30 13:48:17 26 4
gpt4 key购买 nike

我有一个图表,我在轴上设置了一个 maxBarThickness。当图表填充了大量数据时,数据集靠得很近,但当只有几个数据点时,数据集看起来很远。 exemplified in this image

我曾尝试将 categoryPercentage 设置为较小的百分比,但是当图表填充了大量数据(或页面调整大小时)时,图表看起来不对。任何帮助将不胜感激。

最佳答案

根据 this github issue如果您决定设置 barThickness,则无法更改条之间的空间(我假设它在设置 maxBarThickness 时也不起作用,但我可能错了,如果是这样的话,我'我会删除这个答案)

根据前面的链接,您有两种解决方案:

  • 如果您想保持条形粗细(对 github 问题的回答):

If you don't want to stretch out the bar to fill the extra space, you have to reduce the width of the canvas.

  • 否则,您可以在图表上设置 barPercentagecategoryPercentage,而不设置 barThicknessmaxBarThickness:

    scales: {
    xAxes: [{
    categoryPercentage: 0.8,
    barPercentage: 0.9
    }]
    },

这些是默认值。


相关问题:

Chart.js Bar Chart: How to remove space between the bars in v2.3?

CharJS 2.5.0 - How to remove space between bars

Reduce space between ticks in horizontal bar-chart chartJS

关于javascript - 图表 : How can I group datasets closer if I have maxBarThickness set?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58851984/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com