From e03057c4f6396ad2b49dfb9ee3ac62f2386f11f2 Mon Sep 17 00:00:00 2001 From: Jae Sung Park Date: Mon, 15 Apr 2024 12:06:16 +0900 Subject: [PATCH] fix(types): Add missing region.label option - Add type definition - Add on API example code Fix #3732 --- src/Chart/api/regions.ts | 30 +++++++++++++++++++++++++++--- types/options.d.ts | 7 +++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Chart/api/regions.ts b/src/Chart/api/regions.ts index b1309154b..8e80d35f9 100644 --- a/src/Chart/api/regions.ts +++ b/src/Chart/api/regions.ts @@ -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 { @@ -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 { diff --git a/types/options.d.ts b/types/options.d.ts index e64228490..3de78027e 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -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 {