Chart.js 在右上角绘制对角线,并限制线条超出图表范围。

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

Chart.js Plot Diagonal lines on top right and limit the lines going out of the chart

问题

我正在尝试绘制两点之间的对角线,如下图所示,但是线条超出了图表区域的底部,顶部的区域为空。

如何使线条不超出 x 轴,并计算填充顶部区域的方法?

英文:

I am trying to plot the diagonal lines between two points as shown in the below image, but the lines are going beyond the chart area in the bottom and top end is empty.

Chart.js 在右上角绘制对角线,并限制线条超出图表范围。

CodeSandBox here
https://codesandbox.io/s/nameless-dawn-nhcvjq?file=/App.tsx

How to make the lines not go beyond the x-axis, also the calculations to fill the top end area?

答案1

得分: 0

好的,我会为你翻译以下内容:

好的,我自己解决了,现在新的图表在两个 x 轴点之间有一条水平线,如下所示。

Chart.js 在右上角绘制对角线,并限制线条超出图表范围。

代码沙盒:https://codesandbox.io/s/nameless-dawn-nhcvjq?file=/App.tsx

英文:

Okay I resolved it by myself,Now the new graph with the horizontal line between two x axis point looks like below.
Chart.js 在右上角绘制对角线,并限制线条超出图表范围。

Code sandbox: https://codesandbox.io/s/nameless-dawn-nhcvjq?file=/App.tsx

huangapple
  • 本文由 发表于 2023年7月27日 17:00:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76778131.html
匿名

发表评论

匿名网友

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

确定