Skip to content

Commit

Permalink
feat(types): Add area-step-range chart type
Browse files Browse the repository at this point in the history
  • Loading branch information
vlaforet committed May 21, 2024
1 parent 6ad0554 commit 2a763d2
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion demo/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ var billboardDemo = {

// UMD
code.data = code.data.join("")
.replace(/"(area|area-line-range|area-spline|area-spline-range|area-step|bar|bubble|candlestick|donut|gauge|line|pie|polar|radar|scatter|spline|step|treemap|selection|subchart|zoom)(\(\))?",?/g, function(match, p1, p2, p3, offset, string) {
.replace(/"(area|area-line-range|area-spline|area-spline-range|area-step|area-step-range|bar|bubble|candlestick|donut|gauge|line|pie|polar|radar|scatter|spline|step|treemap|selection|subchart|zoom)(\(\))?",?/g, function(match, p1, p2, p3, offset, string) {
var module = camelize(p1);

code.esm.indexOf(module) === -1 &&
Expand Down
1 change: 1 addition & 0 deletions demo/types/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Types = {
"area-spline",
"area-spline-range",
"area-step",
"area-step-range",
"bar",
"grouped-bar",
"bubble",
Expand Down
9 changes: 5 additions & 4 deletions src/config/Options/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default {
* - area-spline
* - area-spline-range
* - area-step
* - area-step-range
* - bar
* - bubble
* - candlestick
Expand Down Expand Up @@ -575,7 +576,7 @@ export default {

/**
* Set a callback for minimum data
* - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
* - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
* @name data․onmin
* @memberof Options
* @type {Function}
Expand All @@ -591,7 +592,7 @@ export default {

/**
* Set a callback for maximum data
* - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
* - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
* @name data․onmax
* @memberof Options
* @type {Function}
Expand Down Expand Up @@ -698,7 +699,7 @@ export default {
* type: "bar"
* }
*
* // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
* // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
* // - an array of [high, mid, low] data following the order
* // - or an object with 'high', 'mid' and 'low' key value
* data: {
Expand Down Expand Up @@ -784,7 +785,7 @@ export default {
* type: "bar"
* }
*
* // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
* // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
* // - an array of [high, mid, low] data following the order
* // - or an object with 'high', 'mid' and 'low' key value
* data: {
Expand Down
14 changes: 10 additions & 4 deletions src/config/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const TYPE = {
AREA_SPLINE: "area-spline",
AREA_SPLINE_RANGE: "area-spline-range",
AREA_STEP: "area-step",
AREA_STEP_RANGE: "area-step-range",
BAR: "bar",
BUBBLE: "bubble",
CANDLESTICK: "candlestick",
Expand All @@ -37,6 +38,7 @@ export const TYPE_METHOD_NEEDED = {
AREA_SPLINE: "initArea",
AREA_SPLINE_RANGE: "initArea",
AREA_STEP: "initArea",
AREA_STEP_RANGE: "initArea",
BAR: "initBar",
BUBBLE: "initCircle",
CANDLESTICK: "initCandlestick",
Expand All @@ -62,11 +64,13 @@ export const TYPE_BY_CATEGORY = {
TYPE.AREA_SPLINE,
TYPE.AREA_SPLINE_RANGE,
TYPE.AREA_LINE_RANGE,
TYPE.AREA_STEP
TYPE.AREA_STEP,
TYPE.AREA_STEP_RANGE
],
AreaRange: [
TYPE.AREA_SPLINE_RANGE,
TYPE.AREA_LINE_RANGE
TYPE.AREA_LINE_RANGE,
TYPE.AREA_STEP_RANGE
],
Arc: [
TYPE.PIE,
Expand All @@ -83,11 +87,13 @@ export const TYPE_BY_CATEGORY = {
TYPE.AREA_SPLINE_RANGE,
TYPE.AREA_LINE_RANGE,
TYPE.STEP,
TYPE.AREA_STEP
TYPE.AREA_STEP,
TYPE.AREA_STEP_RANGE
],
Step: [
TYPE.STEP,
TYPE.AREA_STEP
TYPE.AREA_STEP,
TYPE.AREA_STEP_RANGE
],
Spline: [
TYPE.SPLINE,
Expand Down
4 changes: 4 additions & 0 deletions src/config/resolver/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export {
areaSpline,
areaSplineRange,
areaStep,
areaStepRange,
bar,
bubble,
candlestick,
Expand Down Expand Up @@ -106,6 +107,9 @@ let area = (): string => (
let areaLineRange = (): string => (
extendLine(shapeArea, [optArea]), (areaLineRange = () => TYPE.AREA_LINE_RANGE)()
);
let areaStepRange = (): string => (
extendLine(shapeArea, [optArea]), (areaStepRange = () => TYPE.AREA_STEP_RANGE)()
);
let areaSpline = () => (
extendLine(shapeArea, [optArea, optSpline]), (areaSpline = () => TYPE.AREA_SPLINE)()
);
Expand Down
1 change: 1 addition & 0 deletions src/index.esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {
areaSpline,
areaSplineRange,
areaStep,
areaStepRange,
bar,
bubble,
candlestick,
Expand Down
1 change: 1 addition & 0 deletions types/bb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function areaLineRange(): "area-line-range";
export function areaSpline(): "area-spline";
export function areaSplineRange(): "area-spline-range";
export function areaStep(): "area-step";
export function areaStepRange(): "area-step-range";
export function bar(): "bar";
export function bubble(): "bubble";
export function candlestick(): "candlestick";
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export {
areaSpline,
areaSplineRange,
areaStep,
areaStepRange,
bar,
bubble,
candlestick,
Expand Down
6 changes: 3 additions & 3 deletions types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ export interface Data {
/**
* Set chart type at once.
* If this option is specified, the type will be applied to every data. This setting can be overwritten by data.types.
* - Available Values: area, area-line-range, area-spline, area-spline-range, area-step, bar, bubble, candlestick, donut, gauge, line, pie, radar, scatter, spline, step
* - Available Values: area, area-line-range, area-spline, area-spline-range, area-step, area-step-range, bar, bubble, candlestick, donut, gauge, line, pie, radar, scatter, spline, step
*/
type?: ChartTypes;

Expand Down Expand Up @@ -1342,13 +1342,13 @@ export interface Data {

/**
* Set a callback for minimum data
* - NOTE: For 'area-line-range' and 'area-spline-range', mid data will be taken for the comparison
* - NOTE: For 'area-line-range', 'area-step-range' and 'area-spline-range', mid data will be taken for the comparison
*/
onmin?(this: Chart, d: DataItem[]): void;

/**
* Set a callback for maximum data
* - NOTE: For 'area-line-range' and 'area-spline-range', mid data will be taken for the comparison
* - NOTE: For 'area-line-range', 'area-step-range' and 'area-spline-range', mid data will be taken for the comparison
*/
onmax?(this: Chart, d: DataItem[]): void;

Expand Down
1 change: 1 addition & 0 deletions types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type ChartTypes = "area"
| "area-spline"
| "area-spline-range"
| "area-step"
| "area-step-range"
| "bar"
| "bubble"
| "candlestick"
Expand Down

0 comments on commit 2a763d2

Please sign in to comment.