1 |
|
2 |
|
3 |
|
4 |
|
5 | import Chart from "../../Chart/Chart";
|
6 | import ChartInternal from "../../ChartInternal/ChartInternal";
|
7 | import Options from "../Options/Options";
|
8 | import {TYPE} from "../const";
|
9 | import {extend} from "../../module/util";
|
10 |
|
11 |
|
12 | import {
|
13 | api as axisAPI,
|
14 | internal as axisInternal,
|
15 | options as axisOptions
|
16 | } from "./axis";
|
17 |
|
18 |
|
19 | import shapeArc from "../../ChartInternal/shape/arc";
|
20 | import shapeArea from "../../ChartInternal/shape/area";
|
21 | import shapeBar from "../../ChartInternal/shape/bar";
|
22 | import shapeCandlestick from "../../ChartInternal/shape/candlestick";
|
23 | import shapeGauge from "../../ChartInternal/shape/gauge";
|
24 | import shapeBubble from "../../ChartInternal/shape/bubble";
|
25 | import shapeLine from "../../ChartInternal/shape/line";
|
26 | import shapePoint from "../../ChartInternal/shape/point";
|
27 | import shapeRadar from "../../ChartInternal/shape/radar";
|
28 |
|
29 |
|
30 | import optPoint from "../Options/common/point";
|
31 | import optArea from "../Options/shape/area";
|
32 | import optBar from "../Options/shape/bar";
|
33 | import optBubble from "../Options/shape/bubble";
|
34 | import optCandlestick from "../Options/shape/candlestick";
|
35 | import optLine from "../Options/shape/line";
|
36 | import optScatter from "../Options/shape/scatter";
|
37 | import optSpline from "../Options/shape/spline";
|
38 |
|
39 |
|
40 | import optDonut from "../Options/shape/donut";
|
41 | import optGauge from "../Options/shape/gauge";
|
42 | import optPie from "../Options/shape/pie";
|
43 | import optRadar from "../Options/shape/radar";
|
44 |
|
45 | export {
|
46 | area,
|
47 | areaLineRange,
|
48 | areaSpline,
|
49 | areaSplineRange,
|
50 | areaStep,
|
51 | bar,
|
52 | bubble,
|
53 | candlestick,
|
54 | donut,
|
55 | gauge,
|
56 | line,
|
57 | pie,
|
58 | radar,
|
59 | scatter,
|
60 | spline,
|
61 | step
|
62 | };
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | function extendAxis(module, option?): void {
|
71 | extend(ChartInternal.prototype, axisInternal.concat(module));
|
72 | extend(Chart.prototype, axisAPI);
|
73 | Options.setOptions(axisOptions.concat(option || []));
|
74 | }
|
75 |
|
76 | /**
|
77 | * Extend Line type modules
|
78 | * @param {object} module Module to be extended
|
79 | * @param {Array} option Option object to be extended
|
80 | * @private
|
81 | */
|
82 | function extendLine(module?, option?): void {
|
83 | extendAxis([shapePoint, shapeLine].concat(module || []));
|
84 | Options.setOptions([optPoint, optLine].concat(option || []));
|
85 | }
|
86 |
|
87 | /**
|
88 | * Extend Arc type modules
|
89 | * @param {Array} module Module to be extended
|
90 | * @param {Array} option Option object to be extended
|
91 | * @private
|
92 | */
|
93 | function extendArc(module?, option?): void {
|
94 | extend(ChartInternal.prototype, [shapeArc].concat(module || []));
|
95 | Options.setOptions(option);
|
96 | }
|
97 |
|
98 | // Area types
|
99 | let area = (): string => (
|
100 | extendLine(shapeArea, [optArea]), (area = () => TYPE.AREA)()
|
101 | );
|
102 | let areaLineRange = (): string => (
|
103 | extendLine(shapeArea, [optArea]), (areaLineRange = () => TYPE.AREA_LINE_RANGE)()
|
104 | );
|
105 | let areaSpline = () => (
|
106 | extendLine(shapeArea, [optArea, optSpline]), (areaSpline = () => TYPE.AREA_SPLINE)()
|
107 | );
|
108 | let areaSplineRange = (): string => (
|
109 | extendLine(shapeArea, [optArea, optSpline]), (areaSplineRange = () => TYPE.AREA_SPLINE_RANGE)()
|
110 | );
|
111 | let areaStep = (): string => (
|
112 | extendLine(shapeArea, [optArea]), (areaStep = () => TYPE.AREA_STEP)()
|
113 | );
|
114 |
|
115 | // Line types
|
116 | let line = (): string => (extendLine(), (line = () => TYPE.LINE)());
|
117 | let spline = (): string => (extendLine(undefined, [optSpline]), (spline = () => TYPE.SPLINE)());
|
118 | let step = (): string => (extendLine(), (step = () => TYPE.STEP)());
|
119 |
|
120 | // Arc types
|
121 | let donut = (): string => (extendArc(undefined, [optDonut]), (donut = () => TYPE.DONUT)());
|
122 | let gauge = (): string => (extendArc([shapeGauge], [optGauge]), (gauge = () => TYPE.GAUGE)());
|
123 | let pie = (): string => (extendArc(undefined, [optPie]), (pie = () => TYPE.PIE)());
|
124 | let radar = (): string => (
|
125 | extendArc([shapePoint, shapeRadar], [optPoint, optRadar]), (radar = () => TYPE.RADAR)()
|
126 | );
|
127 |
|
128 | // Axis based types
|
129 | let bar = (): string => (extendAxis([shapeBar], optBar), (bar = () => TYPE.BAR)());
|
130 | let bubble = (): string => (
|
131 | extendAxis([shapePoint, shapeBubble], [optBubble, optPoint]), (bubble = () => TYPE.BUBBLE)()
|
132 | );
|
133 | let candlestick = (): string => (
|
134 | extendAxis([shapeCandlestick], [optCandlestick]), (candlestick = () => TYPE.CANDLESTICK)()
|
135 | );
|
136 | let scatter = (): string => (
|
137 | extendAxis([shapePoint], [optPoint, optScatter]), (scatter = () => TYPE.SCATTER)()
|
138 | );
|