Skip to content

Commit 7fe605c

Browse files
committed
ts: add types for bar. upgrade ts version to 3.8
1 parent 9d8535e commit 7fe605c

26 files changed

+1073
-572
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "./node_modules/typescript/lib"
3+
}

package-lock.json

Lines changed: 9 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@
6666
"serve-handler": "6.1.1",
6767
"slugify": "1.3.4",
6868
"socket.io": "2.2.0",
69-
"typescript": "3.7.4"
69+
"typescript": "^3.8.3"
7070
}
7171
}

src/chart/bar/BarSeries.ts

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,106 @@
1717
* under the License.
1818
*/
1919

20-
// @ts-nocheck
20+
import BaseBarSeriesModel, {BaseBarSeriesOption} from './BaseBarSeries';
21+
import SeriesModel from '../../model/Series';
22+
import { ItemStyleOption, OptionDataValue, LabelOption } from '../../util/types';
23+
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
24+
import type Polar from '../../coord/polar/Polar';
2125

22-
import BaseBarSeries from './BaseBarSeries';
26+
type BarDataValue = OptionDataValue | OptionDataValue[]
2327

24-
export default BaseBarSeries.extend({
28+
export interface BarItemStyleOption extends ItemStyleOption {
29+
/**
30+
* Border radius is not supported for bar on polar
31+
*/
32+
barBorderRadius?: number | number[]
33+
}
34+
export interface BarDataItemOption {
35+
name?: string
36+
37+
value?: BarDataValue
38+
39+
itemStyle?: BarItemStyleOption
40+
label?: LabelOption
41+
42+
cursor?: string
43+
44+
emphasis?: {
45+
itemStyle?: BarItemStyleOption
46+
label?: LabelOption
47+
}
48+
}
49+
50+
export interface BarSeriesOption extends BaseBarSeriesOption {
51+
coordinateSystem?: 'cartesian2d' | 'polar'
52+
53+
clip?: boolean
54+
55+
stack?: string
56+
57+
/**
58+
* If use caps on two sides of bars
59+
* Only available on tangential polar bar
60+
*/
61+
roundCap?: boolean
62+
63+
showBackground?: boolean
2564

26-
type: 'series.bar',
65+
backgroundStyle?: ItemStyleOption & {
66+
borderRadius?: number | number[]
67+
}
68+
69+
data?: (BarDataItemOption | BarDataValue)[]
70+
71+
label?: LabelOption
72+
73+
itemStyle?: BarItemStyleOption
74+
75+
emphasis?: {
76+
label?: LabelOption
77+
itemStyle?: BarItemStyleOption
78+
}
79+
80+
}
2781

28-
dependencies: ['grid', 'polar'],
82+
class BarSeriesModel extends BaseBarSeriesModel<BarSeriesOption> {
83+
static type = 'series.bar'
84+
type = BarSeriesModel.type
2985

30-
brushSelector: 'rect',
86+
static dependencies = ['grid', 'polar']
87+
88+
readonly brushSelector = 'rect'
89+
90+
coordinateSystem: Cartesian2D | Polar
3191

3292
/**
3393
* @override
3494
*/
35-
getProgressive: function () {
95+
getProgressive() {
3696
// Do not support progressive in normal mode.
3797
return this.get('large')
3898
? this.get('progressive')
3999
: false;
40-
},
100+
}
41101

42102
/**
43103
* @override
44104
*/
45-
getProgressiveThreshold: function () {
105+
getProgressiveThreshold() {
46106
// Do not support progressive in normal mode.
47107
var progressiveThreshold = this.get('progressiveThreshold');
48108
var largeThreshold = this.get('largeThreshold');
49109
if (largeThreshold > progressiveThreshold) {
50110
progressiveThreshold = largeThreshold;
51111
}
52112
return progressiveThreshold;
53-
},
113+
}
54114

55-
defaultOption: {
115+
static defaultOption: BarSeriesOption = {
56116
// If clipped
57117
// Only available on cartesian2d
58118
clip: true,
59119

60-
// If use caps on two sides of bars
61-
// Only available on tangential polar bar
62120
roundCap: false,
63121

64122
showBackground: false,
@@ -75,4 +133,9 @@ export default BaseBarSeries.extend({
75133
opacity: 1
76134
}
77135
}
78-
});
136+
137+
}
138+
139+
SeriesModel.registerClass(BarSeriesModel);
140+
141+
export default BarSeriesModel;

0 commit comments

Comments
 (0)