-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[charts] Harmonize charts TS (mui#13366)
- Loading branch information
1 parent
7ba05b3
commit e4874f3
Showing
9 changed files
with
115 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ChartSeriesType } from '../models/seriesType/config'; | ||
|
||
let instance: undefined | Set<ChartSeriesType>; | ||
|
||
class CartesianSeriesTypes { | ||
types: Set<ChartSeriesType> = new Set(); | ||
|
||
constructor() { | ||
if (instance) { | ||
throw new Error('You can only create one instance!'); | ||
} | ||
instance = this.types; | ||
} | ||
|
||
addType(value: ChartSeriesType) { | ||
this.types.add(value); | ||
} | ||
|
||
getTypes() { | ||
return this.types; | ||
} | ||
} | ||
|
||
export const cartesianSeriesTypes = new CartesianSeriesTypes(); | ||
|
||
cartesianSeriesTypes.addType('bar'); | ||
cartesianSeriesTypes.addType('line'); | ||
cartesianSeriesTypes.addType('scatter'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './configInit'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
ChartSeriesType, | ||
CartesianChartSeriesType, | ||
ChartSeriesDefaultized, | ||
} from '../models/seriesType/config'; | ||
import { cartesianSeriesTypes } from './configInit'; | ||
|
||
export function isCartesianSeriesType(seriesType: string): seriesType is CartesianChartSeriesType { | ||
return cartesianSeriesTypes.getTypes().has(seriesType as ChartSeriesType); | ||
} | ||
|
||
export function isCartesianSeries( | ||
series: ChartSeriesDefaultized<ChartSeriesType> & { getColor: (dataIndex: number) => string }, | ||
): series is ChartSeriesDefaultized<CartesianChartSeriesType> & { | ||
getColor: (dataIndex: number) => string; | ||
}; | ||
export function isCartesianSeries( | ||
series: ChartSeriesDefaultized<ChartSeriesType>, | ||
): series is ChartSeriesDefaultized<CartesianChartSeriesType> { | ||
return isCartesianSeriesType(series.type); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters