Skip to content

Commit

Permalink
✨ (line chart) set y-axis min default to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Oct 24, 2024
1 parent f65773a commit 20c4807
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/@ourworldindata/grapher/src/axis/AxisConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export class AxisConfig

deleteRuntimeAndUnchangedProps(obj, new AxisConfigDefaults())

if (obj.min === undefined) obj.min = AxisMinMaxValueStr.auto
if (obj.max === undefined) obj.max = AxisMinMaxValueStr.auto

return obj
Expand Down
2 changes: 2 additions & 0 deletions packages/@ourworldindata/grapher/src/lineCharts/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,8 @@ export class LineChart
// horizontal axis to be at the bottom of the chart.
// see https://github.com/owid/owid-grapher/pull/975#issuecomment-890798547
singleValueAxisPointAlign: AxisAlign.start,
// default to a minimum value of 0 if not set
min: 0,
...this.manager.yAxisConfig,
},
this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const defaultGrapherConfig = {
maxTime: "latest",
yAxis: {
removePointsOutsideDomain: false,
min: "auto",
scaleType: "linear",
max: "auto",
canChangeScaleType: false,
Expand Down Expand Up @@ -66,7 +65,6 @@ export const defaultGrapherConfig = {
},
xAxis: {
removePointsOutsideDomain: false,
min: "auto",
scaleType: "linear",
max: "auto",
canChangeScaleType: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,9 @@ $defs:
type: string
description: Axis label
min:
description: Minimum domain value of the axis. Inferred from data if set to "auto".
default: auto
description: |
Minimum domain value of the axis. Inferred from data if set to "auto".
Usually defaults to "auto", but defaults to 0 for line charts on the y-axis.
oneOf:
- type: number
- type: string
Expand Down

0 comments on commit 20c4807

Please sign in to comment.