Commit 57836026 authored by lynn's avatar lynn Committed by GitHub

fix: Web 1254 explore sparkline chart quality tweaks (#4732)

* init

* init

* undo random height padding

* revert weird merge mistakes

* fixes sparkline sizing

* respond to jordan comments

* add comments
parent 9ba76992
...@@ -25,8 +25,16 @@ function SparklineChart({ width, height, tokenData, pricePercentChange, timePeri ...@@ -25,8 +25,16 @@ function SparklineChart({ width, height, tokenData, pricePercentChange, timePeri
const hasData = pricePoints.length !== 0 const hasData = pricePoints.length !== 0
const startingPrice = hasData ? pricePoints[0] : DATA_EMPTY const startingPrice = hasData ? pricePoints[0] : DATA_EMPTY
const endingPrice = hasData ? pricePoints[pricePoints.length - 1] : DATA_EMPTY const endingPrice = hasData ? pricePoints[pricePoints.length - 1] : DATA_EMPTY
const widthScale = scaleLinear().domain([startingPrice.timestamp, endingPrice.timestamp]).range([0, 124]) const widthScale = scaleLinear()
const rdScale = scaleLinear().domain(getPriceBounds(pricePoints)).range([42, 0]) .domain(
// the range of possible input values
[startingPrice.timestamp, endingPrice.timestamp]
)
.range(
// the range of possible output values that the inputs should be transformed to (see https://www.d3indepth.com/scales/ for details)
[0, 110]
)
const rdScale = scaleLinear().domain(getPriceBounds(pricePoints)).range([30, 0])
/* Default curve doesn't look good for the ALL chart */ /* Default curve doesn't look good for the ALL chart */
const curveTension = timePeriod === TimePeriod.ALL ? 0.75 : 0.9 const curveTension = timePeriod === TimePeriod.ALL ? 0.75 : 0.9
...@@ -37,6 +45,7 @@ function SparklineChart({ width, height, tokenData, pricePercentChange, timePeri ...@@ -37,6 +45,7 @@ function SparklineChart({ width, height, tokenData, pricePercentChange, timePeri
getX={(p: PricePoint) => widthScale(p.timestamp)} getX={(p: PricePoint) => widthScale(p.timestamp)}
getY={(p: PricePoint) => rdScale(p.value)} getY={(p: PricePoint) => rdScale(p.value)}
curve={curveCardinal.tension(curveTension)} curve={curveCardinal.tension(curveTension)}
marginTop={5}
color={pricePercentChange && pricePercentChange < 0 ? theme.accentFailure : theme.accentSuccess} color={pricePercentChange && pricePercentChange < 0 ? theme.accentFailure : theme.accentSuccess}
strokeWidth={1.5} strokeWidth={1.5}
width={width} width={width}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment