CoralAreaChart
Basic Usage
import { CoralAreaChart } from '@krakentech/coral-charts';
<CoralAreaChart
data={[
{
x: '00',
y: 1000,
},
{
x: '01',
y: 500,
},
...
]}
/>;Modifiers
All of the generic modifiers are available, plus an additional area property.
CoralAreaChart has an extended data property, with adds an additional y0 property to the standard ChartData[] type. This allows you to build a range chartΒ which offsets the y-axis points from the x-axis, rather than aligning the area to the baseline.
Default modifiers
AreaChart has the following modifiers set by default.
modifiers: {
chart: {
domainPadding: { x: [2, 0] },
},
}Full API
modifiers API
| Name | Type | Default |
|---|---|---|
height | number | |
legend.showLegend | booleanShould the legend show? | false |
legend.renderedWidth | numberWhen horizontalPosition is set to | |
legend.horizontalPosition | "center" | "right" | "left"The position of the legend on the horizontal axis. | |
legend.verticalPosition | "top" | "bottom"Set whether the legend be positioned above or below the chart. | |
legend.verticalPositionAdjustment | numberWhen assigning verticalPosition to | |
legend.legendData | readonly any[] | undefinedThe series data to be displayed in the legend. | |
legend.legendColorScale | ColorScalePropTypeThe color scale to be used for the legend. This will be mapped to the series data. | |
legend.itemsPerRow | numberDefine how many items to show per row on the legend, the default will run all series on one line without wrapping them. | |
legend.dataComponent | React.ReactElementProvide a custom series data icon, rather than the default coloured square. | |
yAxis.orientation | "right" | "left"Set the position of the y-axis to the left or right of the chart. | left |
yAxis.axisLabel | stringProvides a label for the y-axis. | |
yAxis.axisLabelPadding | numberProvide offset padding to the axis label from the y-axis line. | |
yAxis.tickFormat | any[] | ((tick: any, index: number, ticks: any[]) => string | number) | undefinedSpecify how tick values should be formatted. This is likely to be function that takes a value and returns a formatted string, i.e. | |
yAxis.domain | [number, number]Manually specify the range of data the chart will include, given as an array of the minimum and maximum expected values. This will override the default domain calculation which works out the minimum and maximum values from the supplied data. If you pass a minimum or maximum value that is more or less than the minimum or maximum value in the data, the chart will still include the minimum or maximum value from the data. | |
xAxis.orientation | "top" | "bottom"Set the position of the x-axis to the top or bottom of the chart. | top |
xAxis.fixTickLabelOverlap | booleanDynamically adjust how many ticks show to prevent collision of ticks. | |
xAxis.axisLabel | stringProvides a label for the x-axis. | |
xAxis.axisLabelPadding | numberProvide offset padding to the axis label from the x-axis line. | |
xAxis.tickCount | numberDefine approximately how many ticks to show on the x-axis. Prioritizes returning βniceβ values and evenly spaced ticks over an exact number of ticks. | |
xAxis.tickFormat | any[] | ((tick: any, index: number, ticks: any[]) => string | number) | undefinedSpecify how tick values should be formatted. This is likely to be function that takes a value and returns a formatted string, i.e. | |
xAxis.tickPadding | numberSpecify how many pixels apart the ticks should be spaced.. | |
xAxis.tickAngle | numberSpecify an angle that the ticks should be rotated to. | 0 |
xAxis.textAnchor | "start" | "middle" | "end" | "inherit"Specify the point within the text that should align with the x-coordinate of the labelβs position. | |
xAxis.domain | [number, number]Manually specify the range of data the chart will include, given as an array of the minimum and maximum expected values. Note you should only attempt to apply this property if your independent domain is numeric. | |
xAxis.offsetY | numberManually specify how far from the edge of its calculated position an axis should be offset in the y direction. | |
chart.domainPadding | ForAxes<PaddingType>Specify a number of pixels of padding to add to the beginning or end of a domain. This prop is useful for explicitly spacing data elements farther from the beginning or end of a domain to prevent axis crowding. https://formidable.com/open-source/victory/docs/common-props#domainpaddingΒ | |
chart.padding | PaddingPropsAmount of padding in number of pixels between the edge of the chart and any rendered child components https://formidable.com/open-source/victory/docs/common-props#paddingΒ | |
tooltip.showTooltips | booleanShould the tooltip be shown on hover? | true |
tooltip.labelFormat | string[] | number[] | ((data: any) => string | number | string[] | number[] | null) | undefinedSpecify how labels values should be formatted. This is likely to be function that takes a value and returns a formatted string, i.e. | |
area.interpolation | InterpolationPropTypePresentation of the area line. | linear |
area.showCursorLine | booleanIf | |
area.cursorLineColour | stringSupply an override for the default colour of the cursor line. | |
area.fillColour | stringSupply an override for the default fill colour of the area. | |
area.customFlyout | ElementProvide a custom flyout to be rendered on hover. |