Open AnnelyseBe opened 1 month ago
Hey there, @AnnelyseBe! I'm a bot here to help you with any bugs, questions, or contributions you have for Superset. Let's tackle this issue together!
Yes, it is possible to fix the issue where the annotation formula on a chart does not work for values above 1*10^15 in Superset version 4.0.2. The issue is likely due to the limitations of JavaScript's Number
type, which can cause precision errors for very large numbers.
To address this, you can use the BigInt
type for handling large integers. However, BigInt
does not support floating-point numbers. If you need to handle large floating-point numbers, you might need to use a library like decimal.js
or big.js
.
Here is an example of how you can modify the evalExpression
function to use BigInt
for large integers:
function evalExpression(expression, x) {
// Check if x is greater than 1*10^15 and convert to BigInt if necessary
const xValue = x > 1e15 ? BigInt(x) : x;
// Use Function constructor to evaluate the expression
const func = new Function('x', `return ${expression}`);
return func(xValue);
}
This modification ensures that the x
value is converted to BigInt
if it exceeds 1*10^15, which should help in handling large values without precision errors [1].
To continue talking to Dosu, mention @dosu.
Bug description
I wanted to add an annotation to my area chart to indicate the max value. But I noticed that it only works until the value of 1 10^15 (which is 1 petabyte). I wanted to draw the line at 2 10^15, which is the maximum storage we have available, but the graph disappears from the moment I exceed 1* 10^15
is it possible to fix this?
How to reproduce the bug
Screenshots/recordings
Superset version
4.0.2
Python version
I don't know
Node version
I don't know
Browser
Chrome
Additional context
No response
Checklist