Open skie1997 opened 3 months ago
Hi team, I'm working on this issue. Can I ask some questions before doing the further work?
My idea is to detect the min and max values and throw the error when min >= max. something like:
const domain = angleAxis.getScale().domain();
// min >= max
if (domain[0] >= domain[1]) {
throw new Error('Invalid domain: min value should be less than max value.');
}
I've created a draft PR (WIP) but I think I need further assistance to improve it. Thank you for all the help!
For my current PR, I believe it's not a good way to assert domain[0] >= domain[1]
in protected _getAngleAxis()
because it violates the single responsibility principle of that function.
I tried calling _getAngleAxis()
in gauge.ts
and asserting that domain[0] >= domain[1]
in initData()
here. However, it seems that initData()
does not run when I create a gauge chart (like in the example provided in the draft PR).
Can anyone tell me the better place to do the assertion domain[0] >= domain[1]
?
Raising an error when min >= max may not be the best practice. Do you have any other suggestions?
@Crayon-ShinChan Exactly as what you said in Question2, in a utility library, exceptions should not be overused. I think it would be better to consider optimizing the chart display in this case rather than directly throwing an exception.
@Crayon-ShinChan Exactly as what you said in Question2, in a utility library, exceptions should not be overused. I think it would be better to consider optimizing the chart display in this case rather than directly throwing an exception.
Thanks for the reply. Could you elaborate "optimizing the chart"? For example, like show text "Please set min value to be less than max value" to users?
Actually, there are several situations:
If "optimizing the chart" means show some chart to users, we may only consider the 1.(i) condition?
@Crayon-ShinChan Exactly as what you said in Question2, in a utility library, exceptions should not be overused. I think it would be better to consider optimizing the chart display in this case rather than directly throwing an exception.
Thanks for the reply. Could you elaborate "optimizing the chart"? For example, like show text "Please set min value to be less than max value" to users?
Actually, there are several situations:
min = max
- data point value = min = max (In this case, we may draw something, like "optimizing the chart display" as you said?)
- data point value != min = max (In this case, the data and config should be considered as invalid and I think we shouldn't show any chart to users)
- min > max (invalid config, and we shouldn't show any chart to users)
If "optimizing the chart" means show some chart to users, we may only consider the 1.(i) condition?
good question, actually we don't care data point value and only consider about domain, we classify it into the following situations:
What problem does this feature solve?
环形进度图最大值 = 最小值,应该有兜底绘图策略,比如,直接不绘制
What does the proposed API look like?
null