Skip to content

Commit

Permalink
feat: ✨ improve price scale
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideSegullo committed Jul 3, 2024
1 parent 860a8c4 commit 6d486c3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
16 changes: 15 additions & 1 deletion packages/web/components/chart/historical-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@ export const HistoricalChart = memo((props: HistoricalChartProps) => {
series={[
{
type: "Area",
options: seriesOpt,
options: {
...seriesOpt,
autoscaleInfoProvider: () => {
const values = data
.map((entry) => entry.value)
.filter((entry) => entry >= 0);

return {
priceRange: {
minValue: Math.min(...values),
maxValue: Math.max(...values),
},
};
},
},
data,
},
]}
Expand Down
16 changes: 15 additions & 1 deletion packages/web/components/chart/historical-volume-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,21 @@ export const HistoricalVolumeChart = memo(
series={[
{
type: "Histogram",
options: seriesOpt,
options: {
...seriesOpt,
autoscaleInfoProvider: () => {
const values = data
.map((entry) => entry.value)
.filter((entry) => entry >= 0);

return {
priceRange: {
minValue: Math.min(...values),
maxValue: Math.max(...values),
},
};
},
},
data,
},
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class AreaChartController<

if (params.series && params.series.length > 0) {
for (const [key, s] of params.series.entries()) {
this.series[key].applyOptions(s.options);
this.series[key].setData(s.data);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/web/hooks/ui-config/use-asset-info-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const useAssetInfoConfig = (
numRecentFrames = 14;
break;
case "1d":
frame = 60;
numRecentFrames = 25;
frame = 15;
numRecentFrames = 97;
break;
case "7d":
frame = 720;
Expand Down

0 comments on commit 6d486c3

Please sign in to comment.