Skip to content

Commit

Permalink
update heatmap visualmap (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgerstmayr authored Feb 12, 2025
1 parent bc232bd commit 733e997
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 318 deletions.
14 changes: 4 additions & 10 deletions frontend/src/pages/Returns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function ReturnsHeatmapChart({ method }: ReturnsHeatmapChartProps) {
return <Alert severity="error">{error.message}</Alert>;
}

const max = Math.max(...data.returns.map(([_date, val]) => Math.abs(val)));
const max = Math.max(...data.returns.map(([label, val]) => (label.includes("-") ? Math.abs(val) : 0)));
const maxRounded = Math.round(max * 100) / 100;
const valueFormatter = method === "monetary" ? getIntegerCurrencyFormatter(targetCurrency) : percentFormatter;
const monthFormatter = new Intl.DateTimeFormat(undefined, { month: "short" }).format;
Expand All @@ -71,28 +71,22 @@ function ReturnsHeatmapChart({ method }: ReturnsHeatmapChartProps) {
valueFormatter,
},
grid: {
bottom: "100", // space for visualMap
bottom: 100, // space for visualMap
},
xAxis: {
type: "category",
splitArea: {
show: true,
},
},
yAxis: {
type: "category",
splitArea: {
show: true,
},
},
visualMap: {
min: -maxRounded,
max: maxRounded,
calculable: true, // show handles
orient: "horizontal",
left: "center",
bottom: "0", // place visualMap at bottom of chart
itemHeight: "400", // width
bottom: 0, // place visualMap at bottom of chart
itemHeight: 400, // width
inRange: {
color: [NEGATIVE_NUMBER_COLOR, "#fff", POSITIVE_NUMBER_COLOR],
},
Expand Down
Binary file modified frontend/tests/e2e/__image_snapshots__/returns_mdm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/tests/e2e/__image_snapshots__/returns_twr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 733e997

Please sign in to comment.