简体   繁体   English

如何增加类别或标签之间的 ghap react-chartjs-2

[英]How to increase the ghap between catergories or labels react-chartjs-2

I am working on react-chartjs-2 and want to increase the gap between labels to make it fit horizontal scroll.我正在研究 react-chartjs-2 并希望增加标签之间的间隙以使其适合水平滚动。

在此处输入图像描述

const data = { labels: labels, datasets: [{ axis: 'y', label: 'Line chart', data: [7, 6, 2, 7, 6, 7, 8, 7] fill: false, backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(255, 159, 64, 0.2)', 'rgba(255, 205, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(201, 203, 207, 0.2)' ], borderColor: [ 'rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(54, 162, 235)', 'rgb(153, 102, 255)', 'rgb(201, 203, 207)' ], borderWidth: 2 }] }; const data = {标签:标签,数据集:[{轴:'y',label:'折线图',数据:[7、6、2、7、6、7、8、7]填充:假,背景颜色: [ 'rgba(255, 99, 132, 0.2)', 'rgba(255, 159, 64, 0.2)', 'rgba(255, 205, 86, 0.2)', 'rgba(75, 192, 192, 0.2) )', 'rgba(54, 162, 235, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(201, 203, 207, 0.2)' ], 边框颜色: ['rgb(255) , 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(54, 162, 235)' , 'rgb(153, 102, 255)', 'rgb(201, 203, 207)' ], 边框宽度: 2 }] }; I tried to add options but it is not helping.我试图添加选项,但它没有帮助。

link https://www.npmjs.com/package/react-chartjs-2链接https://www.npmjs.com/package/react-chartjs-2

Note: On the top of this chart I have images that show the record related to this chart.注意:在此图表的顶部,我有显示与此图表相关的记录的图像。 The images have horizontal scroll but the chart does not have.图像有水平滚动,但图表没有。 If we increase the gap between the chart circles and so it will be fixed to the images gap.如果我们增加图表圆圈之间的间隙,那么它将被固定为图像间隙。

在此处输入图像描述

You can see the images gape.你可以看到图像裂开。 The rest of the images is in a horizontal scroll and if the gap increase I want the chart also to be in the scroll.图像的 rest 处于水平滚动状态,如果间隙增加,我希望图表也处于滚动状态。

End result should be like that最终结果应该是这样的

在此处输入图像描述

I found the answer.我找到了答案。

<line
  data={data}
  width={100}
  height={50}
  options={{ maintainAspectRatio: false }}
/>

enter link description here 在此处输入链接描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM