-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
246 additions
and
21 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import Line from './tiny-line'; | ||
import Area from './tiny-area'; | ||
import Column from './tiny-column'; | ||
import Progress from './tiny-progress'; | ||
import Line from './line'; | ||
import Area from './area'; | ||
import Column from './column'; | ||
import Progress from './progress'; | ||
import Ring from './ring'; | ||
|
||
export type { TinyLineConfig } from './tiny-line'; | ||
export type { TinyAreaConfig } from './tiny-area'; | ||
export type { TinyColumnConfig } from './tiny-column'; | ||
export type { TinyProgressConfig } from './tiny-progress'; | ||
export type { TinyLineConfig } from './line'; | ||
export type { TinyAreaConfig } from './area'; | ||
export type { TinyColumnConfig } from './column'; | ||
export type { TinyProgressConfig } from './progress'; | ||
export type { TinyRingConfig } from './ring'; | ||
|
||
type TinyOptions = Record<string, typeof Line | typeof Area | typeof Column | typeof Progress>; | ||
type TinyOptions = Record<string, typeof Line | typeof Area | typeof Column | typeof Progress | typeof Ring>; | ||
|
||
export const Tiny: TinyOptions = { Line, Area, Column, Progress }; | ||
export const Tiny: TinyOptions = { Line, Area, Column, Progress, Ring }; |
File renamed without changes.
File renamed without changes.
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,10 @@ | ||
import React from 'react'; | ||
import { TinyRingOptions } from '../../../core'; | ||
import { CommonConfig } from '../../../interface'; | ||
import { BaseChart } from '../../base'; | ||
|
||
export type TinyRingConfig = CommonConfig<TinyRingOptions>; | ||
|
||
const TinyRingChart = (props: TinyRingOptions) => <BaseChart {...props} chartType="TinyRing" />; | ||
|
||
export default TinyRingChart; |
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
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
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,43 @@ | ||
import { flow, transformOptions, set } from '../../utils'; | ||
import { mark } from '../../components'; | ||
import type { Adaptor } from '../../types'; | ||
import type { TinyRingOptions } from './type'; | ||
|
||
type Params = Adaptor<TinyRingOptions>; | ||
|
||
/** | ||
* @param chart | ||
* @param options | ||
*/ | ||
export function adaptor(params: Params) { | ||
/** | ||
* @description radius | ||
*/ | ||
const radius = (params: Params) => { | ||
const { options } = params; | ||
const { radius = 0.8 } = options; | ||
set(params, 'options.coordinate.innerRadius', radius); | ||
return params; | ||
}; | ||
|
||
/** | ||
* @description 数据转换 | ||
*/ | ||
const transformData = (params: Params) => { | ||
const { options } = params; | ||
const { percent, color = [] } = options; | ||
if (!percent) return params; | ||
|
||
const transformOption = { | ||
scale: { | ||
color: { range: color.length ? color : [] }, | ||
}, | ||
data: [1, percent], | ||
}; | ||
|
||
Object.assign(options, { ...transformOption }); | ||
return params; | ||
}; | ||
|
||
return flow(radius, transformData, transformOptions, mark)(params); | ||
} |
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,51 @@ | ||
import { Plot } from '../../base'; | ||
import type { Adaptor } from '../../types'; | ||
import { adaptor } from './adaptor'; | ||
import { TinyRingOptions } from './type'; | ||
|
||
export type { TinyRingOptions }; | ||
|
||
export class TinyRing extends Plot<TinyRingOptions> { | ||
/** 图表类型 */ | ||
public type = 'TinyRing'; | ||
|
||
/** | ||
* 获取进度图默认配置项 | ||
* 供外部使用 | ||
*/ | ||
static getDefaultOptions(): Partial<TinyRingOptions> { | ||
return { | ||
type: 'view', | ||
data: [], | ||
autoFit: false, | ||
margin: 0, | ||
padding: 0, | ||
coordinate: { type: 'theta' }, | ||
animate: { enter: { type: 'waveIn' } }, | ||
interaction: { tooltip: false }, | ||
tooltip: false, | ||
children: [ | ||
{ | ||
type: 'interval', | ||
axis: false, | ||
legend: false, | ||
encode: { y: (d) => d, color: (d, idx) => idx }, | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
/** | ||
* 获取 进度图 默认配置 | ||
*/ | ||
protected getDefaultOptions() { | ||
return TinyRing.getDefaultOptions(); | ||
} | ||
|
||
/** | ||
* 迷你折线图适配器 | ||
*/ | ||
protected getSchemaAdaptor(): (params: Adaptor<TinyRingOptions>) => void { | ||
return adaptor; | ||
} | ||
} |
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,20 @@ | ||
import type { BaseOptions, Options } from '../../types/common'; | ||
|
||
export type TinyRingOptions = Options & | ||
BaseOptions & { | ||
/** | ||
* @title 进度 | ||
*/ | ||
percent: number; | ||
/** | ||
* @title 颜色 | ||
* @description [ backgroundColor, progressColor] | ||
*/ | ||
color?: [string, string]; | ||
/** | ||
* @title 内径 | ||
* @description 0 ~ 1 | ||
* @default 0.8 | ||
*/ | ||
radius?: number; | ||
}; |
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
Oops, something went wrong.