Axis offset / origin crossing
native
Move axis to cross at zero or offset it from the plot
Matrix status native. Verification render · strong. ChartKit option: ChartKitChartSpecV1.axes.x.crosses, ChartKitChartSpecV1.axes.y.offset.
axes.x.crosses is the y value the x axis passes through, so 0 draws it through zero. axes.y.crosses needs a quantitative x (CK3060). axes.y.offset shifts the axis in px, from -80 to 80. position zero, and the keys zero, origin, and axisAtZero, repair to crosses (CK3068). axisOffset repairs to offset (CK3071).
Source: chartkit:packages/core/src/renderers/cartesian.ts
ChartKit spec
Passed validate() during npm run matrix:refresh. The SVG is the server render.
{
"version": "1",
"type": "line",
"data": [
{
"quarter": "Q1",
"units": 40
},
{
"quarter": "Q2",
"units": 55
}
],
"encoding": {
"x": "quarter",
"y": "units"
},
"a11y": {
"alt": "Units rose in Q2."
},
"size": {
"width": 640,
"height": 260
},
"axes": {
"x": {
"crosses": 0,
"line": true
},
"y": {
"offset": 12
}
}
}Other libraries
Option names are the paths recorded in the matrix. A grep-only cell names the identifier that matched, not a render test. Markdown copy: axis.offset.md.
| Library | Status | Option | Verification | Source |
|---|---|---|---|---|
| Chart.js | native | grep: offsetposition: {y: 0} | grep · weak | chart.js/dist/types/layout.d.ts:3 |
| Recharts | native | YAxis.mirror, XAxis.y | types · strong | recharts/types/cartesian/YAxis.d.ts:112 |
| Apache ECharts | native | xAxis.axisLine.onZero, xAxis.offset | types · strong | echarts/types/dist/shared.d.ts:2753 |
| Highcharts | native | xAxis.offset | types · strong | highcharts/highcharts.d.ts:108503 |
| Plotly.js | native | layout.xaxis.anchor, layout.xaxis.position | types · strong | plot-schema.json#layout.layoutAttributes.xaxis.anchor |
| Nivo | native | grep: tickPadding | grep · weak | @nivo/tree/dist/types/types.d.ts:194 |
| Victory | native | VictoryAxis.offsetX, VictoryAxis.crossAxis | types · strong | victory-axis/lib/victory-axis.d.ts:8 |
| visx | native | AxisBottom.top | types · strong | @visx/axis/lib/types.d.ts:116 |
| ApexCharts | native | xaxis.offsetY | types · strong | apexcharts/types/apexcharts.d.ts:4905 |
| Tremor (npm) | none | — | absence · absence | — |
| Observable Plot | native | grep: insetTop | grep · weak | @observablehq/plot/src/scales.d.ts:314 |
| Vega-Lite | native | grep: offset | grep · weak | 350: "description" |
| AG Charts | native | grep: crossAt | grep · weak | ag-charts-types/dist/types/src/presets/quadrant/quadrantOptions.d.ts:2 |
| amCharts 5 | partial | grep: x | grep · weak | @amcharts/amcharts5/.internal/plugins/exporting/ExportingCSS.d.ts:6 |
| Google Charts | unknown | — | conflict · unknown | — |
| uPlot | unknown | — | conflict · unknown | — |
| TradingView Lightweight Charts | unknown | — | conflict · unknown | — |
| MUI X Charts | native | grep: offset | grep · weak | @mui/x-charts/SparkLineChart/SparkLineChart.d.ts:106 |
| Mermaid (chart-ish diagrams only) | unknown | — | conflict · unknown | — |
| AntV G2 | native | grep: position | grep · weak | @antv/g2/lib/index.d.ts:2 |