Skip to content

Commit

Permalink
fix(types): Add missing region.label option
Browse files Browse the repository at this point in the history
- Add type definition
- Add on API example code

Fix #3732
  • Loading branch information
netil authored and netil committed Apr 15, 2024
1 parent 938f263 commit e03057c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/Chart/api/regions.ts
Expand Up @@ -42,7 +42,16 @@ function regionsFn(regions: RegionsParam, isAdd = false): RegionsParam {
* // Show 2 regions
* chart.regions([
* {axis: "x", start: 5, class: "regionX"},
* {axis: "y", end: 50, class: "regionY"}
* {
* axis: "y", end: 50, class: "regionY",
* label: {
* text: "Region Text",
* x: 5, // position relative of the initial x coordinate
* y: 5, // position relative of the initial y coordinate
* color: "red", // color string
* rotated: true // make text to show in vertical or horizontal
* }
* }
* ]);
*/
const regions = function(regions: RegionsParam): RegionsParam {
Expand All @@ -61,13 +70,28 @@ extend(regions, {
* @example
* // Add a new region
* chart.regions.add(
* {axis: "x", start: 5, class: "regionX"}
* {
* axis: "x", start: 5, class: "regionX",
* label: {
* text: "Region Text",
* color: "red" // color string
* }
* }
* );
*
* // Add new regions
* chart.regions.add([
* {axis: "x", start: 5, class: "regionX"},
* {axis: "y", end: 50, class: "regionY"}
* {
* axis: "y", end: 50, class: "regionY",
* label: {
* text: "Region Text",
* x: 5, // position relative of the initial x coordinate
* y: 5, // position relative of the initial y coordinate
* color: "red", // color string
* rotated: true // make text to show in vertical or horizontal
* }
* }
* ]);
*/
add: function(regions: RegionsParam): RegionsParam {
Expand Down
7 changes: 7 additions & 0 deletions types/options.d.ts
Expand Up @@ -408,6 +408,13 @@ export interface RegionOptions {
start?: string | number | Date;
end?: string | number | Date;
class?: string;
label?: {
text?: string;
x?: number;
y?: number;
color?: string;
rotated?: boolean;
}
}

export interface LegendOptions {
Expand Down

0 comments on commit e03057c

Please sign in to comment.