| 1 | /**
|
|---|
| 2 | * Defines the blank space between the chart and the plot area.
|
|---|
| 3 | * This blank space is occupied by supporting elements like axes, legends, and brushes.
|
|---|
| 4 | * This also includes any margins that might be applied to the chart.
|
|---|
| 5 | */
|
|---|
| 6 | export type ChartOffset = {
|
|---|
| 7 | /**
|
|---|
| 8 | * Distance from the top edge of the chart to the top edge of the plot area.
|
|---|
| 9 | */
|
|---|
| 10 | readonly top: number;
|
|---|
| 11 | /**
|
|---|
| 12 | * Distance from the bottom edge of the chart to the bottom edge of the plot area.
|
|---|
| 13 | * Note that this is not a coordinate, this is a distance.
|
|---|
| 14 | * Meaning, `offset.bottom` could be 0 in a perfectly fine big chart.
|
|---|
| 15 | */
|
|---|
| 16 | readonly bottom: number;
|
|---|
| 17 | /**
|
|---|
| 18 | * Distance from the left edge of the chart to the left edge of the plot area.
|
|---|
| 19 | */
|
|---|
| 20 | readonly left: number;
|
|---|
| 21 | /**
|
|---|
| 22 | * Distance from the right edge of the chart to the right edge of the plot area.
|
|---|
| 23 | * Note that this is not a coordinate, this is a distance.
|
|---|
| 24 | * Meaning, `offset.right` could be 0 in a perfectly fine big chart.
|
|---|
| 25 | */
|
|---|
| 26 | readonly right: number;
|
|---|
| 27 | };
|
|---|
| 28 | /**
|
|---|
| 29 | * Plot area is the area where the actual chart data is rendered.
|
|---|
| 30 | * This means: bars, lines, scatter points, etc.
|
|---|
| 31 | */
|
|---|
| 32 | export type PlotArea = {
|
|---|
| 33 | /**
|
|---|
| 34 | * The width of the plot area.
|
|---|
| 35 | * This will be the same as `chartWidth - offset.left - offset.right`
|
|---|
| 36 | */
|
|---|
| 37 | readonly width: number;
|
|---|
| 38 | /**
|
|---|
| 39 | * The height of the plot area.
|
|---|
| 40 | * This will be the same as `chartHeight - offset.top - offset.bottom`
|
|---|
| 41 | */
|
|---|
| 42 | readonly height: number;
|
|---|
| 43 | /**
|
|---|
| 44 | * The x coordinate of the top-left corner of the plot area.
|
|---|
| 45 | * This will be the same as `offset.left`
|
|---|
| 46 | */
|
|---|
| 47 | readonly x: number;
|
|---|
| 48 | /**
|
|---|
| 49 | * The y coordinate of the top-left corner of the plot area.
|
|---|
| 50 | * This will be the same as `offset.top`
|
|---|
| 51 | */
|
|---|
| 52 | readonly y: number;
|
|---|
| 53 | };
|
|---|