Skip to content

Commit

Permalink
ts: add types for bar. upgrade ts version to 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Mar 1, 2020
1 parent 9d8535e commit 7fe605c
Show file tree
Hide file tree
Showing 26 changed files with 1,073 additions and 572 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "./node_modules/typescript/lib"
}
43 changes: 9 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"serve-handler": "6.1.1",
"slugify": "1.3.4",
"socket.io": "2.2.0",
"typescript": "3.7.4"
"typescript": "^3.8.3"
}
}
91 changes: 77 additions & 14 deletions src/chart/bar/BarSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,106 @@
* under the License.
*/

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

import BaseBarSeries from './BaseBarSeries';
type BarDataValue = OptionDataValue | OptionDataValue[]

export default BaseBarSeries.extend({
export interface BarItemStyleOption extends ItemStyleOption {
/**
* Border radius is not supported for bar on polar
*/
barBorderRadius?: number | number[]
}
export interface BarDataItemOption {
name?: string

value?: BarDataValue

itemStyle?: BarItemStyleOption
label?: LabelOption

cursor?: string

emphasis?: {
itemStyle?: BarItemStyleOption
label?: LabelOption
}
}

export interface BarSeriesOption extends BaseBarSeriesOption {
coordinateSystem?: 'cartesian2d' | 'polar'

clip?: boolean

stack?: string

/**
* If use caps on two sides of bars
* Only available on tangential polar bar
*/
roundCap?: boolean

showBackground?: boolean

type: 'series.bar',
backgroundStyle?: ItemStyleOption & {
borderRadius?: number | number[]
}

data?: (BarDataItemOption | BarDataValue)[]

label?: LabelOption

itemStyle?: BarItemStyleOption

emphasis?: {
label?: LabelOption
itemStyle?: BarItemStyleOption
}

}

dependencies: ['grid', 'polar'],
class BarSeriesModel extends BaseBarSeriesModel<BarSeriesOption> {
static type = 'series.bar'
type = BarSeriesModel.type

brushSelector: 'rect',
static dependencies = ['grid', 'polar']

readonly brushSelector = 'rect'

coordinateSystem: Cartesian2D | Polar

/**
* @override
*/
getProgressive: function () {
getProgressive() {
// Do not support progressive in normal mode.
return this.get('large')
? this.get('progressive')
: false;
},
}

/**
* @override
*/
getProgressiveThreshold: function () {
getProgressiveThreshold() {
// Do not support progressive in normal mode.
var progressiveThreshold = this.get('progressiveThreshold');
var largeThreshold = this.get('largeThreshold');
if (largeThreshold > progressiveThreshold) {
progressiveThreshold = largeThreshold;
}
return progressiveThreshold;
},
}

defaultOption: {
static defaultOption: BarSeriesOption = {
// If clipped
// Only available on cartesian2d
clip: true,

// If use caps on two sides of bars
// Only available on tangential polar bar
roundCap: false,

showBackground: false,
Expand All @@ -75,4 +133,9 @@ export default BaseBarSeries.extend({
opacity: 1
}
}
});

}

SeriesModel.registerClass(BarSeriesModel);

export default BarSeriesModel;
Loading

0 comments on commit 7fe605c

Please sign in to comment.