Skip to content

Commit

Permalink
TimeSeries add yAxis style property with beginAtZero (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecadavid authored Apr 26, 2023
1 parent cbffffa commit 087a7d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/react/time-series/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ The `styles` prop allows you to customize the appearance of the chart. It accept
| bar | `BarStyles` | Styles for the bars in the chart (only used in `bar` variant) |
| line | `LineStyles` | Styles for the line in the chart (only used in `line` variant) |
| point | `PointStyles` | Styles for the points in the chart |
| yAxis | `YAxisStyles` | Options for the y Axis |

### FontStyles

Expand Down Expand Up @@ -184,3 +185,9 @@ The `styles` prop allows you to customize the appearance of the chart. It accept
| borderWidth | `number` | `1` | Border width of the point in `px`. |
| hoverBorderColor | `string` | `"#000"` | Border color of the point on hover. |
| hoverBackgroundColor | `string` | `"#000"` | Background color of the point on hover. |

## yAxis Styles

| Name | Type | Default | Description |
| ----------- | --------- | ------- | ----------------------------------------------- |
| beginAtZero | `boolean` | `false` | Whether the y axis should begin at zero or not. |
1 change: 1 addition & 0 deletions packages/react/time-series/src/TimeSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export function TimeSeries(props: TimeSeriesProps) {
},
y: {
display: !hideGridLines,
beginAtZero: styles?.yAxis?.beginAtZero || defaultStyles.yAxis.beginAtZero,
grid: { drawOnChartArea: true }
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/react/time-series/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export const defaultStyles = {
borderWidth: 1,
hoverBorderColor: '#000',
hoverBackgroundColor: '#000'
},
yAxis: {
beginAtZero: false
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/react/time-series/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ export type Styles = {
backgroundColor?: string
hoverBackgroundColor?: string
}
yAxis?: {
beginAtZero?: boolean
}
}

0 comments on commit 087a7d0

Please sign in to comment.