diff --git a/.changeset/mighty-ghosts-drive.md b/.changeset/mighty-ghosts-drive.md new file mode 100644 index 000000000..2bc5fba83 --- /dev/null +++ b/.changeset/mighty-ghosts-drive.md @@ -0,0 +1,6 @@ +--- +'hostd': minor +'renterd': minor +--- + +All graphs now remember any chart configuration that the user has selected. diff --git a/.changeset/small-apricots-sort.md b/.changeset/small-apricots-sort.md new file mode 100644 index 000000000..183b6b6bb --- /dev/null +++ b/.changeset/small-apricots-sort.md @@ -0,0 +1,5 @@ +--- +'@siafoundation/design-system': minor +--- + +ChartXY now remembers any chart configuration that the user has selected per unique chart. diff --git a/apps/hostd/components/Home/HomeBandwidth.tsx b/apps/hostd/components/Home/HomeBandwidth.tsx index dec277fc0..7cfcb2c36 100644 --- a/apps/hostd/components/Home/HomeBandwidth.tsx +++ b/apps/hostd/components/Home/HomeBandwidth.tsx @@ -34,7 +34,7 @@ export function HomeBandwidth() { /> diff --git a/apps/hostd/components/Home/HomeContracts.tsx b/apps/hostd/components/Home/HomeContracts.tsx index de85a3742..9b2cefc7b 100644 --- a/apps/hostd/components/Home/HomeContracts.tsx +++ b/apps/hostd/components/Home/HomeContracts.tsx @@ -46,7 +46,7 @@ export function HomeContracts() { /> diff --git a/apps/hostd/components/Home/HomeOperations.tsx b/apps/hostd/components/Home/HomeOperations.tsx index 6c8c66169..8931b6644 100644 --- a/apps/hostd/components/Home/HomeOperations.tsx +++ b/apps/hostd/components/Home/HomeOperations.tsx @@ -37,7 +37,7 @@ export function HomeOperations() { /> {graphMode === 'spending' && !selectedContract && ( ( >('center') const [gridProps, setGridProps] = useState<[boolean, boolean]>([false, false]) const [showGridRows, showGridColumns] = gridProps - const [xAxisOrientation, setXAxisOrientation] = useState<'top' | 'bottom'>( - 'bottom' - ) - const [yAxisOrientation, setYAxisOrientation] = useState<'left' | 'right'>( - 'right' - ) + const [xAxisOrientation, setXAxisOrientation] = useLocalStorageState< + 'top' | 'bottom' + >(`${id}/xAxisOrientation`, { + defaultValue: 'bottom', + }) + const [yAxisOrientation, setYAxisOrientation] = useLocalStorageState< + 'left' | 'right' + >(`${id}/yAxisOrientation`, { + defaultValue: 'right', + }) const [showTooltip, setShowTooltip] = useState(true) const [showVerticalCrosshair, setShowVerticalCrosshair] = useState(true) const [showHorizontalCrosshair, setShowHorizontalCrosshair] = useState(false) const [snapTooltipToDatum, setSnapTooltipToDatum] = useState(true) const [sharedTooltip, setSharedTooltip] = useState(true) - const initialChartType = config.chartType || defaultChartType - const initialCurveType = config.curveType || defaultCurveType - const initialStackOffset = config.stackOffset || defaultStackOffset + const [chartType, setChartType] = useLocalStorageState( + `${id}/chartType`, + { + defaultValue: config.chartType || defaultChartType, + } + ) + const [curveType, setCurveType] = useLocalStorageState( + `${id}/curveType`, + { + defaultValue: config.curveType || defaultCurveType, + } + ) + const [stackOffset, setStackOffset] = useLocalStorageState( + `${id}/stackOffset`, + { + defaultValue: config.stackOffset || defaultStackOffset, + } + ) + + // eslint-disable-next-line react-hooks/exhaustive-deps + const initialChartType = useMemo(() => config.chartType, []) + // eslint-disable-next-line react-hooks/exhaustive-deps + const initialCurveType = useMemo(() => config.curveType, []) + // eslint-disable-next-line react-hooks/exhaustive-deps + const initialStackOffset = useMemo(() => config.stackOffset, []) - const [chartType, setChartType] = useState(initialChartType) - const [curveType, setCurveType] = useState(initialCurveType) const isLine = ['line', 'area', 'areastack'].includes(chartType) const isStack = ['barstack', 'areastack'].includes(chartType) - const [stackOffset, setStackOffset] = - useState(initialStackOffset) const glyphOutline = theme.xyChartTheme.gridStyles.stroke const [enableTooltipGlyph, setEnableTooltipGlyph] = useState(false) const [tooltipGlyphComponent, setTooltipGlyphComponent] = useState<