fix(ui-toolkit): sparkline appearing to go up when the price moved down (#5137)
This commit is contained in:
parent
142f08343b
commit
0ebfab64ff
@ -72,7 +72,7 @@ LessThan24HoursIncrease.args = {
|
|||||||
|
|
||||||
export const LessThan24HoursDecrease = Template.bind({});
|
export const LessThan24HoursDecrease = Template.bind({});
|
||||||
LessThan24HoursDecrease.args = {
|
LessThan24HoursDecrease.args = {
|
||||||
data: [20, 21, 22, 23, 24, 6, 7, 9, 11, 13, 11, 9],
|
data: [20990000, 20939973, 20980130],
|
||||||
width: 110,
|
width: 110,
|
||||||
height: 30,
|
height: 30,
|
||||||
};
|
};
|
||||||
|
@ -44,14 +44,12 @@ export const SparklineView = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const midValue = (min + max) / 2;
|
|
||||||
|
|
||||||
// Market may be less than 24hr old so padd the data array
|
// Market may be less than 24hr old so padd the data array
|
||||||
// with values that is the mid value (avg of min and max).
|
// with values that is the mid value (avg of min and max).
|
||||||
// This will rendera horizontal line until the real data shifts the line
|
// This will rendera horizontal line until the real data shifts the line
|
||||||
const padCount = data.length < points ? points - data.length : 0;
|
|
||||||
const padArr = new Array(padCount).fill(midValue);
|
|
||||||
const trimmedData = data.slice(-points);
|
const trimmedData = data.slice(-points);
|
||||||
|
const padCount = data.length < points ? points - data.length : 0;
|
||||||
|
const padArr = new Array(padCount).fill(trimmedData[0]);
|
||||||
|
|
||||||
// Get the last 24 values if data has more than needed
|
// Get the last 24 values if data has more than needed
|
||||||
const lineData: [number, number][] = [...padArr, ...trimmedData].map(
|
const lineData: [number, number][] = [...padArr, ...trimmedData].map(
|
||||||
|
Loading…
Reference in New Issue
Block a user