Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types): Add area-step-range chart type #3776

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,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|funnel|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|funnel|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
2 changes: 1 addition & 1 deletion src/ChartInternal/shape/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ export default {
isWithin = false;
} else if ($$.hasValidPointType?.(that.nodeName)) {
isWithin = $$.isStepType(d) ?
$$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) :
$$.isWithinStep(that, $$.getYScaleById(d.id)($$.getBaseValue(d))) :
$$.isWithinCircle(
that,
$$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0
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 @@ -578,7 +579,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 @@ -594,7 +595,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 @@ -701,7 +702,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 @@ -787,7 +788,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 @@ -38,6 +39,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 @@ -64,11 +66,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 @@ -85,11 +89,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 @@ -52,6 +52,7 @@ export {
areaSpline,
areaSplineRange,
areaStep,
areaStepRange,
bar,
bubble,
candlestick,
Expand Down Expand Up @@ -109,6 +110,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 @@ -1120,7 +1120,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 @@ -1344,13 +1344,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
Loading