├── site
├── .eslintrc.js
└── package.json
├── .babelrc
├── packages
├── console-chart
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── rollup.config.js
│ ├── src
│ │ └── index.ts
│ └── package.json
├── console-bar-chart
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── demo
│ │ ├── Basic.tsx
│ │ ├── Horizontal.tsx
│ │ ├── Stack.tsx
│ │ ├── Color.tsx
│ │ ├── index.stories.tsx
│ │ ├── DodgeStack.tsx
│ │ └── Facet.tsx
│ ├── rollup.config.js
│ ├── package.json
│ └── README.md
├── console-dot-chart
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── demo
│ │ ├── index.stories.tsx
│ │ ├── Basic.tsx
│ │ ├── Multi.tsx
│ │ ├── Size.tsx
│ │ └── Disturbance.tsx
│ ├── rollup.config.js
│ ├── package.json
│ ├── README.md
│ └── src
│ │ └── index.ts
├── console-line-chart
│ ├── tslint.json
│ ├── demo
│ │ ├── Basic.tsx
│ │ ├── YAxisMin.tsx
│ │ ├── OneDotToLine.tsx
│ │ ├── GradualColor.tsx
│ │ ├── Multi.tsx
│ │ ├── XAxisAsync.tsx
│ │ ├── Dot.tsx
│ │ ├── index.stories.tsx
│ │ ├── Unit.tsx
│ │ ├── DoubleAxis.tsx
│ │ ├── Stack.tsx
│ │ ├── Smooth.tsx
│ │ ├── XLabel.tsx
│ │ ├── XAxisTickInterval.tsx
│ │ └── LegendClick.tsx
│ ├── rollup.config.js
│ ├── package.json
│ ├── tsconfig.json
│ └── README.md
├── console-pie-chart
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── demo
│ │ ├── Basic.tsx
│ │ ├── Label.tsx
│ │ ├── SingleColors.tsx
│ │ ├── Select.tsx
│ │ ├── MultiColors.tsx
│ │ ├── Circle.tsx
│ │ ├── CircleSlice.tsx
│ │ ├── Legend.tsx
│ │ ├── LegendRight.tsx
│ │ ├── CircleGuide.tsx
│ │ ├── Tooltip.tsx
│ │ ├── LegendTip.tsx
│ │ ├── ComplexTooltip.tsx
│ │ ├── index.stories.tsx
│ │ └── SelectCircleGuide.tsx
│ ├── rollup.config.js
│ ├── package.json
│ └── README.md
├── console-rose-chart
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── demo
│ │ ├── index.stories.tsx
│ │ ├── Basic.tsx
│ │ ├── SingleColor.tsx
│ │ └── Axis.tsx
│ ├── rollup.config.js
│ ├── package.json
│ ├── README.md
│ └── src
│ │ └── index.ts
├── console-tree-graph
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── demo
│ │ ├── index.stories.tsx
│ │ └── Basic.tsx
│ ├── rollup.config.js
│ ├── package.json
│ └── README.md
├── console-combo-chart
│ ├── tslint.json
│ ├── rollup.config.js
│ ├── demo
│ │ ├── index.stories.tsx
│ │ ├── Basic.tsx
│ │ ├── YAxisColor.tsx
│ │ ├── SingleYAxis.tsx
│ │ ├── Click.tsx
│ │ ├── Stack.tsx
│ │ ├── Smooth.tsx
│ │ └── Color.tsx
│ ├── package.json
│ ├── tsconfig.json
│ └── README.md
├── console-funnel-chart
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── demo
│ │ ├── Basic.tsx
│ │ ├── Left.tsx
│ │ ├── Horizontal.tsx
│ │ ├── Pyramid.tsx
│ │ ├── PyramidHor.tsx
│ │ └── index.stories.tsx
│ ├── rollup.config.js
│ ├── package.json
│ ├── README.md
│ └── src
│ │ └── index.ts
├── console-miniline-chart
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── demo
│ │ ├── Basic.tsx
│ │ ├── Area.tsx
│ │ ├── AreaSmooth.tsx
│ │ ├── Color.tsx
│ │ ├── index.stories.tsx
│ │ └── AreaStack.tsx
│ ├── rollup.config.js
│ ├── package.json
│ ├── README.md
│ └── src
│ │ └── index.ts
├── console-radar-chart
│ ├── tsconfig.json
│ ├── tslint.json
│ ├── demo
│ │ ├── index.stories.tsx
│ │ ├── Basic.tsx
│ │ ├── Multi.tsx
│ │ ├── Axis.tsx
│ │ └── Area.tsx
│ ├── rollup.config.js
│ ├── package.json
│ ├── README.md
│ └── src
│ │ └── index.ts
├── console-sankey-chart
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── src
│ │ ├── types.ts
│ │ └── transform.ts
│ ├── rollup.config.js
│ ├── demo
│ │ ├── index.stories.tsx
│ │ ├── NodeShape.tsx
│ │ ├── Basic.tsx
│ │ ├── Tooltip.tsx
│ │ ├── Topology.tsx
│ │ ├── Vertical.tsx
│ │ ├── LinkStyle.tsx
│ │ └── TopologyVertical.tsx
│ ├── package.json
│ └── README.md
├── console-shared-utils
│ ├── tslint.json
│ ├── tsconfig.json
│ ├── README.md
│ ├── src
│ │ ├── config
│ │ │ ├── yunzhi.ts
│ │ │ ├── index.ts
│ │ │ └── default.ts
│ │ ├── g2Helper
│ │ │ ├── style.ts
│ │ │ ├── size.ts
│ │ │ ├── updater.ts
│ │ │ ├── tooltip.ts
│ │ │ ├── axisX.ts
│ │ │ ├── axisY.ts
│ │ │ ├── legend.ts
│ │ │ ├── guide.ts
│ │ │ ├── label.ts
│ │ │ ├── rectAutoTickCount.ts
│ │ │ ├── drawLine.ts
│ │ │ └── dataAdapter.ts
│ │ ├── constants
│ │ │ └── index.ts
│ │ ├── index.ts
│ │ ├── types
│ │ │ └── index.ts
│ │ ├── theme
│ │ │ └── index.ts
│ │ └── common
│ │ │ └── utils.ts
│ ├── rollup.config.js
│ └── package.json
└── config-common-demo
│ ├── demo
│ ├── WidthHeight.tsx
│ └── PaddingBasic.tsx
│ └── README.md
├── .npmignore
├── .demoProjectTemplate
├── tsconfig.json
├── src
│ └── index.tsx
├── projectTemplateConfig.js
└── package.json
├── .editorconfig
├── .storybook
├── config.js
└── webpack.config.js
├── docs
├── 8-config-y.md
├── 1-quick-start.md
├── 2-concepts.md
├── 13-config-style.md
├── 14-config-size.md
├── 6-config.md
├── 3-contributing.md
├── 11-config-label.md
├── 4-props.md
└── 5-data.md
├── tslint.json
├── .gitignore
├── CHANGELOG.md
├── lerna.json
├── README.md
├── LICENSE
├── tsconfig.json
├── CONTRIBUTING.md
├── package.json
└── rollup.config.js
/site/.eslintrc.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-react", "@babel/preset-env"]
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-line-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-tree-graph/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-tree-graph/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .babelrc
2 | .editorconfig
3 | .eslintignore
4 | .eslintrc
5 | .gitignore
6 | .demoProjectTemplate
7 | site/
8 | lerna.json
9 | rollup.config.js
10 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./lib"
5 | },
6 | "include": ["./src/*"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/console-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./lib"
5 | },
6 | "include": [
7 | "./src/*"
8 | ]
9 | }
--------------------------------------------------------------------------------
/packages/console-pie-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./lib"
5 | },
6 | "include": [
7 | "./src"
8 | ]
9 | }
--------------------------------------------------------------------------------
/packages/console-shared-utils/README.md:
--------------------------------------------------------------------------------
1 | # `@alicloud/console-shared-utils`
2 |
3 | > TODO: description
4 |
5 | ## Usage
6 |
7 | ```
8 |
9 | // TODO: DEMONSTRATE API
10 | ```
11 |
--------------------------------------------------------------------------------
/.demoProjectTemplate/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/**/*"],
3 | "compilerOptions": {
4 | "jsx": "react",
5 | "moduleResolution": "node",
6 | "esModuleInterop": true
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.demoProjectTemplate/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react'
2 | import { render } from 'react-dom'
3 | import App from './demo/{{DEMO_ENTRY_NAME}}'
4 |
5 | const rootElement = document.getElementById('root')
6 | render(, rootElement)
7 |
--------------------------------------------------------------------------------
/packages/console-tree-graph/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 |
6 | storiesOf('ConsoleTreeGraph', module)
7 | .add('基本用法', () => );
8 |
--------------------------------------------------------------------------------
/.storybook/config.js:
--------------------------------------------------------------------------------
1 | import { configure } from '@storybook/react';
2 |
3 | const req = require.context('../packages', true, /.stories.tsx$/);
4 |
5 | function loadStories() {
6 | req.keys().forEach(filename => req(filename));
7 | }
8 |
9 | configure(loadStories, module);
10 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/config/yunzhi.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | ConsoleLineChart: {},
3 | ConsoleBarChart: {},
4 | ConsoleComboChart: {},
5 | ConsolePieChart: {},
6 | ConsoleMinilineChart: {},
7 | ConsoleRadarChart: {},
8 | ConsoleFunnelChart: {},
9 | ConsoleDotChart: {},
10 | ConsoleRoseChart: {},
11 | };
12 |
--------------------------------------------------------------------------------
/docs/8-config-y.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: config-y
3 | zhName: 配置-y轴
4 | sort: 8
5 | ---
6 |
7 | # config-y轴
8 |
9 | `yAxis` 属性控制Y轴展示。
10 |
11 | ## 配置方式
12 | ```javascript
13 | // 单轴形态
14 | config = {
15 | yAxis: {},
16 | };
17 |
18 | // 双轴形态
19 | config = {
20 | yAxis: [{}, {}],
21 | };
22 | ```
23 |
24 | ## 属性列表
25 | 同 `config-xAxis` 配置
26 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/style.ts:
--------------------------------------------------------------------------------
1 | // 标准style函数
2 | // https://www.yuque.com/antv/g2-docs/api-geom#style
3 |
4 | export default function(gemo: any, config, styleConfig) {
5 | if (!styleConfig) {
6 | return;
7 | }
8 | const formatStyleConfig = Array.isArray(styleConfig) ? styleConfig : [styleConfig];
9 | gemo.style(...formatStyleConfig);
10 | }
11 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-string-throw": true,
4 | "no-unused-expression": true,
5 | "no-duplicate-variable": true,
6 | "curly": true,
7 | "class-name": true,
8 | "semicolon": [true, "always"],
9 | "triple-equals": true
10 | },
11 | "defaultSeverity": "warning",
12 | "linterOptions": {
13 | "exclude": ["node_modules"]
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleFunnelChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['毛利润', 20], ['净利润', 15], ['成本', 5]],
8 | },
9 | ];
10 |
11 | const config = {};
12 |
13 | export default () => (
14 |
15 | );
16 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '各类云产品占比',
7 | data: [['计算类', 45], ['资源类', 26], ['服务类', 12], ['工具类', 8]],
8 | },
9 | ];
10 |
11 | const config = {};
12 |
13 | export default () => (
14 |
15 | );
16 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import Axis from './Axis';
6 | import SingleColor from './SingleColor';
7 |
8 | storiesOf('ConsoleRoseChart', module)
9 | .add('基本玫瑰图', () => )
10 | .add('带坐标轴', () => )
11 | .add('单色玫瑰图', () => );
12 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleBarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '阿里云Nat网关价格/月',
7 | data: [
8 | ['Small', 306], ['Middle', 586.5], ['Large', 1147.5], ['XLarge.1', 2040]
9 | ],
10 | },
11 | ];
12 |
13 | export default () => (
14 |
15 | );
16 |
--------------------------------------------------------------------------------
/packages/config-common-demo/demo/WidthHeight.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleMinilineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['2015', 20], ['2016', 5], ['2017', 15], ['2018', 30], ['2019', 40]],
8 | },
9 | ];
10 |
11 | export default () => (
12 |
13 | );
14 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['2015', 20], ['2016', 5], ['2017', 15], ['2018', 30], ['2019', 40]],
8 | },
9 | ];
10 |
11 | const config = {};
12 |
13 | export default () => (
14 |
15 | );
16 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/Label.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '清华',
7 | data: [['Chinese', 20], ['English', 10], ['Math', 15]],
8 | },
9 | ];
10 |
11 | const config = {
12 | label: {},
13 | };
14 |
15 | export default () => (
16 |
17 | );
18 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, commonjs } = plugins;
4 |
5 | const pluginsCb = ({ fmt, ts, dest }) => {
6 | return [typescript(), resolve(), commonjs()];
7 | };
8 |
9 | export default generateRollupConfig({
10 | formatArr: ['es', 'cjs'],
11 | input: 'src/index.ts',
12 | plugins: pluginsCb,
13 | });
14 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleMinilineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['2015', 20], ['2016', 5], ['2017', 15], ['2018', 30], ['2019', 40]],
8 | },
9 | ];
10 |
11 | const config = {};
12 |
13 | export default () => (
14 |
15 | );
16 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/SingleColors.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '各类云产品占比',
7 | data: [['计算类', 45], ['资源类', 26], ['服务类', 12], ['工具类', 8]],
8 | },
9 | ];
10 |
11 | const config = {
12 | colors: '#0093ee',
13 | };
14 |
15 | export default () => (
16 |
17 | );
18 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/demo/Left.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleFunnelChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['毛利润', 20], ['净利润', 15], ['成本', 5]],
8 | },
9 | ];
10 |
11 | const config = {
12 | direction: 'vertical',
13 | align: 'left',
14 | };
15 |
16 | export default () => (
17 |
18 | );
19 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/demo/Area.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleMinilineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['2015', 20], ['2016', 5], ['2017', 15], ['2018', 30], ['2019', 40]],
8 | },
9 | ];
10 |
11 | const config = {
12 | area: true,
13 | };
14 |
15 | export default () => (
16 |
17 | );
18 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import Area from './Area';
6 | import Multi from './Multi';
7 | import Axis from './Axis';
8 |
9 | storiesOf('ConsoleRadarChart', module)
10 | .add('基本用法', () => )
11 | .add('面积图', () => )
12 | .add('多组数据', () => )
13 | .add('自定义坐标轴', () => );
14 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/demo/Horizontal.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleFunnelChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['毛利润', 20], ['净利润', 15], ['成本', 5]],
8 | },
9 | ];
10 |
11 | const config = {
12 | direction: 'horizontal',
13 | align: 'top',
14 | };
15 |
16 | export default () => (
17 |
18 | );
19 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/Select.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '各类云产品占比',
7 | data: [['计算类', 45], ['资源类', 26], ['服务类', 12], ['工具类', 8]],
8 | },
9 | ];
10 |
11 | const config = {
12 | select: true,
13 | selectData: '计算类',
14 | };
15 |
16 | export default () => (
17 |
18 | );
19 |
--------------------------------------------------------------------------------
/.demoProjectTemplate/projectTemplateConfig.js:
--------------------------------------------------------------------------------
1 | const { basename, extname } = require('path')
2 |
3 | const config = {
4 | baseDir: './src/demo',
5 | afterMerge: (mergedProjectFiles, entryPath) => {
6 | const entryFileName = basename(entryPath, extname(entryPath))
7 | mergedProjectFiles['src/index.tsx'] = mergedProjectFiles[
8 | 'src/index.tsx'
9 | ].replace('{{DEMO_ENTRY_NAME}}', entryFileName)
10 | },
11 | }
12 |
13 | module.exports = config
14 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import Multi from './Multi';
6 | import Size from './Size';
7 | import Disturbance from './Disturbance';
8 |
9 | storiesOf('ConsoleDotChart', module)
10 | .add('基本散点图', () => )
11 | .add('多组数据', () => )
12 | .add('自定义点大小', () => )
13 | .add('扰动图', () => );
14 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/MultiColors.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '各类云产品占比',
7 | data: [['计算类', 45], ['资源类', 26], ['服务类', 12], ['工具类', 8]],
8 | },
9 | ];
10 |
11 | const config = {
12 | colors: ['#EE6DD2', '#EE746D', '#B4C5EE', '#B3EE26'],
13 | };
14 |
15 | export default () => (
16 |
17 | );
18 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/demo/Pyramid.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleFunnelChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['毛利润', 20], ['净利润', 15], ['成本', 5]],
8 | },
9 | ];
10 |
11 | const config = {
12 | direction: 'vertical',
13 | align: 'center',
14 | pyramid: true,
15 | };
16 |
17 | export default () => (
18 |
19 | );
20 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/demo/PyramidHor.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleFunnelChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['毛利润', 20], ['净利润', 15], ['成本', 5]],
8 | },
9 | ];
10 |
11 | const config = {
12 | direction: 'horizontal',
13 | align: 'center',
14 | pyramid: true,
15 | };
16 |
17 | export default () => (
18 |
19 | );
20 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/demo/AreaSmooth.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleMinilineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '奇怪的数据量',
7 | data: [['2015', 20], ['2016', 5], ['2017', 15], ['2018', 30], ['2019', 40]],
8 | },
9 | ];
10 |
11 | const config = {
12 | area: true,
13 | smooth: true,
14 | };
15 |
16 | export default () => (
17 |
18 | );
19 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/demo/Color.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleMinilineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '奇怪的数据量',
7 | color: '#ff0000',
8 | data: [
9 | ['2015', 20], ['2016', 5], ['2017', 15], ['2018', 30], ['2019', 40]
10 | ],
11 | },
12 | ];
13 |
14 | const config = {};
15 |
16 | export default () => (
17 |
18 | );
19 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/demo/Horizontal.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleBarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '阿里云Nat网关价格/月',
7 | data: [
8 | ['Small', 306], ['Middle', 586.5], ['Large', 1147.5], ['XLarge.1', 2040]
9 | ],
10 | },
11 | ];
12 |
13 | const config = {
14 | horizontal: true,
15 | };
16 |
17 | export default () => (
18 |
19 | );
20 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/src/types.ts:
--------------------------------------------------------------------------------
1 |
2 | enum linkTypes {
3 | 'arc',
4 | 'line',
5 | }
6 |
7 | enum nodeAligns {
8 | 'start',
9 | 'end',
10 | 'center',
11 | 'justify',
12 | }
13 |
14 | enum directions {
15 | 'vertical',
16 | 'horizontal',
17 | }
18 |
19 | export default interface config {
20 | topology: boolean,
21 | direction?: directions,
22 | linkType?: linkTypes,
23 | linkColor?: string,
24 | linkOpacity?: number,
25 | nodeAlign?: nodeAligns,
26 | }
27 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/Circle.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '时长',
7 | data: [['1年', 45], ['2年', 26], ['3年', 12], ['4年', 8], ['5年', 10], ['6年以上', 27]],
8 | },
9 | ];
10 |
11 | let config = {
12 | cycle: true,
13 | legend: {
14 | position: 'bottom',
15 | },
16 | };
17 |
18 | export default () => (
19 |
20 | );
21 |
--------------------------------------------------------------------------------
/packages/config-common-demo/demo/PaddingBasic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleBarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '阿里云Nat网关价格/月',
7 | data: [
8 | ['Small', 306], ['Middle', 586.5], ['Large', 1147.5], ['XLarge.1', 2040]
9 | ],
10 | },
11 | ];
12 |
13 | const config = {
14 | padding: [50, 50, 100, 100],
15 | }
16 |
17 | export default () => (
18 |
19 | );
20 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleRoseChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '年份数据',
7 | data: [
8 | ['2013', 14],
9 | ['2014', 15],
10 | ['2015', 16],
11 | ['2016', 18],
12 | ['2017', 20],
13 | ['2018', 21],
14 | ['2019', 24.3],
15 | ['2020', 25],
16 | ],
17 | },
18 | ];
19 |
20 | export default () => (
21 |
22 | );
23 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/YAxisMin.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['2015', 4.3], ['2016', 3], ['2017', 2], ['2018', 0], ['2019', 1]],
8 | },
9 | ];
10 |
11 | const config = {
12 | yAxis: {
13 | min: 0,
14 | formatter: (num: number) => Math.round(num),
15 | }
16 | };
17 |
18 | export default () => (
19 |
20 | );
21 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/CircleSlice.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '时长',
7 | data: [['1年', 45], ['2年', 26], ['3年', 12], ['4年', 8], ['5年', 10], ['6年以上', 27]],
8 | },
9 | ];
10 |
11 | let config = {
12 | cycle: true,
13 | legend: {
14 | position: 'bottom',
15 | },
16 | sliceGap: 0.01,
17 | };
18 |
19 | export default () => (
20 |
21 | );
22 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleRadarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'oss',
7 | data: [['specification', 29], ['feature', 28], ['doc', 31]],
8 | color: '#E288CE',
9 | }
10 | ];
11 |
12 | const config = {
13 | xAxis: {
14 | label: {
15 | formatter: val => val + '~'
16 | }
17 | },
18 | };
19 |
20 | export default () => (
21 |
22 | );
23 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/demo/Stack.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleBarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'Nat网关',
7 | data: [['规格', 3], ['动态数', 4], ['SDK支持语言', 4]],
8 | },
9 | {
10 | name: 'Slb负载均衡',
11 | data: [['规格', 12], ['动态数', 11], ['SDK支持语言', 0]],
12 | },
13 | ];
14 |
15 | export default () => {
16 | const config = {
17 | stack: true,
18 | };
19 | return (
20 |
21 | );
22 | }
23 |
--------------------------------------------------------------------------------
/docs/1-quick-start.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: quick-start
3 | zhName: 快速开始
4 | sort: 1
5 | ---
6 |
7 | # 入门指南
8 |
9 | # 使用说明
10 |
11 | **Console Chart** 图表库采用`lerna`包管理工具开发,每种类型的图表单独放在一个包中,同时提供了一个图表库集合包`@alicloud/console-chart`,你可以使用以下方式使用图表。
12 |
13 |
14 | ## 安装
15 |
16 | ```bash
17 | npm install @alicloud/console-chart --save
18 | ```
19 |
20 | ## 使用
21 | ```javascript
22 | import { ConsoleLineChart } from '@alicloud/console-chart';
23 | const data = [];
24 | const config = {};
25 |
26 |
27 | ```
28 |
29 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleDotChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '云产品数据',
7 | data: [
8 | ['a', 1892],
9 | ['b', 7292],
10 | ['c', 5714],
11 | ['d', 5354],
12 | ['e', 2014],
13 | ['f', 22],
14 | ['g', 1123],
15 | ['h', 5218],
16 | ],
17 | },
18 | ];
19 |
20 | const config = {};
21 |
22 | export default () => (
23 |
24 | );
25 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, commonjs, autoExternal } = plugins;
4 | const pluginsCb = ({ fmt, ts, file }) => {
5 | if (fmt === 'umd') {
6 | return [typescript({}), resolve(), commonjs()];
7 | } else {
8 | return [typescript({}), resolve(), commonjs(), autoExternal()];
9 | }
10 | };
11 | export default generateRollupConfig({
12 | formatArr: ['es', 'cjs', 'umd'],
13 | input: 'src/index.ts',
14 | plugins: pluginsCb,
15 | });
16 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, commonjs, resolve, autoExternal } = plugins;
4 |
5 | const pluginsCb = ({ fmt }) => {
6 | if (fmt === 'umd') {
7 | return [typescript({}), resolve(), commonjs()];
8 | } else {
9 | return [typescript({}), resolve(), commonjs(), autoExternal()];
10 | }
11 | };
12 |
13 | export default generateRollupConfig({
14 | formatArr: ['es', 'cjs', 'umd'],
15 | input: 'src/index.ts',
16 | plugins: pluginsCb,
17 | });
18 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, commonjs, autoExternal } = plugins;
4 |
5 | const pluginsCb = ({ fmt, ts }) => {
6 | if (fmt === 'umd') {
7 | return [typescript(), resolve(), commonjs()];
8 | } else {
9 | return [typescript(), resolve(), commonjs(), autoExternal()];
10 | }
11 | };
12 |
13 | export default generateRollupConfig({
14 | formatArr: ['es', 'cjs', 'umd'],
15 | input: 'src/index.ts',
16 | plugins: pluginsCb,
17 | });
18 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import Left from './Left';
6 | import Horizontal from './Horizontal';
7 | import Pyramid from './Pyramid';
8 | import PyramidHor from './PyramidHor';
9 |
10 | storiesOf('ConsoleFunnelChart', module)
11 | .add('基本用法', () => )
12 | .add('居左', () => )
13 | .add('横向居中', () => )
14 | .add('金字塔', () => )
15 | .add('横向金字塔', () => );
16 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import Area from './Area';
6 | import AreaSmooth from './AreaSmooth';
7 | import AreaStack from './AreaStack';
8 | import Color from './Color';
9 |
10 | storiesOf('ConsoleMinilineChart', module)
11 | .add('基本用法', () => )
12 | .add('面积图', () => )
13 | .add('光滑面积图', () => )
14 | .add('面积堆栈图', () => )
15 | .add('自定义颜色', () => );
16 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, commonjs, autoExternal } = plugins;
4 | const pluginsCb = ({ fmt, ts, file }) => {
5 | if (fmt === 'umd') {
6 | return [typescript({}), resolve(), commonjs()];
7 | } else {
8 | return [typescript({}), resolve(), commonjs(), autoExternal()];
9 | }
10 | };
11 | export default generateRollupConfig({
12 | formatArr: ['es', 'cjs', 'umd'],
13 | input: 'src/index.ts',
14 | plugins: pluginsCb,
15 | });
16 |
--------------------------------------------------------------------------------
/packages/console-tree-graph/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, commonjs, autoExternal } = plugins;
4 | const pluginsCb = ({ fmt, ts, file }) => {
5 | if (fmt === 'umd') {
6 | return [typescript({}), resolve(), commonjs()];
7 | } else {
8 | return [typescript({}), resolve(), commonjs(), autoExternal()];
9 | }
10 | };
11 | export default generateRollupConfig({
12 | formatArr: ['es', 'cjs', 'umd'],
13 | input: 'src/index.tsx',
14 | plugins: pluginsCb,
15 | });
16 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/demo/Color.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleBarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'Nat网关',
7 | data: [['规格', 3], ['动态数', 4], ['SDK支持语言', 4]],
8 | color: '#00D9EE',
9 | },
10 | {
11 | name: 'Slb负载均衡',
12 | data: [['规格', 12], ['动态数', 11], ['SDK支持语言', 0]],
13 | color: '#007BEE',
14 | },
15 | ];
16 |
17 | export default () => {
18 | const config = {};
19 | return (
20 |
21 | );
22 | }
23 |
--------------------------------------------------------------------------------
/packages/console-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, commonjs, resolve, postcss, autoExternal } = plugins;
4 |
5 | const pluginsCb = ({ fmt, ts, file }) => {
6 | if (fmt === 'umd') {
7 | return [typescript({}), resolve(), commonjs()];
8 | } else {
9 | return [typescript({}), resolve(), commonjs(), autoExternal()];
10 | }
11 | };
12 |
13 | export default generateRollupConfig({
14 | formatArr: ['es', 'cjs'],
15 | input: 'src/index.ts',
16 | plugins: pluginsCb,
17 | });
18 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, postcss, commonjs, autoExternal } = plugins;
4 | const pluginsCb = ({ fmt, ts, file }) => {
5 | if (fmt === 'umd') {
6 | return [typescript({}), resolve(), commonjs()];
7 | } else {
8 | return [typescript({}), resolve(), commonjs(), autoExternal()];
9 | }
10 | };
11 |
12 | export default generateRollupConfig({
13 | formatArr: ['es', 'cjs', 'umd'],
14 | input: 'src/index.ts',
15 | plugins: pluginsCb,
16 | });
17 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, postcss, commonjs, autoExternal } = plugins;
4 |
5 | const pluginsCb = ({ fmt, ts }) => {
6 | if (fmt === 'umd') {
7 | return [typescript(), resolve(), commonjs()];
8 | } else {
9 | return [typescript(), resolve(), commonjs(), autoExternal()];
10 | }
11 | };
12 |
13 | export default generateRollupConfig({
14 | formatArr: ['es', 'cjs', 'umd'],
15 | input: 'src/index.ts',
16 | plugins: pluginsCb,
17 | });
18 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, commonjs, autoExternal } = plugins;
4 |
5 | const pluginsArr = ({ fmt, ts, file }) => {
6 | if (fmt === 'umd') {
7 | return [typescript({}), resolve(), commonjs()];
8 | } else {
9 | return [typescript({}), resolve(), commonjs(), autoExternal()];
10 | }
11 | };
12 |
13 | export default generateRollupConfig({
14 | formatArr: ['es', 'cjs', 'umd'],
15 | input: 'src/index.ts',
16 | plugins: pluginsArr,
17 | });
18 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/constants/index.ts:
--------------------------------------------------------------------------------
1 | export const COLORS_24 = [
2 | '#2196F3',
3 | '#2FC25B',
4 | '#13C2C2',
5 | '#66B5FF',
6 | '#41D9C7',
7 | '#6EDB8F',
8 | '#9AE65C',
9 | '#FACC14',
10 | '#E6965C',
11 | '#57AD71',
12 | '#F44336',
13 | '#738AE6',
14 | '#7564CC',
15 | '#8543E0',
16 | '#A877ED',
17 | '#5C8EE6',
18 | '#70E0E0',
19 | '#5CA3E6',
20 | '#3436C7',
21 | '#8082FF',
22 | '#DD81E6',
23 | '#F04864',
24 | '#FA7D92',
25 | '#D598D9',
26 | ];
27 |
28 | export const PIE_DEFAULT_DRAW_PADDING = [48, 48, 48, 48];
29 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, commonjs, resolve, postcss, autoExternal } = plugins;
4 |
5 | const pluginsCb = ({ fmt, ts, file }) => {
6 | if (fmt === 'umd') {
7 | return [typescript({}), resolve(), commonjs()];
8 | } else {
9 | return [typescript({}), resolve(), commonjs(), autoExternal()];
10 | }
11 | };
12 | export default generateRollupConfig({
13 | formatArr: ['es', 'cjs', 'umd'],
14 | input: 'src/index.ts',
15 | plugins: pluginsCb,
16 | });
17 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, commonjs, autoExternal } = plugins;
4 |
5 | const pluginsArr = ({ fmt, ts, file }) => {
6 | if (fmt === 'umd') {
7 | return [typescript({}), resolve(), commonjs()];
8 | } else {
9 | return [typescript({}), resolve(), commonjs(), autoExternal()];
10 | }
11 | };
12 |
13 | export default generateRollupConfig({
14 | formatArr: ['es', 'cjs', 'umd'],
15 | input: 'src/index.ts',
16 | plugins: pluginsArr,
17 | });
18 |
--------------------------------------------------------------------------------
/packages/console-line-chart/rollup.config.js:
--------------------------------------------------------------------------------
1 | import generateRollupConfig, { plugins } from '../../rollup.config';
2 |
3 | const { typescript, resolve, commonjs, autoExternal } = plugins;
4 | const pluginsArr = ({ fmt, ts, file }) => {
5 | if (fmt === 'umd') {
6 | return [typescript(), resolve(), commonjs()];
7 | } else {
8 | return [typescript(), resolve(), commonjs(), autoExternal()];
9 | }
10 | };
11 | const a = generateRollupConfig({
12 | formatArr: ['es', 'cjs', 'umd'],
13 | input: 'src/index.ts',
14 | plugins: pluginsArr,
15 | });
16 |
17 | export default a;
18 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/demo/AreaStack.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleMinilineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '奇怪的数据量',
7 | data: [
8 | ['2015', 20], ['2016', 5], ['2017', 15], ['2018', 30], ['2019', 40],
9 | ['2015', 12], ['2016', 15], ['2017', 35], ['2018', 20], ['2019', 40]
10 | ],
11 | },
12 | ];
13 |
14 | const config = {
15 | area: true,
16 | stack: true,
17 | };
18 |
19 | export default () => (
20 |
21 | );
22 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/demo/SingleColor.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleRoseChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '年份数据',
7 | data: [
8 | ['2013', 14],
9 | ['2014', 15],
10 | ['2015', 16],
11 | ['2016', 18],
12 | ['2017', 20],
13 | ['2018', 21],
14 | ['2019', 24.3],
15 | ['2020', 25],
16 | ],
17 | },
18 | ];
19 |
20 | const config = {
21 | colors: '#0093ee',
22 | };
23 |
24 | export default () => (
25 |
26 | );
27 |
--------------------------------------------------------------------------------
/.storybook/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | module.exports = ({ config }) => {
4 | config.module.rules.push({
5 | test: /\.(ts|tsx)$/,
6 | use: [
7 | {
8 | loader: require.resolve('awesome-typescript-loader'),
9 | },
10 | // Optional
11 | {
12 | loader: require.resolve('react-docgen-typescript-loader'),
13 | },
14 | ],
15 | });
16 | config.resolve.extensions.push('.ts', '.tsx');
17 | // config.resolve.alias = {
18 | // '@alicloud/console-chart': path.resolve(__dirname, '../packages/console-chart/es'),
19 | // };
20 | return config;
21 | };
22 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import Horizontal from './Horizontal';
6 | import Stack from './Stack';
7 | import Color from './Color';
8 | import Facet from './Facet';
9 | import DodgeStack from './DodgeStack';
10 |
11 | storiesOf('ConsoleBarChart', module)
12 | .add('基本用法', () => )
13 | .add('水平柱状图', () => )
14 | .add('堆叠柱状图', () => )
15 | .add('镜面柱状图', () => )
16 | .add('分组柱状图', () => )
17 | .add('自定义数据列颜色', () => );
18 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/demo/Multi.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleRadarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ecs',
7 | data: [['specification', 20], ['feature', 10], ['doc', 15]],
8 | color: '#0093EE',
9 | },
10 | {
11 | name: 'oss',
12 | data: [['specification', 25], ['feature', 15], ['doc', 31]],
13 | color: '#E288CE',
14 | }
15 | ];
16 |
17 | const config = {
18 | xAxis: {
19 | label: {
20 | formatter: val => val + '~'
21 | }
22 | },
23 | };
24 |
25 | export default () => (
26 |
27 | );
28 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/demo/Axis.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleRoseChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '年份数据',
7 | data: [
8 | ['2013', 14],
9 | ['2014', 15],
10 | ['2015', 16],
11 | ['2016', 18],
12 | ['2017', 20],
13 | ['2018', 21],
14 | ['2019', 24.3],
15 | ['2020', 25],
16 | ],
17 | },
18 | ];
19 |
20 | const config = {
21 | axis: true,
22 | label: false,
23 | padding: [50, 50, 50, 50],
24 | legend: false,
25 | };
26 |
27 | export default () => (
28 |
29 | );
30 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/size.ts:
--------------------------------------------------------------------------------
1 | import { isNumber, isFunction } from '../common/utils';
2 |
3 | export default function(
4 | geom,
5 | config,
6 | sizeConfig,
7 | yField = 'type',
8 | callbackYField = 'x*y*type*facet'
9 | ) {
10 | if (!sizeConfig) {
11 | return;
12 | }
13 | if (Array.isArray(sizeConfig)) {
14 | if (isNumber(sizeConfig[0] && isNumber(sizeConfig[1]))) {
15 | geom.size(yField, sizeConfig);
16 | } else {
17 | geom.size(...sizeConfig);
18 | }
19 | } else if (isFunction(sizeConfig)) {
20 | geom.size(callbackYField, sizeConfig);
21 | } else {
22 | geom.size(sizeConfig);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import YAxisColor from './YAxisColor';
6 | import SingleYAxis from './SingleYAxis';
7 | import Smooth from './Smooth';
8 | import Stack from './Stack';
9 | import Color from './Color';
10 | import Click from './Click';
11 |
12 | storiesOf('ConsoleComboChart', module)
13 | .add('基础混合图', () => )
14 | .add('纵坐标设置颜色', () => )
15 | .add('单个纵坐标', () => )
16 | .add('光滑曲线', () => )
17 | .add('堆叠图', () => )
18 | .add('自定义颜色', () => )
19 | .add('点击事件', () => );
20 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/Legend.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'Source',
7 | data: [
8 | ['A', 4590],
9 | ['B', 2628],
10 | ['C', 1228],
11 | ['D', 825],
12 | ['E', 622],
13 | ['F', 1207],
14 | ],
15 | },
16 | ];
17 |
18 | const config = {
19 | padding: [60, 'auto', 0, 'auto'],
20 | legend: {
21 | position: 'top',
22 | offsetY: -10,
23 | itemFormatter: function(value) {
24 | return value + 'K';
25 | },
26 | },
27 | };
28 |
29 | export default () => (
30 |
31 | );
32 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/updater.ts:
--------------------------------------------------------------------------------
1 | import { shallowEqual } from '../common/utils';
2 |
3 | const Updater = {
4 | needRebuildChart(unifiedProps, nextUnifiedProps) {
5 | if (unifiedProps == null || nextUnifiedProps == null) return false;
6 |
7 | if (
8 | !shallowEqual(unifiedProps.padding, nextUnifiedProps.padding) ||
9 | !shallowEqual(unifiedProps.background, nextUnifiedProps.background) ||
10 | !shallowEqual(unifiedProps.plotBackground, nextUnifiedProps.plotBackground) ||
11 | !shallowEqual(unifiedProps.pixelRatio, nextUnifiedProps.pixelRatio)
12 | ) {
13 | return true;
14 | }
15 |
16 | return false;
17 | },
18 | };
19 |
20 | export default Updater;
21 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/demo/Axis.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleRadarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'oss',
7 | data: [['specification', 29], ['feature', 28], ['doc', 31]],
8 | color: '#E288CE',
9 | }
10 | ];
11 |
12 | const config = {
13 | xAxis: {
14 | label: {
15 | htmlTemplate: (val, item, index) => {
16 | return `
17 |
18 |
${val}
19 |
${index}
20 |
21 | `;
22 | }
23 | }
24 | },
25 | };
26 |
27 | export default () => (
28 |
29 | );
30 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/LegendRight.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'Source',
7 | data: [
8 | ['A', 4590],
9 | ['B', 2628],
10 | ['C', 1228],
11 | ['D', 825],
12 | ['E', 622],
13 | ['F', 1207],
14 | ],
15 | },
16 | ];
17 |
18 | const config = {
19 | padding: [0, 120 + 50, 0, 0],
20 | legend: {
21 | position: 'right-center',
22 | offsetY: 10,
23 | offsetX: 50,
24 | itemFormatter: function(value) {
25 | return `${value} 400 40%`;
26 | },
27 | },
28 | };
29 |
30 | export default () => (
31 |
32 | );
33 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/CircleGuide.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '时长',
7 | data: [['1年', 45], ['2年', 26], ['3年', 12], ['4年', 8], ['5年', 10], ['6年以上', 27]],
8 | },
9 | ];
10 |
11 | let config = {
12 | cycle: true,
13 | guide: {
14 | html: {
15 | position: ['50%', '50%'],
16 | htmlContent:
17 | '1年
45
',
18 | alignX: 'middle',
19 | alignY: 'middle',
20 | },
21 | },
22 | };
23 |
24 | export default () => (
25 |
26 | );
27 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/OneDotToLine.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [
8 | ['2015', 20]
9 | ],
10 | },
11 | ];
12 |
13 | const config: any = {};
14 |
15 | export default () => {
16 | const dataLength = data[0].data.length;
17 | if (dataLength === 1) {
18 | config.guide = {
19 | line: {
20 | start: ['0%', '0'],
21 | end: ['100%', '0'],
22 | lineStyle: {
23 | stroke: '#2196F3',
24 | lineWidth: 2,
25 | lineDash: [ 0, 0 ]
26 | },
27 | }
28 | };
29 | }
30 | return (
31 |
32 | );
33 | };
34 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/Tooltip.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '等级',
7 | data: [
8 | ['11', 55.0],
9 | ['12', 26.8],
10 | ['13', 112.8],
11 | ['14', 81.5],
12 | ['15', 61.2],
13 | ['16', 7],
14 | ['17', 12],
15 | ],
16 | },
17 | ];
18 |
19 | const config = {
20 | tooltip: {
21 | itemTpl: '' +
22 | '' +
23 | 'v{name}: {value}%' +
24 | '',
25 | }
26 | };
27 |
28 | export default () => (
29 |
30 | );
31 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleComboChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ECS使用量',
7 | type: 'bar',
8 | yAxis: 0,
9 | data: [['2015', 5], ['2016', 10], ['2017', 15], ['2018', 30], ['2019', 36]],
10 | },
11 | {
12 | name: 'ECS同比增长',
13 | type: 'line',
14 | yAxis: 1,
15 | data: [['2015', 0.3], ['2016', 0.1], ['2017', 0.5], ['2018', 1], ['2019', 0.2]],
16 | },
17 | ];
18 |
19 | const config = {
20 | yAxis: [
21 | {
22 | formatter: val => val + '万',
23 | },
24 | {
25 | formatter: val => val * 100 + '%',
26 | },
27 | ],
28 | };
29 |
30 | export default () => (
31 |
32 | );
33 |
--------------------------------------------------------------------------------
/site/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gatsby-theme-console-doc-template",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "scripts": {
7 | "clean": "gatsby clean",
8 | "dev": "npm run clean && gatsby develop",
9 | "start": "npm run develop",
10 | "debug": "npm run clean && npx --node-arg=--inspect-brk gatsby develop",
11 | "build": "npm run clean && gatsby build --prefix-paths",
12 | "push-build": "npm run build && gh-pages -d public"
13 | },
14 | "dependencies": {},
15 | "devDependencies": {
16 | "@alicloud/gatsby-theme-console-doc": "^1.0.11",
17 | "gatsby": "^2.18.2",
18 | "react": "^16.12.0",
19 | "react-dom": "^16.12.0",
20 | "styled-components": "^4.4.1",
21 | "typescript": "^3.7.2",
22 | "gh-pages": "^2.1.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/LegendTip.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'Source',
7 | data: [
8 | ['A', 4590],
9 | ['B', 2628],
10 | ['C', 1228],
11 | ['D', 825],
12 | ['E', 622],
13 | ['F', 1207],
14 | ],
15 | },
16 | ];
17 |
18 | const config = {
19 | padding: [0, 120 + 50, 0, 0],
20 | legend: {
21 | position: 'right-center',
22 | offsetY: 10,
23 | offsetX: 50,
24 | itemFormatter: function(value: string) {
25 | return `${value} 400 40%`;
26 | },
27 | tip: true,
28 | tipFormatter: (value: string) => value + 1,
29 | },
30 | };
31 |
32 | export default () => (
33 |
34 | );
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # common
2 |
3 | .*
4 | !.*ignore
5 | !.*rc
6 | !.gitattributes
7 | !.aoneci.yml
8 | !.editorconfig
9 | !.storybook
10 | !.demoProjectTemplate
11 | !site/.eslintrc.js
12 |
13 | site/public/
14 | lerna-debug.json
15 | # Logs
16 | logs
17 | *.log*
18 |
19 | # Runtime data
20 | pids
21 | *.pid
22 | *.seed
23 | *.pid.lock
24 |
25 | # Directory for instrumented libs generated by jscoverage/JSCover
26 | lib-cov
27 |
28 | # Coverage directory used by tools like istanbul
29 | coverage
30 |
31 | # Dependency directories
32 | bower_components
33 | node_modules/
34 | jspm_packages/
35 |
36 | # Compiled binary addons (https://nodejs.org/api/addons.html)
37 | build/Release
38 | lib/
39 | es/
40 | dist/
41 |
42 | # TypeScript v1 declaration files
43 | typings/
44 |
45 | # Output of 'npm pack'
46 | *.tgz
47 |
48 | packages/*/lib/
49 | packages/*/es/
50 | packages/*/dist/
--------------------------------------------------------------------------------
/packages/console-funnel-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-funnel-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib es dist",
14 | "build": "npm run clean && rollup -c",
15 | "prepare": "npm run build",
16 | "watch": "rollup -c -w"
17 | },
18 | "publishConfig": {
19 | "access": "public"
20 | },
21 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-funnel-chart",
22 | "license": "MIT",
23 | "dependencies": {
24 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
25 | "tslib": "^1.10.0"
26 | },
27 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
28 | }
29 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 0.4.5(2020-02-09)
4 | ### Fixs
5 | - 修复Console-sankey-chart packages.json依赖版本不正确的问题
6 |
7 | ## 0.4.4(2020-02-06)
8 | ### Features
9 | - Console-shared-utils加入legend.tip属性支持
10 |
11 | ## 0.4.3(2020-01-03)
12 | ### Features
13 | - Console-sankey-chart加入拓扑图的支持
14 |
15 | ## 0.4.2(2020-01-03)
16 | ### Fixs
17 | - 修复Console-sankey-chart默认Tooltip展示无效信息的问题
18 |
19 | ## 0.4.1(2020-01-02)
20 | ### Fixs
21 | - 升级版本号修复部分包发包失败的错误版本号
22 |
23 | ## 0.4.0(2020-01-02)
24 | ### Features
25 | - 桑基图Console-sankey-chart支持
26 |
27 | ## 0.3.0(2019-12-30)
28 | ### Features
29 | - Console-pie-chart 加入`sliceGap`支持
30 |
31 | ## 0.2.0(2019-12-27)
32 |
33 | ### Fixs
34 | - 修复测试版本里众多问题
35 |
36 | ### Docs
37 | - 每个组件加入对应的示例
38 |
39 | ## 0.1.0-beta.1(2019-10-27)
40 |
41 | ### Features
42 | - 发布第一个测试可用版本
43 |
44 | ## 0.1.0(2019-12-05)
45 |
46 | ### Features
47 | - 发布第一个正式版本
--------------------------------------------------------------------------------
/.demoProjectTemplate/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wind-demo",
3 | "version": "1.0.0",
4 | "description": "",
5 | "keywords": [],
6 | "main": "src/index.tsx",
7 | "dependencies": {
8 | "styled-components": "^4.2.0",
9 | "react": "16.8.4",
10 | "react-dom": "16.8.4",
11 | "react-scripts": "2.1.3",
12 | "@alicloud/console-chart": "^0.4.8"
13 | },
14 | "devDependencies": {
15 | "@types/react": "16.8.8",
16 | "@types/react-dom": "16.8.2",
17 | "@types/styled-components": "^4.1.8",
18 | "typescript": "3.3.3"
19 | },
20 | "scripts": {
21 | "start": "react-scripts start",
22 | "build": "react-scripts build",
23 | "test": "react-scripts test --env=jsdom",
24 | "eject": "react-scripts eject"
25 | },
26 | "browserslist": [
27 | ">0.2%",
28 | "not dead",
29 | "not ie <= 11",
30 | "not op_mini all"
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "useWorkspaces": true,
3 | "npmClient": "yarn",
4 | "publish": {
5 | "message": "Publish",
6 | "npmClient": "npm",
7 | "registry": "https://registry.npmjs.org/",
8 | "version": {
9 | "allowBranch": [
10 | "master",
11 | "develop"
12 | ]
13 | }
14 | },
15 | "packages": [
16 | "packages/console-bar-chart",
17 | "packages/console-chart",
18 | "packages/console-combo-chart",
19 | "packages/console-dot-chart",
20 | "packages/console-funnel-chart",
21 | "packages/console-line-chart",
22 | "packages/console-miniline-chart",
23 | "packages/console-pie-chart",
24 | "packages/console-radar-chart",
25 | "packages/console-rose-chart",
26 | "packages/console-shared-utils",
27 | "packages/console-tree-graph",
28 | "packages/console-sankey-chart"
29 | ],
30 | "version": "0.4.10-alpha.0"
31 | }
32 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-bar-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "lint": "tslint --project .",
14 | "clean": "rm -rf lib es dist",
15 | "build": "npm run clean && rollup -c",
16 | "prepare": "npm run build",
17 | "watch": "rollup -c -w"
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-combo-chart",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
26 | "tslib": "^1.10.0"
27 | },
28 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
29 | }
30 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-pie-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib es dist",
14 | "build": "npm run clean && rollup -c",
15 | "prepare": "npm run build",
16 | "watch": "rollup -c -w",
17 | "lint": "tslint --project ."
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-pie-chart",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
26 | "tslib": "^1.10.0"
27 | },
28 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
29 | }
30 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/demo/Area.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleRadarChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'oss',
7 | data: [['specification', 25], ['feature', 24], ['doc', 26]],
8 | color: '#E288CE',
9 | }
10 | ];
11 |
12 | const config = {
13 | xAxis: {
14 | label: {
15 | formatter: val => val + '~'
16 | }
17 | },
18 | guide: {
19 | line: [
20 | {
21 | start: ['specification', 25.5],
22 | end: ['feature', 25.5],
23 | },
24 | {
25 | start: ['specification', 25.5],
26 | end: ['doc', 25.5],
27 | },
28 | {
29 | start: ['feature', 25.5],
30 | end: ['doc', 25.5],
31 | }
32 | ],
33 | },
34 | area: true,
35 | };
36 |
37 | export default () => (
38 |
39 | );
40 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-radar-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib es dist",
14 | "build": "npm run clean && rollup -c ",
15 | "prepare": "npm run build",
16 | "watch": "rollup -c -w",
17 | "lint": "tslint --project ."
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-radar-chart",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
26 | "tslib": "^1.10.0"
27 | },
28 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
29 | }
30 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-rose-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib es dist",
14 | "build": "npm run clean && rollup -c",
15 | "prepare": "npm run build",
16 | "watch": "rollup -c -w",
17 | "lint": "tslint --project ."
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-rose-chart",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
26 | "tslib": "^1.10.0"
27 | },
28 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
29 | }
30 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/config/index.ts:
--------------------------------------------------------------------------------
1 | import consoleDefaultConfig from './default';
2 | import consoleYunzhiConfig from './yunzhi';
3 |
4 | const consoleConfigMap = {
5 | default: consoleDefaultConfig,
6 | yunzhi: consoleYunzhiConfig,
7 | };
8 |
9 | const CONSOLE_CONFIG_KEY = 'console_config_key';
10 | const CONSOLE_DEFAULT_CONFIG_KEY = 'default';
11 |
12 | export function setConsoleConfig(key: string) {
13 | if (!key) {
14 | return;
15 | }
16 | try {
17 | window.localStorage.setItem(CONSOLE_CONFIG_KEY, key);
18 | } catch (e) {}
19 | }
20 |
21 | export function getConsoleConfig(key?: string) {
22 | let consoleConfigKey = null;
23 | try {
24 | consoleConfigKey = window.localStorage.getItem(CONSOLE_CONFIG_KEY);
25 | } catch (e) {}
26 | key = key || consoleConfigKey;
27 | return Object.assign(consoleConfigMap[CONSOLE_DEFAULT_CONFIG_KEY], consoleConfigMap[key]);
28 | }
29 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-dot-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean": "rm -rf es lib dist",
13 | "clean-rpt": "rm -rf .rpt2_cache",
14 | "build": "rm -rf ./lib && rollup -c",
15 | "prepare": "rm -rf ./lib && rollup -c",
16 | "watch": "rollup -c -w",
17 | "lint": "tslint --project ."
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-dot-chart",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
26 | "tslib": "^1.10.0"
27 | },
28 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
29 | }
30 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-shared-utils",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es"
9 | ],
10 | "scripts": {
11 | "clean-rpt": "rm -rf .rpt2_cache",
12 | "clean": "rm -rf lib es",
13 | "build": "npm run clean && rollup -c",
14 | "prepare": "npm run build",
15 | "watch": "rollup -c -w"
16 | },
17 | "publishConfig": {
18 | "access": "public"
19 | },
20 | "peerDependencies": {
21 | "react": "^16.9.0"
22 | },
23 | "devDependencies": {
24 | "@types/lodash": "^4.14.138",
25 | "@types/react": "^16.9.2",
26 | "rollup": "1.19.4"
27 | },
28 | "dependencies": {
29 | "@antv/g2": "3.4.10",
30 | "lodash": "^4.17.15",
31 | "tslib": "^1.10.0"
32 | },
33 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
34 | }
35 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-miniline-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib es dist",
14 | "build": "npm run clean && rollup -c",
15 | "prepare": "npm run build",
16 | "watch": "rollup -c -w",
17 | "lint": "tslint --project ."
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-miniline-chart",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
26 | "tslib": "^1.10.0"
27 | },
28 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
29 | }
30 |
--------------------------------------------------------------------------------
/docs/2-concepts.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: concepts
3 | zhName: 基本介绍
4 | sort: 2
5 | ---
6 |
7 | # 图表库简介
8 |
9 | # Console-Chart
10 |
11 | Console-Chart 是阿里云xconsole团队基于[G2](https://antv.alipay.com/zh-cn/index.html)封装的控制台图表组件库。
12 |
13 | 在介绍 Console-Chart 之前,先介绍下 G2。[G2](https://antv.alipay.com/zh-cn/index.html)是蚂蚁金服前端团队开发的底层图表库,这个图表库功能强大,配置丰富,使用会带来以下问题:
14 |
15 | - 上手成本较大
16 | - 重复的图表开发
17 | - 不一致的交互体验
18 | - 基于场景的图表能力无法沉淀
19 |
20 | 同时我们也有自己的业务诉求:
21 |
22 | - 保持控制台图表组件的视觉、交互统一
23 | - 沉淀有控制台特色的图表能力
24 | - 为我们的客户提供高效的图表开发能力
25 |
26 | 于是 Console-Chart 就诞生了。
27 |
28 | # 开源
29 | 为了帮助第三方云云产商提供统一的控制台解决方案,我们将控制台开发套件开源, **Console Chart** 是其中的一部分。
30 |
31 | 仓库地址: [alibaba-console-chart](https://github.com/aliyun/alibabacloud-console-chart)
32 |
33 | npm包地址:[@alicloud/console-chart](https://www.npmjs.com/package/@alicloud/console-chart)
34 |
35 | 有任何问题欢迎在github提供 [Issue](https://github.com/aliyun/alibabacloud-console-chart/issues)
36 |
37 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-combo-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib es dist",
14 | "compile": "rm -rf es && npx tsc --outDir es",
15 | "build": "npm run clean && rollup -c",
16 | "prepare": "npm run build",
17 | "watch": "rollup -c -w"
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-bar-chart",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
26 | "tslib": "^1.10.0"
27 | },
28 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
29 | }
30 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import MultiCol from './MultiCol';
6 | import LinkStyle from './LinkStyle';
7 | import Vertical from './Vertical';
8 | import NodeAlign from './NodeAlign';
9 | import Tooltip from './Tooltip';
10 | import Topology from './Topology';
11 | import TopologyVertical from './TopologyVertical';
12 | // import NodeShape from './NodeShape';
13 |
14 | storiesOf('ConsoleSankeyChart', module)
15 | .add('基本桑基图', () => )
16 | .add('多列情况', () => )
17 | .add('配置边的样式', () => )
18 | .add('垂直布局', () => )
19 | .add('节点排列方式', () => )
20 | .add('自定义Tooltip', () => )
21 | .add('拓扑图', () => )
22 | .add('垂直拓扑图', () => )
23 | // .add('自定义节点展示内容', () => )
24 |
--------------------------------------------------------------------------------
/packages/console-tree-graph/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-tree-graph",
3 | "version": "0.4.5",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib es dist",
14 | "build": "npm run clean && rollup -c ",
15 | "prepare": "npm run build",
16 | "watch": "rollup -c -w",
17 | "lint": "tslint --project ."
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-tree-graph",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@antv/g6": "^3.2.4",
26 | "tslib": "^1.10.0"
27 | },
28 | "peerDependencies": {
29 | "react": "^16.9.0"
30 | },
31 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
32 | }
33 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/GradualColor.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'A产品',
7 | data: [['2015', 20], ['2016', 5], ['2017', 15], ['2018', 30], ['2019', 40]],
8 | color: ['#0072ff', 'l (90) 0:#0072ff 1:#E3F2FD']
9 | },
10 | ];
11 |
12 | const config = {
13 | area: true,
14 | smooth: true,
15 | };
16 |
17 | const onTooltipChange = evt => {
18 | let items = evt.items; // tooltip显示的项,不处理的话会有2项
19 | // 在这里 去掉你想去掉的item,这里选择只要纯色的(线的颜色)
20 | const newItems = items.filter(x => x.color === '#0072ff');
21 | items.splice(0); // 将原来的Tooltip Items清空
22 | items.push(newItems[0]); // 只展示你筛选后的结果
23 | }
24 |
25 | export default () => (
26 |
34 | );
35 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-sankey-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib es dist",
14 | "build": "npm run clean && rollup -c",
15 | "prepare": "npm run build",
16 | "watch": "rollup -c -w",
17 | "lint": "tslint --project ."
18 | },
19 | "publishConfig": {
20 | "access": "public"
21 | },
22 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-sankey-chart",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
26 | "d3-sankey": "^0.12.3",
27 | "tslib": "^1.10.0"
28 | },
29 | "gitHead": "76efc38b27cda1d046b06c2e1cf8ac83de63ced1"
30 | }
31 |
--------------------------------------------------------------------------------
/packages/console-tree-graph/README.md:
--------------------------------------------------------------------------------
1 |
2 | # 树图API
3 |
4 | # 引入方式
5 |
6 | ```javascript
7 | import ConsoleTreeGraph from '@alicloud/console-tree-graph';
8 | ```
9 |
10 | 注意,目前为了减少打包之后的体积大小,暂不将Graph相关的加入`console-chart`包内,所以只能通过单包引入的方式使用。
11 |
12 | # 示例 Demo
13 |
14 | ## 基本使用
15 |
16 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
17 |
18 | # 配置 Config
19 |
20 | ## 数据列配置
21 |
22 | | 属性 | 说明 | 类型 | 默认值 | 可选值 |
23 | | --- | --- | --- | --- | --- |
24 | | name | 数据列名称 | String | - | - |
25 | | data | 数据 | Object | - | - |
26 |
27 | 注意:与普通图表不同的是,树图的数据结构为一个`JSON对象`,通过`children`属性来关联子级节点。
28 |
29 | 最简单的一个数据例子:
30 | ```json
31 | {
32 | id: '01',
33 | children: [
34 | {
35 | id: '011',
36 | children: []
37 | },
38 | {
39 | id: '012',
40 | children: [
41 | {
42 | id: '0121',
43 | }
44 | ]
45 | }
46 | ]
47 | }
48 | ```
49 |
50 | ## 专属配置
51 |
52 | ### fitView: Boolean
53 | 是否自适应画布
54 |
55 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-rose-chart
3 | zhName: 玫瑰图
4 | ---
5 |
6 | # 玫瑰图API
7 |
8 | # 引入方式
9 |
10 | ```javascript
11 | import { ConsoleRoseChart } from '@alicloud/console-chart';
12 | ```
13 |
14 | # 示例 Demo
15 |
16 | ## 基本用法
17 |
18 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
19 |
20 | ## 带坐标轴
21 |
22 | [MDXInstruction:importDemo:Axis](./demo/Axis.tsx)
23 |
24 | ## 单色玫瑰图
25 |
26 | [MDXInstruction:importDemo:SingleColor](./demo/SingleColor.tsx)
27 |
28 | # 配置 Config
29 |
30 | # 数据列配置
31 |
32 | | 属性 | 说明 | 类型 | 默认值 | 可选值 |
33 | | --- | --- | --- | --- | --- |
34 | | name | 数据列名称 | String | - | - |
35 | | data | 数据 | Array | - | - |
36 |
37 | ## 通用配置
38 |
39 | | 属性 | 说明 |
40 | | --- | --- |
41 | | padding | 配置绘图内边距 |
42 | | xAxis | 配置x轴 |
43 | | yAxis | 配置y轴 |
44 | | legend | 配置图例 |
45 | | guide | 配置辅助元素 |
46 | | tooltip | 配置提示信息 |
47 | | label | 配置图形文本 |
48 | | size | 配置自定义大小 |
49 | | style | 配置自定义样式 |
50 |
51 | ## 专属配置
52 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/demo/DodgeStack.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleBarChart } from '@alicloud/console-chart';
3 |
4 | let data = [
5 | {
6 | name: 'ECS',
7 | dodge: '分组1',
8 | data: [],
9 | },
10 | {
11 | name: 'OSS',
12 | dodge: 'OSS',
13 | data: [],
14 | },
15 | {
16 | name: 'ACS',
17 | dodge: 'OSS',
18 | data: [],
19 | },
20 | {
21 | name: 'RDS',
22 | dodge: 'OSS',
23 | data: [],
24 | },
25 | ];
26 |
27 | for (let i = 1; i < 11; i++) {
28 | const name = i + '月';
29 | data[0].data.push([name, Math.random() * 100 + 300]);
30 | data[1].data.push([name, Math.random() * 100 + 100]);
31 | data[2].data.push([name, Math.random() * 100 + 100]);
32 | data[3].data.push([name, Math.random() * 100 + 100]);
33 | }
34 |
35 | export default () => {
36 | const config = {
37 | dodgeStack: true,
38 | };
39 | return (
40 |
41 | );
42 | }
43 |
--------------------------------------------------------------------------------
/docs/13-config-style.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: config-style
3 | zhName: 配置-样式
4 | sort: 13
5 | ---
6 |
7 | # config-自定义样式
8 |
9 | 用于配置几何标记显示的图形属性。
10 |
11 |
12 | # 配置方法
13 |
14 | ## 关闭 style
15 | Console-Chart 默认关闭所有图形自定义样式。
16 |
17 |
18 | ## 自定义
19 |
20 | ### 统一设置
21 | ```javascript
22 | config.style = {
23 | lineWidth: 2,
24 | };
25 | ```
26 |
27 |
28 | ### callback方式设置
29 | 使用回调函数设置属性
30 |
31 | ```javascript
32 | config.style = [
33 | 'x*y',
34 | {
35 | lineWidth: (x, y) => {},
36 | stroke: 'red',
37 | },
38 | ];
39 | ```
40 |
41 |
42 | # 属性列表
43 |
44 | ## 通用属性
45 |
46 | - `fill` 设置用于填充绘画的颜色、渐变或模式;
47 | - `stroke` 设置用于笔触的颜色、渐变或模式;
48 | - `shadowColor` 设置用于阴影的颜色;
49 | - `shadowBlur` 设置用于阴影的模糊级别;
50 | - `shadowOffsetX` 设置阴影距形状的水平距离;
51 | - `shadowOffsetY` 设置阴影距形状的垂直距离;
52 | - `opacity` 设置绘图的当前 alpha 或透明值;
53 | - `globalCompositeOperation` 设置新图像如何绘制到已有的图像上
54 |
55 | style 的更详细的配置项请参考:[绘图属性](https://www.yuque.com/antv/g2-docs/api-graphic)
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Console Chart
2 |
3 | Console Chart 是阿里云云管控解决方案开发套件的一部分,旨在为用户提供一款**开箱即用、统一视觉方案**的图表组件库。
4 |
5 |
6 |
7 |
8 |
9 | [![NPM version][npm-image]][npm-url]
10 |
11 | [npm-image]: https://img.shields.io/npm/v/@alicloud/console-chart.svg?style=flat-square
12 | [npm-url]: https://npmjs.org/package/@alicloud/console-chart
13 |
14 |
15 | ## Install
16 |
17 | ```bash
18 | npm install @alicloud/console-chart --save
19 | ```
20 |
21 | ## Usage
22 |
23 | ```js
24 | // 引入组件
25 | import { ConsoleLineChart } from "@alicloud/console-chart";
26 |
27 | ;
28 | ```
29 |
30 | ## API 文档
31 |
32 | [API 文档](https://aliyun.github.io/alibabacloud-console-chart/guides/quick-start)
33 |
34 | ## CONTRIBUTING
35 |
36 | 代码贡献请参考 [CONTRIBUTING.md](CONTRIBUTING.md)
37 |
38 | ## CHANGELOG
39 |
40 | 版本日志请参考 [CHANGELOG.md](CHANGELOG.md)
41 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/tooltip.ts:
--------------------------------------------------------------------------------
1 | import { get, isFunction } from "../common/utils";
2 |
3 | const sortFun = {
4 | // 升序
5 | asc(a: any, b: any) {
6 | return a.value - b.value;
7 | },
8 | // 降序
9 | desc(a: any, b: any) {
10 | return b.value - a.value;
11 | }
12 | };
13 |
14 | function tooltip(chart: any, config: any, configTooltip, specConfig = null) {
15 | if (configTooltip === false || get(configTooltip, "visible") === false) {
16 | chart.tooltip(false);
17 | return;
18 | }
19 | const finalConfigTooltip = Object.assign({}, configTooltip, specConfig);
20 |
21 | chart.tooltip(finalConfigTooltip);
22 |
23 | const sort = get(finalConfigTooltip, "sort");
24 | if (sort) {
25 | chart.on("tooltip:change", (ev: any) => {
26 | // 如果设置了合法的排序关键字,则开始排序
27 | if (isFunction(sort)) {
28 | ev.items.sort(sort);
29 | } else if (sortFun[sort]) {
30 | ev.items.sort(sortFun[sort]);
31 | }
32 | });
33 | }
34 | }
35 |
36 | export default tooltip;
37 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/config/default.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | ConsoleLineChart: {},
3 | ConsoleBarChart: {},
4 | ConsoleComboChart: {},
5 | ConsolePieChart: {},
6 | ConsoleMinilineChart: {
7 | padding: [0, 0, 0, 0],
8 | xAxis: {},
9 | yAxis: {},
10 | tooltip: false,
11 | area: false,
12 | smooth: false,
13 | symbol: false,
14 | label: false,
15 | },
16 | ConsoleRadarChart: {
17 | xAxis: {
18 | label: {},
19 | line: null,
20 | tickLine: null,
21 | grid: {
22 | lineStyle: {
23 | lineDash: null,
24 | },
25 | },
26 | },
27 | yAxis: {
28 | label: {
29 | offset: 8,
30 | textStyle: {
31 | textAlign: 'right',
32 | },
33 | },
34 | line: null,
35 | tickLine: null,
36 | grid: {
37 | type: 'polygon',
38 | lineStyle: {
39 | lineDash: null,
40 | },
41 | },
42 | },
43 | },
44 | ConsoleFunnelChart: {},
45 | ConsoleDotChart: {},
46 | ConsoleRoseChart: {},
47 | };
48 |
--------------------------------------------------------------------------------
/packages/console-line-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-line-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "lib",
8 | "es",
9 | "dist"
10 | ],
11 | "scripts": {
12 | "clean-rpt": "rm -rf .rpt2_cache",
13 | "clean": "rm -rf lib dist es",
14 | "compile": "rm -rf es && npx tsc --outDir es",
15 | "compile:cjs": "rm -rf lib && npx tsc --outDir lib --module commonjs",
16 | "bundle": "rm -rf dist && rollup -c",
17 | "build": "npm run clean && rollup -c",
18 | "prepare": "npm run build",
19 | "watch": "rollup -c -w",
20 | "lint": "tslint --project ."
21 | },
22 | "publishConfig": {
23 | "access": "public"
24 | },
25 | "repository": "https://github.com/aliyun/alibabacloud-console-chart/tree/master/packages/console-line-chart",
26 | "license": "MIT",
27 | "dependencies": {
28 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0",
29 | "tslib": "^1.10.0"
30 | },
31 | "gitHead": "c79b139c3484d9590cfe3e43b106c5e718bf2ff9"
32 | }
33 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './types/index';
2 |
3 | import { G2 } from './common/utils';
4 | import * as Utils from './common/utils';
5 | import * as Constants from './constants/index';
6 | export { G2, Utils, Constants };
7 |
8 | export * from './g2Helper/common';
9 | export { default as dataAdapter } from './g2Helper/dataAdapter';
10 |
11 | export * from './g2Helper/rectAutoTickCount';
12 |
13 | export { default as axisX } from './g2Helper/axisX';
14 | export { default as axisY } from './g2Helper/axisY';
15 | export { default as drawLine } from './g2Helper/drawLine';
16 |
17 | export { default as g2Tooltip } from './g2Helper/tooltip';
18 | export { default as g2Guide } from './g2Helper/guide';
19 | export { default as g2Label } from './g2Helper/label';
20 | export { default as g2Style } from './g2Helper/style';
21 | export { default as g2Size } from './g2Helper/size';
22 | export { default as g2Legend } from './g2Helper/legend';
23 | export { default as g2Factory } from './g2Helper/g2Factory';
24 |
25 | export * from './theme/index';
26 | export * from './config/index';
27 |
--------------------------------------------------------------------------------
/packages/console-chart/src/index.ts:
--------------------------------------------------------------------------------
1 | import ConsoleBarChart from '@alicloud/console-bar-chart';
2 | import ConsoleLineChart from '@alicloud/console-line-chart';
3 | import ConsoleComboChart from '@alicloud/console-combo-chart';
4 | import ConsoleFunnelChart from '@alicloud/console-funnel-chart';
5 | import ConsoleMinilineChart from '@alicloud/console-miniline-chart';
6 | import ConsolePieChart from '@alicloud/console-pie-chart';
7 | import ConsoleDotChart from '@alicloud/console-dot-chart';
8 | import ConsoleRadarChart from '@alicloud/console-radar-chart';
9 | import ConsoleRoseChart from '@alicloud/console-rose-chart';
10 | import ConsoleSankeyChart from '@alicloud/console-sankey-chart';
11 |
12 | import { G2, setConsoleConfig, setConsoleTheme } from '@alicloud/console-shared-utils';
13 |
14 | export {
15 | ConsoleBarChart,
16 | ConsoleLineChart,
17 | ConsoleComboChart,
18 | ConsoleFunnelChart,
19 | ConsoleMinilineChart,
20 | ConsolePieChart,
21 | ConsoleDotChart,
22 | ConsoleRadarChart,
23 | ConsoleRoseChart,
24 | ConsoleSankeyChart,
25 | setConsoleConfig,
26 | setConsoleTheme,
27 | G2,
28 | };
29 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-dot-chart
3 | zhName: 散点图
4 | ---
5 |
6 | # 散点图API
7 |
8 | # 引入方式
9 |
10 | ```javascript
11 | import { ConsoleDotChart } from '@alicloud/console-chart';
12 | ```
13 |
14 | # 示例 Demo
15 |
16 | ## 基本散点图
17 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
18 |
19 | ## 多组数据
20 | [MDXInstruction:importDemo:Multi](./demo/Multi.tsx)
21 |
22 | ## 自定义点大小
23 | [MDXInstruction:importDemo:Size](./demo/Size.tsx)
24 |
25 | ## 扰动图
26 | [MDXInstruction:importDemo:Disturbance](./demo/Disturbance.tsx)
27 |
28 | # 配置 Config
29 |
30 | # 数据列配置
31 | | 属性 | 说明 | 类型 | 默认值 | 可选值 |
32 | | --- | --- | --- | --- | --- |
33 | | name | 数据列名称 | String | - | - |
34 | | data | 数据 | - | - | - |
35 | | color | 自定义当前数据列颜色 | String | 主题`color_24` | - |
36 |
37 | ## 通用配置
38 |
39 | | 属性 | 说明 |
40 | | --- | --- |
41 | | padding | 配置绘图内边距 |
42 | | xAxis | 配置x轴 |
43 | | yAxis | 配置y轴 |
44 | | legend | 配置图例 |
45 | | guide | 配置辅助元素 |
46 | | tooltip | 配置提示信息 |
47 | | label | 配置图形文本 |
48 | | size | 配置自定义大小 |
49 | | style | 配置自定义样式 |
50 |
51 | ## 专属配置
52 |
53 | ### jitter: Boolean
54 | 是否展示成扰动图
55 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/Multi.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ECS',
7 | data: [
8 | ['201804', 31],
9 | ['201805', 39],
10 | ['201806', 32],
11 | ['201807', 35],
12 | ['201808', 31],
13 | ['201809', 36],
14 | ['201810', 32],
15 | ['201811', 34],
16 | ],
17 | },
18 | {
19 | name: 'OSS',
20 | data: [
21 | ['201804', 12],
22 | ['201805', 12],
23 | ['201806', 12],
24 | ['201807', 11],
25 | ['201808', 10],
26 | ['201809', 14],
27 | ['201810', 12],
28 | ['201811', 11],
29 | ],
30 | },
31 | {
32 | name: 'RDS',
33 | data: [
34 | ['201804', 48],
35 | ['201805', 45],
36 | ['201806', 43],
37 | ['201807', 44],
38 | ['201808', 41],
39 | ['201809', 45],
40 | ['201810', 42],
41 | ['201811', 45],
42 | ],
43 | },
44 | ];
45 |
46 | const config = {};
47 |
48 | export default () => (
49 |
50 | );
51 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Alibaba Cloud
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/docs/14-config-size.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: config-size
3 | zhName: 配置-大小
4 | sort: 14
5 | ---
6 |
7 | # config-size自定义
8 |
9 |
10 |
11 | # 配置方式
12 |
13 | ## 关闭size自定义
14 | Console-Chart 默认关闭 所有图表size自定义功能。
15 |
16 | ```javascript
17 | config.size = null;
18 | ```
19 |
20 |
21 | ## 开启size自定义
22 |
23 | ### 使用常量
24 | ```javascript
25 | config.size = 5;
26 | ```
27 |
28 | 注意: 不同图形的 size 的含义有所差别:
29 |
30 | - point 图形的 size 影响点的半径大小;
31 | - line, area, path 中的 size 影响线的粗细;
32 | - interval 的 size 影响柱状图的宽度
33 |
34 |
35 | ### 使用Field
36 |
37 | 根据 field 字段的值映射大小,使用默认的最大值 max:10 和最小值 min: 1。
我们使用 highcharts 的数据,所有的数据都会转换为`x*y*type*facet`的形式,所以请按照实际情况填入`field`字段。
38 |
39 | ```javascript
40 | config.size = 'y';
41 | ```
42 |
43 |
44 | ### 使用区间
45 | 根据 field 字段的值映射大小,使用默认的最大值 max:10 和最小值 min: 1。
46 |
47 | ```javascript
48 | config.size = [5, 10];
49 | ```
50 |
51 |
52 | ### 使用函数
53 | 如果传递的是一个普通的回调函数,我们默认的内部处理逻辑为:
54 | ```javascript
55 | config.size = type => {}
56 | ```
57 |
58 |
59 | ### 指定字段+函数
60 |
61 | `field` 指定要设置 size 的字段, 可以是`x*y*type*facet` 的任意组合。
62 |
63 | `sizeConfig` 可以是`number`、 `array`、`function`形式。
64 |
65 | ```javascript
66 | config.size = ['x*y', (x, y) => {}];
67 | ```
68 |
69 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/XAxisAsync.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, Fragment } from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'NAT',
7 | data: [
8 | [1522512000000, 302335],
9 | [1525104000000, 402335],
10 | [1527782400000, 202335],
11 | [1530374400000, 502335],
12 | [1533052800000, 102335],
13 | [1535731200000, 602335],
14 | [1538323200000, 202335],
15 | [1541001600000, 402335],
16 | ],
17 | },
18 | ];
19 |
20 | const configDefault = {
21 | xAxis: {
22 | type: 'time',
23 | mask: 'YYYY-MM-DD'
24 | },
25 | };
26 |
27 | const configInnner = {
28 | xAxis: {
29 | type: 'time',
30 | mask: 'YYYY-MM-DD HH:mm:ss'
31 | },
32 | }
33 |
34 | export default () => {
35 | const [flag, setFlag] = useState(false);
36 |
37 | const onClick = () => {
38 | setFlag(!flag);
39 | }
40 |
41 | return (
42 |
43 |
44 |
49 |
50 | );
51 | }
--------------------------------------------------------------------------------
/packages/console-sankey-chart/demo/NodeShape.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | // import { ConsoleSankeyChart } from '@alicloud/console-chart';
3 | import ConsoleSankeyChart from '../src';
4 |
5 | const config = {
6 | topology: true,
7 | direction: 'vertical',
8 | }
9 |
10 | export default () => (
11 |
18 | );
19 |
20 | const data = [
21 | {
22 | name: '节点数据',
23 | type: 'node',
24 | data: [
25 | {
26 | "name": "ecs"
27 | },
28 | {
29 | "name": "oss"
30 | },
31 | {
32 | "name": "oos"
33 | },
34 | {
35 | "name": "cdn"
36 | },
37 | ]
38 | },
39 | {
40 | name: '边数据',
41 | type: 'link',
42 | data: [
43 | {
44 | "source": 3,
45 | "target": 0,
46 | "value": 5
47 | },
48 | {
49 | "source": 2,
50 | "target": 0,
51 | "value": 5
52 | },
53 | {
54 | "source": 1,
55 | "target": 0,
56 | "value": 5
57 | },
58 | ]
59 | }
60 | ];
61 |
62 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | // "module": "ES2015",
4 | // "moduleResolution": "node",
5 | "target": "es5",
6 | "module": "esnext",
7 | "outDir": "lib",
8 | "lib": ["es6", "dom", "es2017.string"],
9 | // "sourceMap": true,
10 | /* Strict Type-Checking Option */
11 | "strict": false /* enable all strict type-checking options */,
12 | /* Additional Checks */
13 | "jsx": "react",
14 | "importHelpers": true,
15 | "moduleResolution": "node",
16 | "declaration": true,
17 | "declarationMap": true,
18 | "skipLibCheck": true,
19 | "noUnusedLocals": true /* Report errors on unused locals. */,
20 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
21 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
22 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
23 | "checkJs": false,
24 | "resolveJsonModule": true,
25 | "noStrictGenericChecks": true,
26 | "noImplicitUseStrict": true,
27 | "allowSyntheticDefaultImports": true
28 | },
29 | "exclude": ["node_modules"]
30 | }
31 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/Dot.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ECS',
7 | data: [
8 | ['201804', 31],
9 | ['201805', 39],
10 | ['201806', 32],
11 | ['201807', 35],
12 | ['201808', 31],
13 | ['201809', 36],
14 | ['201810', 32],
15 | ['201811', 34],
16 | ],
17 | },
18 | {
19 | name: 'OSS',
20 | data: [
21 | ['201804', 12],
22 | ['201805', 12],
23 | ['201806', 12],
24 | ['201807', 11],
25 | ['201808', 10],
26 | ['201809', 14],
27 | ['201810', 12],
28 | ['201811', 11],
29 | ],
30 | },
31 | {
32 | name: 'RDS',
33 | data: [
34 | ['201804', 48],
35 | ['201805', 45],
36 | ['201806', 43],
37 | ['201807', 44],
38 | ['201808', 41],
39 | ['201809', 45],
40 | ['201810', 42],
41 | ['201811', 45],
42 | ],
43 | },
44 | ];
45 |
46 | const config = {
47 | xAxis: {
48 | type: 'cat',
49 | },
50 | symbol: true,
51 | };
52 |
53 | export default () => (
54 |
55 | );
56 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | // "module": "ES2015",
4 | // "moduleResolution": "node",
5 | "target": "es5",
6 | "module": "esnext",
7 | "outDir": "lib",
8 | "lib": ["es6", "dom", "es2017.string"],
9 | // "sourceMap": true,
10 | /* Strict Type-Checking Option */
11 | "strict": false /* enable all strict type-checking options */,
12 | /* Additional Checks */
13 | "jsx": "react",
14 | "importHelpers": true,
15 | "moduleResolution": "node",
16 | // "declaration": true,
17 | // "declarationMap": true,
18 | "skipLibCheck": true,
19 | "noUnusedLocals": true /* Report errors on unused locals. */,
20 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
21 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
22 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
23 | "checkJs": false,
24 | "resolveJsonModule": true,
25 | "noStrictGenericChecks": true,
26 | "noImplicitUseStrict": true,
27 | "downlevelIteration": true,
28 | },
29 | "exclude": ["node_modules"]
30 | }
31 |
--------------------------------------------------------------------------------
/packages/console-line-chart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | // "module": "ES2015",
4 | // "moduleResolution": "node",
5 | "target": "es5",
6 | "module": "esnext",
7 | "outDir": "lib",
8 | "lib": ["es6", "dom", "es2017.string"],
9 | // "sourceMap": true,
10 | /* Strict Type-Checking Option */
11 | "strict": false /* enable all strict type-checking options */,
12 | /* Additional Checks */
13 | "jsx": "react",
14 | "importHelpers": true,
15 | "moduleResolution": "node",
16 | "declaration": true,
17 | "declarationMap": true,
18 | "skipLibCheck": true,
19 | "noUnusedLocals": true /* Report errors on unused locals. */,
20 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
21 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
22 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
23 | "checkJs": false,
24 | "resolveJsonModule": true,
25 | "noStrictGenericChecks": true,
26 | "noImplicitUseStrict": true,
27 | "allowSyntheticDefaultImports": true
28 | },
29 | "exclude": ["node_modules"]
30 | }
31 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import Multi from './Multi';
6 | import XLabel from './XLabel';
7 | import XAxisTickInterval from './XAxisTickInterval';
8 | import DoubleAxis from './DoubleAxis';
9 | import Unit from './Unit';
10 | import Smooth from './Smooth';
11 | import Dot from './Dot';
12 | import Stack from './Stack';
13 | import XAxisAsync from './XAxisAsync';
14 | import YAxisMin from './YAxisMin';
15 | import GradualColor from './GradualColor';
16 | import LegendClick from './LegendClick';
17 | import OneDotToLine from './OneDotToLine';
18 |
19 | storiesOf('ConsoleLineChart', module)
20 | .add('基本折线图', () => )
21 | .add('多组数据', () => )
22 | .add('自定义X轴label', () => )
23 | .add('自定义x轴时间刻度间距', () => )
24 | .add('X轴动态变化', XAxisAsync)
25 | .add('Y轴最小值与正整数', YAxisMin)
26 | .add('设置双轴', () => )
27 | .add('配置顶部单位', () => )
28 | .add('设置光滑曲线', () => )
29 | .add('线条带点', () => )
30 | .add('面积堆栈图', () => )
31 | .add('颜色渐变图', GradualColor)
32 | .add('图例点击控制', LegendClick)
33 | .add('只有一个点数据时展示线', OneDotToLine)
34 |
--------------------------------------------------------------------------------
/packages/console-chart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alicloud/console-chart",
3 | "version": "0.4.10-alpha.0",
4 | "main": "lib/index.js",
5 | "module": "es/index.js",
6 | "files": [
7 | "es",
8 | "lib"
9 | ],
10 | "scripts": {
11 | "clean-rpt": "rm -rf .rpt2_cache",
12 | "clean": "rm -rf lib es dist",
13 | "build": "npm run clean && rollup -c",
14 | "prepare": "npm run build",
15 | "watch": "rollup -c -w"
16 | },
17 | "publishConfig": {
18 | "access": "public"
19 | },
20 | "dependencies": {
21 | "@alicloud/console-bar-chart": "^0.4.10-alpha.0",
22 | "@alicloud/console-combo-chart": "^0.4.10-alpha.0",
23 | "@alicloud/console-dot-chart": "^0.4.10-alpha.0",
24 | "@alicloud/console-funnel-chart": "^0.4.10-alpha.0",
25 | "@alicloud/console-line-chart": "^0.4.10-alpha.0",
26 | "@alicloud/console-miniline-chart": "^0.4.10-alpha.0",
27 | "@alicloud/console-pie-chart": "^0.4.10-alpha.0",
28 | "@alicloud/console-radar-chart": "^0.4.10-alpha.0",
29 | "@alicloud/console-rose-chart": "^0.4.10-alpha.0",
30 | "@alicloud/console-sankey-chart": "^0.4.10-alpha.0",
31 | "@alicloud/console-shared-utils": "^0.4.10-alpha.0"
32 | },
33 | "gitHead": "76efc38b27cda1d046b06c2e1cf8ac83de63ced1"
34 | }
35 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/demo/Multi.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleDotChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ECS数据',
7 | data: [
8 | ['2018-04-01', 1892],
9 | ['2018-04-02', 7292],
10 | ['2018-04-03', 5714],
11 | ['2018-04-04', 5354],
12 | ['2018-04-05', 2014],
13 | ['2018-04-06', 22],
14 | ['2018-04-07', 1023],
15 | ['2018-04-08', 5218],
16 | ['2018-04-09', 8759],
17 | ['2018-04-10', 5981],
18 | ['2018-04-11', 4533],
19 | ['2018-04-12', 1398],
20 | ],
21 | },
22 | {
23 | name: 'OSS数据',
24 | data: [
25 | ['2018-04-01', 2892],
26 | ['2018-04-02', 6292],
27 | ['2018-04-03', 3714],
28 | ['2018-04-04', 4354],
29 | ['2018-04-05', 8014],
30 | ['2018-04-06', 2200],
31 | ['2018-04-07', 1023],
32 | ['2018-04-08', 2218],
33 | ['2018-04-09', 6759],
34 | ['2018-04-10', 3981],
35 | ['2018-04-11', 2533],
36 | ['2018-04-12', 1398],
37 | ],
38 | },
39 | ];
40 |
41 | const config = {
42 | padding: [40, 24, 24, 44],
43 | xAxis: {
44 | type: 'cat',
45 | tickCount: 10,
46 | },
47 | };
48 |
49 | export default () => (
50 |
51 | );
52 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/Unit.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ECS',
7 | data: [
8 | ['201804', 31],
9 | ['201805', 39],
10 | ['201806', 32],
11 | ['201807', 35],
12 | ['201808', 31],
13 | ['201809', 36],
14 | ['201810', 32],
15 | ['201811', 34],
16 | ],
17 | },
18 | {
19 | name: 'OSS',
20 | data: [
21 | ['201804', 12],
22 | ['201805', 12],
23 | ['201806', 12],
24 | ['201807', 11],
25 | ['201808', 10],
26 | ['201809', 14],
27 | ['201810', 12],
28 | ['201811', 11],
29 | ],
30 | },
31 | {
32 | name: 'RDS',
33 | data: [
34 | ['201804', 48],
35 | ['201805', 45],
36 | ['201806', 43],
37 | ['201807', 44],
38 | ['201808', 41],
39 | ['201809', 45],
40 | ['201810', 42],
41 | ['201811', 45],
42 | ],
43 | },
44 | ];
45 |
46 | const config = {
47 | padding: [50, 50, 50, 60],
48 | xAxis: {
49 | type: 'time',
50 | mask: 'YYYY-MM-DD',
51 | },
52 | guide: {
53 | topUnit: ['单位: 个', '单位: %'],
54 | },
55 | };
56 |
57 | export default () => (
58 |
59 | );
60 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleSankeyChart } from '@alicloud/console-chart';
3 |
4 | const config = {}
5 |
6 | export default () => (
7 |
8 | );
9 |
10 | const data = [
11 | {
12 | name: '节点数据',
13 | type: 'node',
14 | data: [
15 | {
16 | "name": "ecs"
17 | },
18 | {
19 | "name": "oss"
20 | },
21 | {
22 | "name": "oos"
23 | },
24 | {
25 | "name": "cdn"
26 | },
27 | {
28 | "name": "composer"
29 | },
30 | {
31 | "name": "rds"
32 | },
33 | ]
34 | },
35 | {
36 | name: '边数据',
37 | type: 'link',
38 | data: [
39 | {
40 | "source": 3,
41 | "target": 0,
42 | "value": 5
43 | },
44 | {
45 | "source": 2,
46 | "target": 0,
47 | "value": 5
48 | },
49 | {
50 | "source": 1,
51 | "target": 0,
52 | "value": 5
53 | },
54 | {
55 | "source": 0,
56 | "target": 4,
57 | "value": 5
58 | },
59 | {
60 | "source": 0,
61 | "target": 5,
62 | "value": 10
63 | },
64 | ]
65 | }
66 | ];
67 |
68 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/ComplexTooltip.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '等级',
7 | data: [
8 | ['11', 55.0],
9 | ['12', 26.8],
10 | ['13', 112.8],
11 | ['14', 81.5],
12 | ['15', 61.2],
13 | ['16', 7],
14 | ['17', 12],
15 | ],
16 | },
17 | ];
18 |
19 | const config = {};
20 |
21 | const onTooltipChange = evt => {
22 | console.log(evt);
23 | const items = evt.items; // tooltip显示的项
24 | const origin = items[0]; // 将一条数据改成多条数据
25 | const range = origin.point._origin;
26 | console.log(range);
27 | items.splice(0); // 清空
28 | items.push(
29 | Object.assign(
30 | {},
31 | origin,
32 | {
33 | name: 'key',
34 | marker: true,
35 | value: range.x,
36 | },
37 | ),
38 | );
39 | items.push(
40 | Object.assign(
41 | {},
42 | origin,
43 | {
44 | name: 'value',
45 | marker: true,
46 | value: range.y,
47 | },
48 | ),
49 | );
50 | }
51 |
52 | export default () => (
53 |
61 | );
62 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/demo/Tooltip.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleSankeyChart } from '@alicloud/console-chart';
3 |
4 | const config = {
5 | }
6 |
7 | export default () => (
8 |
9 | );
10 |
11 | const data = [
12 | {
13 | name: '节点数据',
14 | type: 'node',
15 | data: [
16 | {
17 | "name": "ecs"
18 | },
19 | {
20 | "name": "oss"
21 | },
22 | {
23 | "name": "oos"
24 | },
25 | {
26 | "name": "cdn"
27 | },
28 | {
29 | "name": "composer"
30 | },
31 | {
32 | "name": "rds"
33 | },
34 | ]
35 | },
36 | {
37 | name: '边数据',
38 | type: 'link',
39 | data: [
40 | {
41 | "source": 3,
42 | "target": 0,
43 | "value": 5
44 | },
45 | {
46 | "source": 2,
47 | "target": 0,
48 | "value": 5
49 | },
50 | {
51 | "source": 1,
52 | "target": 0,
53 | "value": 5
54 | },
55 | {
56 | "source": 0,
57 | "target": 4,
58 | "value": 5
59 | },
60 | {
61 | "source": 0,
62 | "target": 5,
63 | "value": 10
64 | },
65 | ]
66 | }
67 | ];
68 |
69 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-radar-chart
3 | zhName: 雷达图
4 | ---
5 |
6 | # 雷达图API
7 |
8 | # 引入方式
9 |
10 | ```javascript
11 | import { ConsoleRadarChart } from '@alicloud/console-chart';
12 | ```
13 |
14 | # 示例 Demo
15 |
16 | ## 基本使用
17 |
18 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
19 |
20 | ## 面积图
21 |
22 | [MDXInstruction:importDemo:Area](./demo/Area.tsx)
23 |
24 | ## 多组数据
25 |
26 | [MDXInstruction:importDemo:Multi](./demo/Multi.tsx)
27 |
28 | ## 自定义坐标轴
29 |
30 | [MDXInstruction:importDemo:Axis](./demo/Axis.tsx)
31 |
32 | # 配置 Config
33 |
34 | ## 通用配置
35 | | 属性 | 说明 |
36 | | --- | --- |
37 | | padding | 配置绘图内边距 |
38 | | xAxis | 配置x轴 |
39 | | yAxis | 配置y轴 |
40 | | legend | 配置图例 |
41 | | guide | 配置辅助元素 |
42 | | tooltip | 配置提示信息 |
43 | | label | 配置图形文本 |
44 | | size | 配置自定义大小 |
45 | | style | 配置自定义样式 |
46 |
47 | ## 专属配置
48 |
49 | ### symbol: Boolean
50 | 是否展示数据点
51 |
52 | ### smooth: Boolean
53 | 显示成光滑曲线
54 |
55 | ### area: Boolean
56 | 是否显示面积雷达图
57 |
58 | ### stack: Boolean
59 | 是否显示堆栈图, 仅在`area=true`时生效
60 |
61 | ### radius: Number
62 | 设置极坐标系的半径,可控制显示图形的大小
63 |
64 | ## 数据列配置
65 |
66 | | 属性 | 说明 | 类型 | 默认值 | 可选值 |
67 | | --- | --- | --- | --- | --- |
68 | | name | 数据列名称 | String | - | - |
69 | | data | 数据 | - | - | - |
70 | | color | 自定义当前数据列颜色 | String | 主题`color_24` | - |
71 |
--------------------------------------------------------------------------------
/docs/6-config.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: config
3 | zhName: 通用配置
4 | sort: 6
5 | ---
6 |
7 | # config 配置
8 |
9 | 在接下来的文档中,你会看到很多 `config` 的配置项,但默认情况下,Console-Chart 是不需要配置的,你甚至不需要传入任何的 `config` 配置就能够得到你期望的图表。
10 |
11 | 一方面为了满足更多用户的业务诉求,另外也为了能够将控制台特色的图表能力释放出去,Console-Chart从逻辑上将 `config` 配置分成两种类型: 通用配置、组件专属配置。
12 |
13 | ## 常见配置样例
14 |
15 | ```javascript
16 | // 无需任何配置
17 | const config = {};
18 |
19 | // 设置图表的内边距
20 | const config = {
21 | padding: [50, 50, 50, 50],
22 | };
23 |
24 | // 格式化X轴的刻度值
25 | const config = {
26 | xAxis: {
27 | label: {
28 | formatter: val => val
29 | }
30 | },
31 | yAxis: {},
32 | };
33 |
34 | // 设置图例的位置
35 | const config = {
36 | legend: {
37 | position: 'bottom',
38 | },
39 | };
40 | ```
41 |
42 | ## 通用配置列表
43 | 所有组件均可配置,且配置方式相同,列表如下:
44 |
45 | | 属性 | 说明 | 相关文档 |
46 | | --- | --- | --- |
47 | | xAxis | 配置 X 轴 | - |
48 | | yAxis | 配置 Y 轴 | - |
49 | | legend | 配置图例 | - |
50 | | guide | 配置引导内容 | - |
51 | | tooltip | 配置鼠标提示框 (tooltip) | - |
52 | | label | 配置标签 | - |
53 | | size | 配置图形 size | - |
54 | | style | 配置图形 style | - |
55 |
56 | ## 专属配置
57 |
58 | 每个图表组件由于功能的差异,独享控制其能力的配置项,可参考相关组件的 API 文档。
59 |
60 | ```javascript
61 | // 线图专属配置项
62 | config = {
63 | smooth: true, // 可实现将折线转化为光滑曲线
64 | }
65 |
66 | // 柱状图专属配置
67 | config = {
68 | dodgeStack: true, // 可实现分组堆叠柱状图
69 | }
70 | ```
71 |
72 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/demo/Topology.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleSankeyChart } from '@alicloud/console-chart';
3 |
4 | const config = {
5 | topology: true,
6 | }
7 |
8 | export default () => (
9 |
10 | );
11 |
12 | const data = [
13 | {
14 | name: '节点数据',
15 | type: 'node',
16 | data: [
17 | {
18 | "name": "ecs"
19 | },
20 | {
21 | "name": "oss"
22 | },
23 | {
24 | "name": "oos"
25 | },
26 | {
27 | "name": "cdn"
28 | },
29 | {
30 | "name": "composer"
31 | },
32 | {
33 | "name": "rds"
34 | },
35 | ]
36 | },
37 | {
38 | name: '边数据',
39 | type: 'link',
40 | data: [
41 | {
42 | "source": 3,
43 | "target": 0,
44 | "value": 5
45 | },
46 | {
47 | "source": 2,
48 | "target": 0,
49 | "value": 5
50 | },
51 | {
52 | "source": 1,
53 | "target": 0,
54 | "value": 5
55 | },
56 | {
57 | "source": 0,
58 | "target": 4,
59 | "value": 5
60 | },
61 | {
62 | "source": 0,
63 | "target": 5,
64 | "value": 10
65 | },
66 | ]
67 | }
68 | ];
69 |
70 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/types/index.ts:
--------------------------------------------------------------------------------
1 | export interface MetaDataItem {
2 | key: string;
3 | alias: string;
4 | axis: string;
5 | tickCount?: number;
6 | showMax?: boolean;
7 | }
8 |
9 | export interface IntervalChartConfig {
10 | type: any;
11 | transpose: boolean;
12 | }
13 |
14 | export interface LineChartConfig {
15 | shape: string;
16 | showPoint: boolean;
17 | }
18 |
19 | export interface AreaChartConfig {
20 | showLine: boolean; // 展示线条
21 | showPoint: boolean; // 展示点
22 | }
23 |
24 | export interface AreaStackChartConfig {
25 | showPoint: boolean;
26 | showLine: boolean;
27 | attachLast: boolean; // 图例跟随(一般在右侧显示)
28 | type: 'value' | 'percent'; // value || percent
29 | showCount: true; // 当type为value时,展示“总计”
30 | }
31 |
32 | export interface ConsoleChartProps {
33 | data: any[];
34 | metaData?: MetaDataItem[];
35 | chartConfig?: IntervalChartConfig | LineChartConfig | AreaChartConfig;
36 | }
37 |
38 | export interface IProps {
39 | width?: number;
40 | height?: number;
41 | config?: any;
42 | data?: any;
43 | event?: object;
44 | forceFit?: boolean;
45 | customChartProcess?: any;
46 | padding?: any;
47 | changeConfig?: any;
48 | onGetG2Instance?: Function;
49 | className?: any;
50 | style?: any;
51 | children?: any;
52 | animate?: boolean;
53 | forceUpdate?: boolean;
54 | }
55 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/demo/Vertical.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleSankeyChart } from '@alicloud/console-chart';
3 |
4 | const config = {
5 | direction: 'vertical',
6 | }
7 |
8 | export default () => (
9 |
10 | );
11 |
12 | const data = [
13 | {
14 | name: '节点数据',
15 | type: 'node',
16 | data: [
17 | {
18 | "name": "ecs"
19 | },
20 | {
21 | "name": "oss"
22 | },
23 | {
24 | "name": "oos"
25 | },
26 | {
27 | "name": "cdn"
28 | },
29 | {
30 | "name": "composer"
31 | },
32 | {
33 | "name": "rds"
34 | },
35 | ]
36 | },
37 | {
38 | name: '边数据',
39 | type: 'link',
40 | data: [
41 | {
42 | "source": 3,
43 | "target": 0,
44 | "value": 5
45 | },
46 | {
47 | "source": 2,
48 | "target": 0,
49 | "value": 5
50 | },
51 | {
52 | "source": 1,
53 | "target": 0,
54 | "value": 5
55 | },
56 | {
57 | "source": 0,
58 | "target": 4,
59 | "value": 5
60 | },
61 | {
62 | "source": 0,
63 | "target": 5,
64 | "value": 10
65 | },
66 | ]
67 | }
68 | ];
69 |
70 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/index.stories.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { storiesOf } from '@storybook/react';
3 |
4 | import Basic from './Basic';
5 | import Label from './Label';
6 | import Tooltip from './Tooltip';
7 | import Legend from './Legend';
8 | import LegendRight from './LegendRight';
9 | import LegendTip from './LegendTip';
10 | import Circle from './Circle';
11 | import CircleGuide from './CircleGuide';
12 | import Select from './Select';
13 | import SelectCircleGuide from './SelectCircleGuide';
14 | import ComplexTooltip from './ComplexTooltip';
15 | import SingleColors from './SingleColors';
16 | import MultiColors from './MultiColors';
17 | import CircleSlice from './CircleSlice';
18 |
19 | storiesOf('ConsolePieChart', module)
20 | .add('基本用法', () => )
21 | .add('带label指标', () => )
22 | .add('自定义tooltip', () => )
23 | .add('配置legend', () => )
24 | .add('legend在右边', () => )
25 | .add('legend tip', () => )
26 | .add('单色', () => )
27 | .add('指定颜色', () => )
28 | .add('基础环状图', () => )
29 | .add('环间距', () => )
30 | .add('环状带Guide', () => )
31 | .add('选中状态', () => )
32 | .add('根据选中状态更新环内Guide', () => )
33 | .add('复杂Tooltip', () => );
34 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/demo/LinkStyle.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleSankeyChart } from '@alicloud/console-chart';
3 |
4 | const config = {
5 | linkType: 'line',
6 | linkColor: '#8FD2EC',
7 | }
8 |
9 | export default () => (
10 |
11 | );
12 |
13 | const data = [
14 | {
15 | name: '节点数据',
16 | type: 'node',
17 | data: [
18 | {
19 | "name": "ecs"
20 | },
21 | {
22 | "name": "oss"
23 | },
24 | {
25 | "name": "oos"
26 | },
27 | {
28 | "name": "cdn"
29 | },
30 | {
31 | "name": "composer"
32 | },
33 | {
34 | "name": "rds"
35 | },
36 | ]
37 | },
38 | {
39 | name: '边数据',
40 | type: 'link',
41 | data: [
42 | {
43 | "source": 3,
44 | "target": 0,
45 | "value": 5
46 | },
47 | {
48 | "source": 2,
49 | "target": 0,
50 | "value": 5
51 | },
52 | {
53 | "source": 1,
54 | "target": 0,
55 | "value": 5
56 | },
57 | {
58 | "source": 0,
59 | "target": 4,
60 | "value": 5
61 | },
62 | {
63 | "source": 0,
64 | "target": 5,
65 | "value": 10
66 | },
67 | ]
68 | }
69 | ];
70 |
71 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/demo/YAxisColor.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleComboChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ECS',
7 | type: 'bar',
8 | yAxis: 0,
9 | data: [
10 | ['2018-04', 1892],
11 | ['2018-05', 7292],
12 | ['2018-06', 5714],
13 | ['2018-07', 5354],
14 | ['2018-08', 2014],
15 | ['2018-09', 22],
16 | ['2018-10', 11023],
17 | ['2018-11', 5218],
18 | ['2018-12', 8759],
19 | ],
20 | },
21 | {
22 | name: 'OSS',
23 | type: 'line',
24 | yAxis: 1,
25 | data: [
26 | ['2018-04', 11.751],
27 | ['2018-05', 40.78],
28 | ['2018-06', 21.75],
29 | ['2018-07', 12.048],
30 | ['2018-08', 17.48],
31 | ['2018-09', 10.494],
32 | ['2018-10', 95.97],
33 | ['2018-11', 47.88],
34 | ['2018-12', 20.85],
35 | ],
36 | },
37 | ];
38 |
39 | const config = {
40 | padding: [40, 52, 44, 44],
41 | xAxis: {
42 | type: 'cat',
43 | tickCount: 5,
44 | },
45 | yAxis: [
46 | {},
47 | {
48 | labelFormatter: val => val + '%',
49 | },
50 | ],
51 | legend: {
52 | position: 'top',
53 | },
54 | tooltip: {},
55 | yAxisColor: true, // y轴是否使用标记颜色
56 | };
57 |
58 | export default () => (
59 |
60 | );
61 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/demo/Facet.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleBarChart } from '@alicloud/console-chart';
3 |
4 | let data = [
5 | {
6 | name: 'RDS',
7 | facet: '2019',
8 | data: [],
9 | },
10 | {
11 | name: 'RDS',
12 | facet: '2018',
13 | data: [],
14 | },
15 | {
16 | name: 'OSS',
17 | facet: '2019',
18 | data: [],
19 | },
20 | {
21 | name: 'OSS',
22 | facet: '2018',
23 | data: [],
24 | },
25 | {
26 | name: 'ECS',
27 | facet: '2019',
28 | data: [],
29 | },
30 | {
31 | name: 'ECS',
32 | facet: '2018',
33 | data: [],
34 | },
35 | ];
36 |
37 | for (let i = 0; i < 10; i++) {
38 | const name = i + '月';
39 | data[0].data.push([name, Math.random() * 100 + 500]);
40 | data[1].data.push([name, Math.random() * 100 + 100]);
41 | data[2].data.push([name, Math.random() * 100 + 500]);
42 | data[3].data.push([name, Math.random() * 100 + 100]);
43 | data[4].data.push([name, Math.random() * 100 + 500]);
44 | data[5].data.push([name, Math.random() * 100 + 100]);
45 | }
46 |
47 | export default () => {
48 | const config = {
49 | padding: [40, 24, 20, 44],
50 | colors: ['#001122', '#004455', '#008899', '#00eeff'],
51 | marginRatio: 0.05,
52 | facet: true,
53 | };
54 | return (
55 |
56 | );
57 | }
58 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/demo/SingleYAxis.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleComboChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ECS',
7 | type: 'bar',
8 | yAxis: 0,
9 | data: [
10 | ['2018-04', 1892],
11 | ['2018-05', 7292],
12 | ['2018-06', 5714],
13 | ['2018-07', 5354],
14 | ['2018-08', 2014],
15 | ['2018-09', 22],
16 | ['2018-10', 11023],
17 | ['2018-11', 5218],
18 | ['2018-12', 8759],
19 | ],
20 | },
21 | {
22 | name: 'OSS',
23 | type: 'line',
24 | yAxis: 1,
25 | data: [
26 | ['2018-04', 11.751],
27 | ['2018-05', 40.78],
28 | ['2018-06', 21.75],
29 | ['2018-07', 12.048],
30 | ['2018-08', 17.48],
31 | ['2018-09', 10.494],
32 | ['2018-10', 95.97],
33 | ['2018-11', 47.88],
34 | ['2018-12', 20.85],
35 | ],
36 | },
37 | ];
38 |
39 |
40 | const config = {
41 | padding: [40, 52, 44, 44],
42 | xAxis: {
43 | type: 'cat',
44 | tickCount: 5,
45 | },
46 | yAxis: [
47 | {},
48 | {
49 | labelFormatter: val => val + '%',
50 | },
51 | ],
52 | legend: {
53 | position: 'top',
54 | },
55 | tooltip: {},
56 | yAxisColor: true, // y轴是否使用标记颜色
57 | };
58 |
59 | export default () => (
60 |
61 | );
62 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/demo/TopologyVertical.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleSankeyChart } from '@alicloud/console-chart';
3 |
4 | const config = {
5 | topology: true,
6 | direction: 'vertical',
7 | }
8 |
9 | export default () => (
10 |
11 | );
12 |
13 | const data = [
14 | {
15 | name: '节点数据',
16 | type: 'node',
17 | data: [
18 | {
19 | "name": "ecs"
20 | },
21 | {
22 | "name": "oss"
23 | },
24 | {
25 | "name": "oos"
26 | },
27 | {
28 | "name": "cdn"
29 | },
30 | {
31 | "name": "composer"
32 | },
33 | {
34 | "name": "rds"
35 | },
36 | ]
37 | },
38 | {
39 | name: '边数据',
40 | type: 'link',
41 | data: [
42 | {
43 | "source": 3,
44 | "target": 0,
45 | "value": 5
46 | },
47 | {
48 | "source": 2,
49 | "target": 0,
50 | "value": 5
51 | },
52 | {
53 | "source": 1,
54 | "target": 0,
55 | "value": 5
56 | },
57 | {
58 | "source": 0,
59 | "target": 4,
60 | "value": 5
61 | },
62 | {
63 | "source": 0,
64 | "target": 5,
65 | "value": 10
66 | },
67 | ]
68 | }
69 | ];
70 |
71 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-miniline-chart
3 | zhName: 迷你曲线图
4 | ---
5 |
6 | # 迷你曲线图API
7 |
8 | # 引入方式
9 |
10 | ```javascript
11 | import { ConsoleMinilineChart } from '@alicloud/console-chart';
12 | ```
13 |
14 | # 示例 Demo
15 |
16 | ## 基本使用
17 |
18 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
19 |
20 | ## 面积图
21 |
22 | [MDXInstruction:importDemo:Area](./demo/Area.tsx)
23 |
24 | ## 光滑面积图
25 |
26 | [MDXInstruction:importDemo:AreaSmooth](./demo/AreaSmooth.tsx)
27 |
28 | ## 面积堆栈图
29 |
30 | [MDXInstruction:importDemo:AreaStack](./demo/AreaStack.tsx)
31 |
32 | ## 自定义颜色
33 |
34 | [MDXInstruction:importDemo:Color](./demo/Color.tsx)
35 |
36 | # 配置 Config
37 |
38 | # 数据列配置
39 |
40 | | 属性 | 说明 | 类型 | 默认值 | 可选值 |
41 | | --- | --- | --- | --- | --- |
42 | | name | 数据列名称 | String | - | - |
43 | | data | 数据 | - | - | - |
44 | | color | 自定义当前数据列颜色 | String | 主题`color_24` | - |
45 |
46 | ## 通用配置
47 |
48 | | 属性 | 说明 |
49 | | --- | --- |
50 | | padding | 配置绘图内边距 |
51 | | ~~xAxis~~ | ~~配置x轴~~ |
52 | | ~~yAxis~~ | ~~配置y轴~~ |
53 | | ~~legend~~ | ~~配置图例~~ |
54 | | guide | 配置辅助元素 |
55 | | tooltip | 配置提示信息 |
56 | | label | 配置图形文本 |
57 | | size | 配置自定义大小 |
58 | | style | 配置自定义样式 |
59 |
60 | ## 专属配置
61 |
62 | ### smooth: Boolean
63 | 是否显示成光滑曲线
64 |
65 | ### area: Boolean
66 | 是否展示成面积图
67 |
68 | ### stack: Boolean
69 | 在`area=true`时生效,是否展示成面积堆栈。
70 |
71 | ### symbol: Boolean
72 | 是否展示数据点
73 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/demo/Click.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { ConsoleComboChart } from '@alicloud/console-chart';
3 |
4 | const { useState } = React;
5 |
6 | const data = [
7 | {
8 | name: 'ECS使用量',
9 | type: 'bar',
10 | yAxis: 0,
11 | color: '#0093EE',
12 | data: [['2015', 5], ['2016', 10], ['2017', 15], ['2018', 30], ['2019', 36]],
13 | },
14 | {
15 | name: 'ECS同比增长',
16 | type: 'line',
17 | yAxis: 1,
18 | color: '#EE6DD2',
19 | data: [['2015', 0.3], ['2016', 0.1], ['2017', 0.5], ['2018', 1], ['2019', 0.2]],
20 | },
21 | ];
22 |
23 | const config = {
24 | yAxis: [
25 | {
26 | formatter: val => val + '万',
27 | },
28 | {
29 | formatter: val => val * 100 + '%',
30 | },
31 | ],
32 | };
33 |
34 | export default () => {
35 |
36 | const [hasClick, setClick] = useState(false);
37 |
38 | // 不要像下面这样修改属性,否则不会触发更新,需要生成一个新的对象引用
39 | // data[0].color = hasClick ? '#EE6DD2' : '#0093EE';
40 | const list = data.map(x => Object.assign({}, x, {
41 | color: hasClick ? '#EE6DD2' : '#0093EE',
42 | }))
43 |
44 | const onClick = evt => {
45 | console.log(evt);
46 | setClick(preState => !preState);
47 | }
48 |
49 | return (
50 |
58 | );
59 | }
60 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/DoubleAxis.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'WAF使用',
7 | yAxis: 0,
8 | data: [
9 | ['2018-04', 200001],
10 | ['2018-05', 600001],
11 | ['2018-06', 100001],
12 | ['2018-07', 500001],
13 | ['2018-08', 100001],
14 | ['2018-09', 900001],
15 | ['2018-10', 300001],
16 | ['2018-11', 900001],
17 | ['2018-12', 1000000],
18 | ['2019-01', 1100000],
19 | ['2019-02', 1200000],
20 | ],
21 | },
22 | {
23 | name: '增长率',
24 | yAxis: 1,
25 | data: [
26 | ['2018-04', 11.751],
27 | ['2018-05', 40.78],
28 | ['2018-06', 21.75],
29 | ['2018-07', 12.048],
30 | ['2018-08', 17.48],
31 | ['2018-09', 10.494],
32 | ['2018-10', 95.97],
33 | ['2018-11', 47.88],
34 | ['2018-12', 20.85],
35 | ['2019-01', 49.2],
36 | ['2019-02', 29.65],
37 | ],
38 | },
39 | ];
40 |
41 | const config = {
42 | xAxis: {
43 | type: 'time',
44 | mask: 'YYYYMM',
45 | },
46 | yAxis: [
47 | {
48 | labelFormatter: val => (val > 10000 ? parseInt(String(val / 10000)) + 'W' : val),
49 | },
50 | {
51 | labelFormatter: val => val + '%',
52 | },
53 | ],
54 | };
55 |
56 | export default () => (
57 |
58 | );
59 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/axisX.ts:
--------------------------------------------------------------------------------
1 | // 通用坐标轴配置
2 | export default function(chart: any, config: any, componentConfig?: any) {
3 | if (config.xAxis === false || (config.xAxis && config.xAxis.visible === false)) {
4 | chart.axis('x', false);
5 | } else {
6 | const { grid, title = false, autoRotate = false, rotate = false, ...other } =
7 | config.xAxis || {};
8 |
9 | const xAxisConfig = other;
10 |
11 | if (rotate) {
12 | if (!xAxisConfig.label) xAxisConfig.label = {};
13 | xAxisConfig.label.textStyle = {
14 | textAlign: 'start',
15 | rotate,
16 | };
17 | }
18 |
19 | // 网格线
20 | if (grid) {
21 | if (grid === true) {
22 | xAxisConfig.grid = {
23 | lineStyle: {
24 | lineWidth: 1,
25 | },
26 | };
27 | } else {
28 | xAxisConfig.grid = Object.assign({}, grid);
29 | }
30 | }
31 |
32 | // 开启坐标轴标题
33 | if (title) {
34 | if (title === true) {
35 | xAxisConfig.title = {
36 | position: 'center',
37 | offset: 38,
38 | textStyle: {
39 | rotate: 0,
40 | },
41 | };
42 | } else {
43 | xAxisConfig.title = Object.assign({}, title);
44 | }
45 | }
46 |
47 | if (componentConfig) {
48 | Object.assign(xAxisConfig, componentConfig);
49 | }
50 |
51 | chart.axis('x', xAxisConfig);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/theme/index.ts:
--------------------------------------------------------------------------------
1 | import isPlainObject from 'lodash/isPlainObject';
2 | import normalTheme from './normal';
3 | import yunzhiTheme from './yunzhi';
4 | import darkTheme from './dark';
5 | import macaronsTheme from './macarons';
6 | import { G2 } from '../common/utils';
7 |
8 | const builtinG2Themes = {
9 | normal: normalTheme,
10 | yunzhi: yunzhiTheme,
11 | dark1: darkTheme,
12 | macarons: macaronsTheme,
13 | };
14 |
15 | export function setConsoleTheme(key?: string | object) {
16 | let theme = null;
17 | if (key) {
18 | if (typeof key === 'string') {
19 | theme = getConsoleTheme(key);
20 | } else {
21 | theme = key;
22 | }
23 | } else {
24 | theme = 'default';
25 | }
26 | if (!theme) {
27 | console.warn('主题设置错误');
28 | return;
29 | }
30 |
31 | // @ts-ignore
32 | G2.Global.setTheme(theme);
33 | }
34 |
35 | export function registerConsoleTheme(themeKey: string, obj: object) {
36 | if (!isPlainObject(obj)) {
37 | console.warn('主题包必须设置为普通javascript对象');
38 | return;
39 | }
40 | builtinG2Themes[themeKey] = obj;
41 | // @ts-ignore
42 | G2.Global.registerTheme(themeKey, obj);
43 | }
44 |
45 | export function getConsoleTheme(key?: string) {
46 | key = key || 'default';
47 | if (builtinG2Themes[key]) {
48 | return builtinG2Themes[key];
49 | } else if (['default', 'dark'].includes(key)) {
50 | return key;
51 | }
52 | return null;
53 | }
54 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/Stack.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '云产品A',
7 | data: [
8 | ['2018-04-01', 302335],
9 | ['2018-05-01', 402335],
10 | ['2018-06-01', 202335],
11 | ['2018-07-01', 502335],
12 | ['2018-08-01', 102335],
13 | ['2018-09-01', 602335],
14 | ['2018-10-01', 202335],
15 | ['2018-11-01', 402335],
16 | ],
17 | },
18 | {
19 | name: '云产品B',
20 | data: [
21 | ['2018-04-01', 33412],
22 | ['2018-05-01', 43412],
23 | ['2018-06-01', 23412],
24 | ['2018-07-01', 53412],
25 | ['2018-08-01', 13412],
26 | ['2018-09-01', 63412],
27 | ['2018-10-01', 23412],
28 | ['2018-11-01', 43412],
29 | ],
30 | },
31 | {
32 | name: '云产品C',
33 | data: [
34 | ['2018-04-01', 200001],
35 | ['2018-05-01', 600001],
36 | ['2018-06-01', 100001],
37 | ['2018-07-01', 500001],
38 | ['2018-08-01', 100001],
39 | ['2018-09-01', 900001],
40 | ['2018-10-01', 300001],
41 | ['2018-11-01', 900001],
42 | ],
43 | },
44 | ];
45 |
46 | const config = {
47 | xAxis: {
48 | type: 'time',
49 | mask: 'YYYY-MM-DD',
50 | },
51 | symbol: true,
52 | area: true,
53 | stack: true,
54 | };
55 |
56 | export default () => (
57 |
58 | );
59 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/Smooth.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '云产品A',
7 | data: [
8 | ['2018-04-01', 302335],
9 | ['2018-05-01', 402335],
10 | ['2018-06-01', 202335],
11 | ['2018-07-01', 502335],
12 | ['2018-08-01', 102335],
13 | ['2018-09-01', 602335],
14 | ['2018-10-01', 202335],
15 | ['2018-11-01', 402335],
16 | ],
17 | },
18 | {
19 | name: '云产品B',
20 | data: [
21 | ['2018-04-01', 33412],
22 | ['2018-05-01', 43412],
23 | ['2018-06-01', 23412],
24 | ['2018-07-01', 53412],
25 | ['2018-08-01', 13412],
26 | ['2018-09-01', 63412],
27 | ['2018-10-01', 23412],
28 | ['2018-11-01', 43412],
29 | ],
30 | },
31 | {
32 | name: '云产品C',
33 | data: [
34 | ['2018-04-01', 200001],
35 | ['2018-05-01', 600001],
36 | ['2018-06-01', 100001],
37 | ['2018-07-01', 500001],
38 | ['2018-08-01', 100001],
39 | ['2018-09-01', 900001],
40 | ['2018-10-01', 300001],
41 | ['2018-11-01', 900001],
42 | ],
43 | },
44 | ];
45 |
46 | const config = {
47 | xAxis: {
48 | type: 'time',
49 | mask: 'YYYY-MM-DD',
50 | },
51 | yAxis: {
52 | min: 0,
53 | },
54 | smooth: true,
55 | };
56 |
57 | export default () => (
58 |
59 | );
60 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/axisY.ts:
--------------------------------------------------------------------------------
1 | import { get } from '../common/utils';
2 |
3 | /*
4 | * 常见直角坐标系的单个Y轴设置。
5 | * */
6 | export default function(chart: any, config: any, yField?: string, componentConfig?: any) {
7 | yField = yField || 'y';
8 | if (config.yAxis === false || get(config, 'yAxis.visible') === false) {
9 | chart.axis(yField, false);
10 | return;
11 | } else {
12 | const { title = false, formatter = false, line, ...other } = config.yAxis || {};
13 |
14 | const yAxisConfig = other;
15 |
16 | // 关闭了X轴,需要显示第一条grid
17 | if (config.xAxis === false || get(config, 'xAxis.visible') === false) {
18 | yAxisConfig.grid = {
19 | hideFirstLine: false,
20 | };
21 | }
22 |
23 | // 开启坐标轴标题
24 | if (title) {
25 | if (title === true) {
26 | yAxisConfig.title = {
27 | position: 'center',
28 | // offset: 30,
29 | textStyle: {
30 | rotate: -90,
31 | },
32 | };
33 | } else {
34 | yAxisConfig.title = Object.assign({}, title);
35 | }
36 | // 如果存在右侧坐标轴,调整旋转方向
37 | if (yField === 'y1') {
38 | yAxisConfig.title.textStyle.rotate = 90;
39 | }
40 | yAxisConfig.label.textStyle = {
41 | rotate: 0,
42 | };
43 | }
44 |
45 | if (componentConfig) {
46 | Object.assign(yAxisConfig, componentConfig);
47 | }
48 |
49 | chart.axis(yField, yAxisConfig);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/demo/Size.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleDotChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '云产品A',
7 | data: [
8 | [1483372800000, 1892],
9 | [1483459200000, 7292],
10 | [1483545600000, 5714],
11 | [1483632000000, 5354],
12 | [1483718400000, 2014],
13 | [1483804800000, 22],
14 | [1483891200000, 11023],
15 | [1483977600000, 5218],
16 | [1484064000000, 8759],
17 | [1484150400000, 9981],
18 | [1484236800000, 4533],
19 | [1484323200000, 11398],
20 | [1484409600000, 1064],
21 | [1484496000000, 6494],
22 | ],
23 | },
24 | {
25 | name: '云产品B',
26 | data: [
27 | [1483372800000, 3242],
28 | [1483459200000, 2292],
29 | [1483545600000, 4714],
30 | [1483632000000, 2354],
31 | [1483718400000, 5014],
32 | [1483804800000, 2322],
33 | [1483891200000, 12023],
34 | [1483977600000, 4218],
35 | [1484064000000, 2759],
36 | [1484150400000, 6981],
37 | [1484236800000, 12533],
38 | [1484323200000, 8398],
39 | [1484409600000, 2064],
40 | [1484496000000, 4494],
41 | ],
42 | },
43 | ];
44 |
45 | const config = {
46 | padding: [40, 15, 24, 44],
47 | xAxis: {
48 | type: 'time',
49 | mask: 'YYYY-MM-DD',
50 | },
51 | size: [5, 20],
52 | geomStyle: {
53 | fillOpacity: 0.6,
54 | },
55 | };
56 |
57 |
58 | export default () => (
59 |
60 | );
61 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-funnel-chart
3 | zhName: 漏斗图
4 | ---
5 |
6 | # 漏斗图API
7 |
8 | # 引用方式
9 | ```javascript
10 | import { ConsoleFunnelChart } from '@alicloud/console-chart';
11 | ```
12 |
13 | # 示例 Demo
14 |
15 | ## 基本使用
16 |
17 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
18 |
19 | ## 居左
20 |
21 | [MDXInstruction:importDemo:Left](./demo/Left.tsx)
22 |
23 | ## 横向居中
24 |
25 | [MDXInstruction:importDemo:Horizontal](./demo/Horizontal.tsx)
26 |
27 | ## 金字塔
28 |
29 | `金字塔图`和漏斗图的主要区别在于图形顶部是否有“尖角”
30 |
31 | [MDXInstruction:importDemo:Pyramid](./demo/Pyramid.tsx)
32 |
33 | ## 横向金字塔
34 |
35 | [MDXInstruction:importDemo:PyramidHor](./demo/PyramidHor.tsx)
36 |
37 | # 配置 Config
38 |
39 | ## 数据列配置
40 |
41 | | 属性 | 说明 | 类型 | 默认值 | 可选值 |
42 | | --- | --- | --- | --- | --- |
43 | | name | 数据列名称 | String | - | - |
44 | | data | 数据 | - | - | - |
45 | | color | 自定义当前数据列颜色 | String | 主题`color_24` | - |
46 |
47 | ## 通用配置
48 |
49 | | 属性 | 说明 |
50 | | --- | --- |
51 | | padding | 配置绘图内边距 |
52 | | ~~xAxis~~ | ~~配置x轴~~ |
53 | | ~~yAxis~~ | ~~配置y轴~~ |
54 | | ~~legend~~ | ~~配置图例~~ |
55 | | guide | 配置辅助元素 |
56 | | tooltip | 配置提示信息 |
57 | | label | 配置图形文本 |
58 | | size | 配置自定义大小 |
59 | | style | 配置自定义样式 |
60 |
61 | ## 专属配置
62 |
63 | ### direction: String
64 | 控制漏斗的方向, 可选值: `vertical` 、 `horizontal`
65 |
66 | ### align: String
67 | 漏斗图的对齐方式。
当 `direction = vertical` 时,可选对齐方式为: `left` 、 `center` 、 `right`
当 `direction = horizontal` 时,可选对齐方式为: `top` 、 `center` 、 `bottom`
68 |
69 | ### pyramid: Boolean
70 | 是否显示金字塔尖角。
71 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/demo/Disturbance.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleDotChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '云产品A',
7 | data: [
8 | ['11', 35],
9 | ['11', 10],
10 | ['12', 32],
11 | ['11', 7],
12 | ['13', 32],
13 | ['12', 23],
14 | ['11', 80],
15 | ['13', 33],
16 | ['11', 11],
17 | ['11', 32],
18 | ['12', 24],
19 | ['12', 72],
20 | ['13', 14],
21 | ['11', 42],
22 | ],
23 | },
24 | {
25 | name: '云产品B',
26 | data: [
27 | ['11', 54],
28 | ['11', 10],
29 | ['12', 24],
30 | ['12', 72],
31 | ['13', 14],
32 | ['11', 42],
33 | ['12', 32],
34 | ['11', 7],
35 | ['13', 32],
36 | ['12', 23],
37 | ['11', 24],
38 | ['13', 33],
39 | ['11', 11],
40 | ['11', 32],
41 | ],
42 | },
43 | {
44 | name: '云产品C',
45 | data: [
46 | ['11', 31],
47 | ['11', 10],
48 | ['11', 11],
49 | ['11', 32],
50 | ['12', 24],
51 | ['12', 32],
52 | ['11', 7],
53 | ['13', 32],
54 | ['12', 23],
55 | ['11', 43],
56 | ['13', 33],
57 | ['12', 72],
58 | ['13', 14],
59 | ['11', 42],
60 | ],
61 | },
62 | ];
63 |
64 | const config = {
65 | padding: [40, 5, 24, 40],
66 | jitter: true,
67 | yAxis: {
68 | min: 0,
69 | max: 100,
70 | },
71 | };
72 |
73 | export default () => (
74 |
75 | );
76 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/demo/Stack.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleComboChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '使用',
7 | type: 'bar',
8 | yAxis: 0,
9 | data: [
10 | ['ecs', 1892],
11 | ['disk', 7292],
12 | ['ess', 5714],
13 | ['acs', 5354],
14 | ['batchcompute', 2014],
15 | ['ros', 22],
16 | ['fc', 11023],
17 | ['swas', 5218],
18 | ['ehpc', 8759],
19 | ['ecsgpu', 9981],
20 | ['acr', 4533],
21 | ['xdragon', 11398],
22 | ['scc', 1064],
23 | ['ddh', 6494],
24 | ],
25 | },
26 | {
27 | name: '使用增长率',
28 | type: 'line',
29 | yAxis: 1,
30 | data: [
31 | ['ecs', 18.92],
32 | ['disk', 72.92],
33 | ['ess', 57.14],
34 | ['acs', 53.54],
35 | ['batchcompute', 20.14],
36 | ['ros', 22],
37 | ['fc', 110.23],
38 | ['swas', 52.18],
39 | ['ehpc', 87.59],
40 | ['ecsgpu', 99.81],
41 | ['acr', 45.33],
42 | ['xdragon', 113.98],
43 | ['scc', 10.64],
44 | ['ddh', 64.94],
45 | ],
46 | },
47 | ];
48 |
49 | const config = {
50 | padding: [40, 52, 'auto', 60],
51 | xAxis: {
52 | type: 'cat',
53 | // mask: 'YYYY-MM-DD'
54 | tickCount: 5,
55 | },
56 | yAxis: [
57 | {},
58 | {
59 | labelFormatter: val => val + '%',
60 | },
61 | ],
62 | legend: {
63 | position: 'bottom',
64 | },
65 | stack: true,
66 | };
67 | export default () => (
68 |
69 | );
70 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/legend.ts:
--------------------------------------------------------------------------------
1 | import { get, isFunction } from '../common/utils';
2 |
3 | export default function(chart, config, legendConfig, yField?: any) {
4 | let finalYField = yField || true;
5 | let finalLegendConfig = legendConfig;
6 | if (Array.isArray(legendConfig)) {
7 | finalYField = legendConfig[0];
8 | finalLegendConfig = legendConfig[1];
9 | }
10 |
11 | if (finalLegendConfig === false || get(finalLegendConfig, 'visible') === false) {
12 | if (Array.isArray(legendConfig)) {
13 | chart.legend(finalYField, false);
14 | } else {
15 | chart.legend(false);
16 | }
17 | return;
18 | }
19 | if (get(finalLegendConfig, 'tip')) {
20 | const dom = get(chart, '_attrs.canvas._cfg.canvasDOM');
21 | dom.title = null;
22 | const onHover = event => {
23 | const value: string = get(event, 'item.value');
24 | let text: string = value;
25 | if (get(config, 'legend.tipFormatter') && isFunction(config.legend.tipFormatter)) {
26 | text = config.legend.tipFormatter(get(event, 'item.value'));
27 | } else if (get(config, 'legend.itemFormatter') && isFunction(config.legend.itemFormatter)) {
28 | text = config.legend.itemFormatter(get(event, 'item.value'));
29 | }
30 | dom.title = text;
31 | };
32 | if (Array.isArray(legendConfig)) {
33 | chart.legend(finalYField, { onHover });
34 | } else {
35 | chart.legend({ onHover });
36 | }
37 | }
38 |
39 | finalLegendConfig = Object.assign({}, { position: 'bottom-center' }, finalLegendConfig);
40 |
41 | chart.legend(yField, finalLegendConfig);
42 | }
43 |
--------------------------------------------------------------------------------
/packages/console-bar-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-bar-chart
3 | zhName: 柱状图
4 | ---
5 |
6 | # 柱状图API
7 |
8 | 目前柱状图只支持单轴,不支持双轴,在配置 `yAxis`时需要注意。
9 |
10 | # 引入方式
11 |
12 | ```javascript
13 | import { ConsoleBarChart } from '@alicloud/console-chart';
14 | ```
15 |
16 | # 示例 Demo
17 |
18 | ## 基本使用
19 |
20 | [MDXInstruction:importDemo:basic](./demo/Basic.tsx)
21 |
22 | ## 水平柱状图
23 |
24 | [MDXInstruction:importDemo:horizontal](./demo/Horizontal.tsx)
25 |
26 | ## 堆叠柱状图
27 |
28 | [MDXInstruction:importDemo:stack](./demo/Stack.tsx)
29 |
30 | ## 镜面柱状图
31 |
32 | [MDXInstruction:importDemo:facet](./demo/Facet.tsx)
33 |
34 | ## 分组柱状图
35 |
36 | [MDXInstruction:importDemo:dodgeStack](./demo/DodgeStack.tsx)
37 |
38 | ## 自定义数据列颜色
39 |
40 | [MDXInstruction:importDemo:color](./demo/Color.tsx)
41 |
42 |
43 | # 数据列配置
44 | | 属性 | 说明 | 类型 | 默认值 | 说明 |
45 | | --- | --- | --- | --- | --- |
46 | | name | 数据列名称 | String | - | - |
47 | | yAxis | 坐标轴下标 | Number | 0 | - |
48 | | data | 数据 | Array | - | - |
49 | | color | 自定义当前数据列颜色 | String | 主题`color_24` | - |
50 | | dodge | 分组名 | String | - | 如使用需开启`dodgeStack`配置 |
51 |
52 | # 配置 Config
53 |
54 | ## 通用配置
55 | | 属性 | 说明 |
56 | | --- | --- |
57 | | padding | 配置绘图内边距 |
58 | | xAxis | 配置x轴 |
59 | | yAxis | 配置y轴 |
60 | | legend | 配置图例 |
61 | | guide | 配置辅助元素 |
62 | | tooltip | 配置提示信息 |
63 | | label | 配置图形文本 |
64 | | size | 配置自定义大小 |
65 | | style | 配置自定义样式 |
66 |
67 | ## 专属配置
68 |
69 | ### grid: Boolean
70 | 是否显示网格线,`默认开启`。
71 |
72 | ### marginRatio: Number
73 | 数值范围为 0 至 1,用于调整分组中各个柱子的间距。
74 |
75 | ### dodgeStack: Boolean
76 | 是否为分组柱状图。如开启该配置,需在数据列中配置`dodge`
77 |
78 | ### horizontal: Boolean
79 | 是否水平展示柱状图。
80 |
81 | ### stack: Boolean
82 | 是否为堆叠柱状图
83 |
84 | ### facet: Boolean
85 | 是否使用镜面柱状图
86 |
--------------------------------------------------------------------------------
/packages/config-common-demo/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: config
3 | zhName: 通用配置场景
4 | ---
5 |
6 | # 通用配置场景
7 |
8 | ## Props
9 |
10 | ### width/height
11 | 通过`width/height`这两个属性可以配置图表组件的宽度和高度,不配置时则默认为父组件的宽度/高度。
12 | 注意,这两个属性是直接通过`props`向组件传递的,不需要放在`config`中。
13 |
14 | [MDXInstruction:importDemo:WidthHeight](./demo/WidthHeight.tsx)
15 |
16 | ---
17 |
18 | 以下所有配置都是`config`中的参数。
19 |
20 | ## Padding
21 | 可以通过配置`config.padding`来控制图表的内边距。padding的值类似与css里的padding,详细的请看这里[属性-padding](/guides/props#padding)
22 |
23 | ### 设置Padding大小
24 |
25 | [MDXInstruction:importDemo:PaddingBasic](./demo/PaddingBasic.tsx)
26 |
27 | ## Legend
28 | 可以通过配置`config.legend`来控制图表里的图例,详细的请看这里[配置-图例](/guides/config-legend)
29 |
30 | ### Legend位置
31 |
32 | [MDXInstruction:importDemo:LegendPosition](../console-pie-chart/demo/Legend.tsx)
33 |
34 | ### Legend在右边
35 | 通过设置Chart的`右Padding`和Legend的`offsetY`属性来控制legend的位置。
36 |
37 | Note: `右Padding`是指圆形的右边界到渲染区域的右边界。`offsetY`是指圆形的右边界到legend的左边界。
38 |
39 | [MDXInstruction:importDemo:LegendRight](../console-pie-chart/demo/LegendRight.tsx)
40 |
41 | ### Legend tip
42 |
43 | 配置`legend`的`tip`属性可开启legend悬浮提示。开启tip配置之后,可进一步配置`tipFormatter`属性来进行格式化tip显示内容(取值优先级:`tipFormatter` => `itemFormatter` => `value`)
44 |
45 | Note: `legend`的`tip`属性是通过`dom`的`title`属性来进行简单实现的,只能满足简单场景。
46 |
47 | [MDXInstruction:importDemo:LegendTip](../console-pie-chart/demo/LegendTip.tsx)
48 |
49 | ## Tooltip
50 | 可以通过配置`config.tooltip`来控制图表里的图例,详细的请看这里[配置-提示信息](/guides/config-tooltip)
51 |
52 | ## 自定义tooltip
53 |
54 | [MDXInstruction:importDemo:Tooltip](../console-pie-chart/demo/Tooltip.tsx)
55 |
56 | ## 复杂Tooltip
57 |
58 | [MDXInstruction:importDemo:ComplexTooltip](../console-pie-chart/demo/ComplexTooltip.tsx)
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/XLabel.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'NAT',
7 | data: [
8 | [1522512000000, 302335],
9 | [1525104000000, 402335],
10 | [1527782400000, 202335],
11 | [1530374400000, 502335],
12 | [1533052800000, 102335],
13 | [1535731200000, 602335],
14 | [1538323200000, 202335],
15 | [1541001600000, 402335],
16 | ],
17 | },
18 | {
19 | name: 'SLB',
20 | data: [
21 | [1522512000000, 33412],
22 | [1525104000000, 43412],
23 | [1527782400000, 23412],
24 | [1530374400000, 53412],
25 | [1533052800000, 13412],
26 | [1535731200000, 63412],
27 | [1538323200000, 23412],
28 | [1541001600000, 43412],
29 | ],
30 | },
31 | {
32 | name: 'VPN',
33 | data: [
34 | [1522512000000, 200001],
35 | [1525104000000, 600001],
36 | [1527782400000, 100001],
37 | [1530374400000, 500001],
38 | [1533052800000, 100001],
39 | [1535731200000, 900001],
40 | [1538323200000, 300001],
41 | [1541001600000, 900001],
42 | ],
43 | },
44 | ];
45 |
46 | const config = {
47 | legend: {
48 | position: 'bottom',
49 | },
50 | xAxis: {
51 | type: 'time',
52 | mask: 'YYYY-MM-DD',
53 | },
54 | yAxis: {
55 | labelFormatter: val => (val > 10000 ? parseInt(String(val / 10000)) + 'W' : val),
56 | },
57 | tooltip: {
58 | valueFormatter: (val, rawData) => {
59 | return val > 10000 ? parseInt(String(val / 10000)) + 'W' : val;
60 | },
61 | },
62 | };
63 |
64 | export default () => (
65 |
66 | );
67 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/guide.ts:
--------------------------------------------------------------------------------
1 | import isPlainObjet from 'lodash/isPlainObject';
2 | import intersection from 'lodash/intersection';
3 |
4 | const allowedFunctions = [
5 | 'line',
6 | 'text',
7 | 'image',
8 | 'region',
9 | 'html',
10 | 'arc',
11 | 'regionFilter',
12 | 'dataMarker',
13 | 'dataRegion',
14 | ];
15 |
16 | export default function guide(chart, config, guideConfig) {
17 | if (!isPlainObjet(guideConfig)) {
18 | return;
19 | }
20 |
21 | // 横向的,不允许展示topUnit属性
22 | if (config.horizontal) {
23 | guideConfig.topUnit = false;
24 | }
25 |
26 | const { topUnit, ...other } = guideConfig;
27 |
28 | const configKeys = Object.keys(other || {});
29 | const intersectionKeys = intersection(configKeys, allowedFunctions);
30 | intersectionKeys.forEach(key => {
31 | if (Array.isArray(other[key])) {
32 | other[key].forEach(config => chart.guide()[key](config));
33 | } else {
34 | chart.guide()[key](other[key]);
35 | }
36 | });
37 |
38 | if (topUnit) {
39 | // 顶部单位
40 | const defaultUnitConfig = {
41 | top: true,
42 | position: ['-3%', '-10%'],
43 | style: {
44 | fill: '#8dabc4',
45 | },
46 | content: '单位',
47 | offsetX: 0,
48 | offsetY: 0,
49 | };
50 | if (Array.isArray(topUnit)) {
51 | const [firstText, secondText] = topUnit;
52 | chart
53 | .guide()
54 | .text(Object.assign(defaultUnitConfig, { content: firstText, position: ['-3%', '-10%'] }));
55 | chart
56 | .guide()
57 | .text(Object.assign(defaultUnitConfig, { content: secondText, position: ['97%', '-10%'] }));
58 | } else {
59 | chart.guide().text(Object.assign(defaultUnitConfig, { content: topUnit }));
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/XAxisTickInterval.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { ConsoleLineChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'NAT',
7 | data: [
8 | [1522512000000, 302335],
9 | [1525104000000, 402335],
10 | [1527782400000, 202335],
11 | [1530374400000, 502335],
12 | [1533052800000, 102335],
13 | [1535731200000, 602335],
14 | [1538323200000, 202335],
15 | [1541001600000, 402335],
16 | ],
17 | },
18 | {
19 | name: 'SLB',
20 | data: [
21 | [1522512000000, 33412],
22 | [1525104000000, 43412],
23 | [1527782400000, 23412],
24 | [1530374400000, 53412],
25 | [1533052800000, 13412],
26 | [1535731200000, 63412],
27 | [1538323200000, 23412],
28 | [1541001600000, 43412],
29 | ],
30 | },
31 | {
32 | name: 'VPN',
33 | data: [
34 | [1522512000000, 200001],
35 | [1525104000000, 600001],
36 | [1527782400000, 100001],
37 | [1530374400000, 500001],
38 | [1533052800000, 100001],
39 | [1535731200000, 900001],
40 | [1538323200000, 300001],
41 | [1541001600000, 900001],
42 | ],
43 | },
44 | ];
45 |
46 | const config = {
47 | legend: {
48 | position: 'bottom',
49 | },
50 | xAxis: {
51 | type: 'time',
52 | mask: 'YYYY-MM-DD',
53 | tickInterval: 1525104000000 - 1522512000000, // 1个月的时间戳差值,这里只能传入时间戳
54 | },
55 | yAxis: {
56 | labelFormatter: val => (val > 10000 ? parseInt(String(val / 10000)) + 'W' : val),
57 | },
58 | tooltip: {
59 | valueFormatter: (val, rawData) => {
60 | return val > 10000 ? parseInt(String(val / 10000)) + 'W' : val;
61 | },
62 | },
63 | };
64 |
65 | export default () => (
66 |
67 | );
68 |
--------------------------------------------------------------------------------
/docs/3-contributing.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: contributing
3 | zhName: 贡献指南
4 | sort: 3
5 | ---
6 |
7 | # 贡献指南
8 |
9 | ## 命令
10 |
11 | ### 环境准备
12 |
13 | ```bash
14 | git clone git@github.com:aliyun/alibabacloud-console-chart.git
15 |
16 | cd alibabacloud-console-chart
17 |
18 | yarn
19 | ```
20 |
21 | ### 项目初始化
22 |
23 | 在项目根目录下执行命令:
24 |
25 | ```bash
26 | yarn build
27 | ```
28 |
29 | 因为需要构建每个源码包,所以速度会比较慢,请稍等
30 |
31 | ### demo 预览
32 |
33 | 在项目根目录执行命令:
34 |
35 | ```bash
36 | yarn dev
37 | ```
38 |
39 | 可打开: `http://localhost:9001` 查看demo 情况。每个demo在`/packages`目录下各自对应目录下的`demo`目录。
40 |
41 | ### 项目开发
42 |
43 | 建议单个项目开发测试,进入到指定的图表子目录
44 |
45 | ```bash
46 | cd packages/console-***-chart
47 |
48 | yarn watch
49 | ```
50 |
51 | 开启 watch,这时候所有的改动都会被 demo 服务感知,可实时查看更改后的效果。
52 |
53 | ### 文档编写
54 |
55 |
56 | ### 发包
57 |
58 | 项目根目录执行命令
59 |
60 | ```bash
61 | lerna publish
62 | ```
63 |
64 |
65 | ## 代码仓库组织结构
66 |
67 | 本仓库使用 yarn workspace + lerna 进行管理,是 monorepo 的结构。
68 | 将本仓库克隆到本地以后,执行`yarn build`即可完成项目的初始化。
69 |
70 | > 初始化耗时较长,因为需要将所有 package 都构建一遍。
71 |
72 | - 图表组件:在`packages/`目录下。使用 webpack 来构建开发环境,进入`packages/console-xx-chart`目录并执行`yarn run watch`来开启 watch,这时候所有的改动都会被 demo 服务感知,可实时查看更改后的效果。
73 | - 文档站点:在`site`目录下。
74 | - 开发指南:原文放在`docs`目录下(比如本指南)。开发指南会被`site`项目打包,在文档站点中展示。
75 |
76 | ## 所有开发期所需的依赖都安装在根目录
77 |
78 | 新增图表组件时注意:**所有开发期所需的依赖都安装在根目录中**,从而不需要每个子目录都维护一份自己的开发依赖,做到统一管理、升级。
79 |
80 | ## 开发工具
81 |
82 | 所有`package.json`都已经配置好`scripts`,新增业务组件时请仿照已有`package.json`的格式。
83 |
84 | - 图表组件:
85 | - 使用 typescript 开发
86 | - 使用 storybook 作为开发环境
87 | - README 使用[mdx](https://mdxjs.com/)来编写,并被文档站打包渲染。在 mdx 中可以引入 storybook 的示例,以及引用源码中的类型、注释信息作为 API 文档
88 | - `yarn run dev`启动开发环境
89 | - 文档站:使用 gatsbyjs 进行开发。从而文档站是完全静态化的,所有数据在构建期间就被收集(从仓库中),在运行期间无需服务端提供数据
90 |
91 | ## PR 贡献者必须签署 CLA 协议
92 |
93 | 在提交 PR 以后会出现一个 CLA 协议让提交者签署,未签署 CLA 协议的 PR 不会被合并。
94 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # CONTRIBUTING
2 |
3 | ## 命令
4 |
5 | ### 环境准备
6 |
7 | ```bash
8 | git clone git@github.com:aliyun/alibabacloud-console-chart.git
9 |
10 | cd alibabacloud-console-chart
11 |
12 | yarn
13 | ```
14 |
15 | ### 项目初始化
16 |
17 | 在项目根目录下执行命令:
18 |
19 | ```bash
20 | yarn build
21 | ```
22 |
23 | 因为需要构建每个源码包,所以速度会比较慢,请稍等
24 |
25 | ### demo 预览
26 |
27 | 在项目根目录执行命令:
28 |
29 | ```bash
30 | yarn dev
31 | ```
32 |
33 | 可打开: `http://localhost:9001` 查看demo 情况。每个demo在`/packages`目录下各自对应目录下的`demo`目录。
34 |
35 | ### 项目开发
36 |
37 | 建议单个项目开发测试,进入到指定的图表子目录
38 |
39 | ```bash
40 | cd packages/console-***-chart
41 |
42 | yarn watch
43 | ```
44 |
45 | 开启 watch,这时候所有的改动都会被 demo 服务感知,可实时查看更改后的效果。
46 |
47 | ### 文档编写
48 |
49 | 进入项目根目录,执行以下命令即可预览文档网站:
50 | ```bash
51 | yarn site:dev
52 | ```
53 |
54 | 将编写好的文档推动到Github Pages上:
55 | ```bash
56 | yarn site:push
57 | ```
58 |
59 | ### 发包
60 |
61 | 项目根目录执行命令
62 |
63 | ```bash
64 | lerna publish
65 | ```
66 |
67 | ## 代码仓库组织结构
68 |
69 | 本仓库使用 yarn workspace + lerna 进行管理,是 monorepo 的结构。
70 | 将本仓库克隆到本地以后,执行`yarn build`即可完成项目的初始化。
71 |
72 | > 初始化耗时较长,因为需要将所有 package 都构建一遍。
73 |
74 | - 图表组件:在`packages/`目录下。使用 webpack 来构建开发环境,进入`packages/console-xx-chart`目录并执行`yarn run watch`来开启 watch,这时候所有的改动都会被 demo 服务感知,可实时查看更改后的效果。
75 | - 文档站点:在`site`目录下。
76 | - 开发指南:原文放在`docs`目录下(比如本指南)。开发指南会被`site`项目打包,在文档站点中展示。
77 |
78 | ## 所有开发期所需的依赖都安装在根目录
79 |
80 | 新增图表组件时注意:**所有开发期所需的依赖都安装在根目录中**,从而不需要每个子目录都维护一份自己的开发依赖,做到统一管理、升级。
81 |
82 | ## 开发工具
83 |
84 | 所有`package.json`都已经配置好`scripts`,新增业务组件时请仿照已有`package.json`的格式。
85 |
86 | - 图表组件:
87 | - 使用 typescript 开发
88 | - 使用 storybook 作为开发环境
89 | - README 使用[mdx](https://mdxjs.com/)来编写,并被文档站打包渲染。在 mdx 中可以引入 storybook 的示例,以及引用源码中的类型、注释信息作为 API 文档
90 | - `yarn run dev`启动开发环境
91 | - 文档站:使用 gatsbyjs 进行开发。从而文档站是完全静态化的,所有数据在构建期间就被收集(从仓库中),在运行期间无需服务端提供数据
92 |
93 | ## PR 贡献者必须签署 CLA 协议
94 |
95 | 在提交 PR 以后会出现一个 CLA 协议让提交者签署,未签署 CLA 协议的 PR 不会被合并。
96 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/demo/Smooth.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleComboChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: 'ECS',
7 | type: 'bar',
8 | yAxis: 0,
9 | data: [
10 | [1483372800000, 1892],
11 | [1483459200000, 7292],
12 | [1483545600000, 5714],
13 | [1483632000000, 5354],
14 | [1483718400000, 2014],
15 | [1483804800000, 22],
16 | [1483891200000, 11023],
17 | [1483977600000, 5218],
18 | [1484064000000, 8759],
19 | [1484150400000, 9981],
20 | [1484236800000, 4533],
21 | [1484323200000, 11398],
22 | [1484409600000, 1064],
23 | [1484496000000, 6494],
24 | ],
25 | },
26 | {
27 | name: 'RDS',
28 | type: 'line',
29 | yAxis: 1,
30 | data: [
31 | [1483372800000, 11751],
32 | [1483459200000, 4078],
33 | [1483545600000, 2175],
34 | [1483632000000, 12048],
35 | [1483718400000, 1748],
36 | [1483804800000, 10494],
37 | [1483891200000, 9597],
38 | [1483977600000, 4788],
39 | [1484064000000, 2085],
40 | [1484150400000, 492],
41 | [1484236800000, 2965],
42 | [1484323200000, 4246],
43 | [1484409600000, 2160],
44 | [1484496000000, 11877],
45 | ],
46 | },
47 | ];
48 |
49 | const config = {
50 | padding: [40, 60, 44, 28],
51 | smooth: true,
52 | xAxis: {
53 | type: 'timeCat',
54 | mask: 'YYYY-MM-DD',
55 | },
56 | yAxis: [
57 | {
58 | labelFormatter: function(value) {
59 | if (value >= 1000) return parseInt(String(value / 1000)) + 'K';
60 | else return value;
61 | },
62 | },
63 | {
64 | labelFormatter: function(value) {
65 | return value + 'W';
66 | },
67 | },
68 | ],
69 | };
70 |
71 | export default () => (
72 |
73 | );
74 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/label.ts:
--------------------------------------------------------------------------------
1 | import { get, isFunction } from '../common/utils';
2 | import isPlainObject from 'lodash/isPlainObject';
3 | import isString from 'lodash/isString';
4 |
5 | function label(
6 | geom: any,
7 | config: any,
8 | labelConfig,
9 | yField = 'y',
10 | callbackYField = 'x*y*type*facet',
11 | extras = {}
12 | ) {
13 | if (!labelConfig || get(labelConfig, 'visible') === false) {
14 | return;
15 | }
16 |
17 | if (isString(labelConfig)) {
18 | geom.label(labelConfig);
19 | } else if (isPlainObject(labelConfig)) {
20 | const newLabelConfig = Object.assign({}, labelConfig);
21 | const formatter = newLabelConfig.formatter;
22 | if (formatter) {
23 | newLabelConfig.formatter = (...args) => formatter(...args, extras);
24 | }
25 | geom.label(yField, newLabelConfig);
26 | } else if (isFunction(labelConfig)) {
27 | const newFunc = function(...args) {
28 | return labelConfig(...args, extras);
29 | };
30 | geom.label(callbackYField, newFunc);
31 | } else if (Array.isArray(labelConfig)) {
32 | let finalField = null;
33 | let finalCallback = null;
34 | let finalCfg = null;
35 | labelConfig.forEach(v => {
36 | if (isString(v)) {
37 | finalField = v;
38 | } else if (isPlainObject(v)) {
39 | finalCfg = Object.assign({}, v);
40 | } else if (isFunction(v)) {
41 | finalCallback = v;
42 | }
43 | });
44 | finalField = finalField ? finalField : callbackYField;
45 | if (finalCallback) {
46 | geom.label(finalField, (...args) => finalCallback(...args, extras), finalCfg);
47 | } else {
48 | if (finalCfg && finalCfg.formatter) {
49 | const formatter = finalCfg.formatter;
50 | finalCfg.formatter = (...args) => formatter(...args, extras);
51 | }
52 |
53 | geom.label(finalField, finalCfg);
54 | }
55 | }
56 | }
57 |
58 | export default label;
59 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "clear": "rm -rf node_modules",
4 | "clean": "lerna clean",
5 | "reinstall": "yarn run clear && yarn install",
6 | "lint": "lerna run lint",
7 | "publish": "lerna publish",
8 | "publish-next": "lerna publish --pre-dist-tag next",
9 | "build": "lerna run build",
10 | "site:push": "cd site && yarn push-build",
11 | "site:dev": "cd site && yarn dev",
12 | "dev": "start-storybook -p 9001 -c .storybook ",
13 | "bootstrap": "lerna bootstrap"
14 | },
15 | "husky": {
16 | "hooks": {
17 | "pre-commit": ""
18 | }
19 | },
20 | "private": true,
21 | "workspaces": [
22 | "packages/*"
23 | ],
24 | "devDependencies": {
25 | "@babel/cli": "^7.6.4",
26 | "@babel/core": "^7.6.4",
27 | "@babel/preset-env": "^7.6.3",
28 | "@babel/preset-react": "^7.6.3",
29 | "@storybook/addon-info": "^5.2.6",
30 | "@storybook/react": "^5.2.5",
31 | "@types/react": "^16.9.0",
32 | "@types/react-dom": "^16.8.5",
33 | "awesome-typescript-loader": "^5.2.1",
34 | "babel-loader": "^8.0.6",
35 | "husky": "^1.0.0-rc.13",
36 | "lint-staged": "^8.1.5",
37 | "prettier": "^1.14.0",
38 | "react": "^16.8.6",
39 | "react-docgen-typescript-loader": "^3.6.0",
40 | "react-dom": "^16.8.6",
41 | "rollup": "1.19.4",
42 | "rollup-plugin-auto-external": "^2.0.0",
43 | "rollup-plugin-babel": "^4.3.3",
44 | "rollup-plugin-commonjs": "^10.0.2",
45 | "rollup-plugin-copy": "^3.1.0",
46 | "rollup-plugin-json": "^4.0.0",
47 | "rollup-plugin-node-resolve": "^5.2.0",
48 | "rollup-plugin-postcss": "^2.0.3",
49 | "rollup-plugin-scss": "^1.0.2",
50 | "rollup-plugin-typescript2": "^0.22.1",
51 | "ts-jest": "^23.10.5",
52 | "tslint": "^5.8.0",
53 | "typescript": "^3.6.2",
54 | "uglifyjs-webpack-plugin": "^2.1.3"
55 | },
56 | "dependencies": {
57 | "lerna": "^3.18.4",
58 | "tslib": "^1.10.0",
59 | "d3-sankey": "^0.12.3"
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/packages/console-radar-chart/src/index.ts:
--------------------------------------------------------------------------------
1 | import {
2 | propertyAssign,
3 | propertyMap,
4 | g2Tooltip,
5 | drawLine,
6 | g2Factory,
7 | g2Legend,
8 | g2Guide,
9 | getFinalGeomColors,
10 | getConsoleConfig,
11 | Utils,
12 | dataAdapter,
13 | } from '@alicloud/console-shared-utils';
14 |
15 | const COMPONENT_NAME = 'ConsoleRadarChart';
16 |
17 | const cfg = {
18 | // 初始化前对props的预处理函数
19 | getUnifiedProps(props) {
20 | const { config } = props;
21 | const defaultConfig = getConsoleConfig()[COMPONENT_NAME];
22 | const newConfig = Utils.merge({}, defaultConfig, config);
23 | // TODO 处理padding
24 | return Object.assign({}, props, {
25 | padding: props.padding || newConfig.padding || 'auto',
26 | config: newConfig,
27 | });
28 | },
29 |
30 | drawChart(chart, config, data) {
31 | const defs: any = {
32 | x: propertyAssign(propertyMap.xAxis, {}, config.xAxis),
33 | type: {
34 | type: 'cat',
35 | },
36 | };
37 |
38 | defs.y = propertyAssign(
39 | propertyMap.yAxis,
40 | {
41 | type: 'linear',
42 | tickCount: 5,
43 | },
44 | config.yAxis
45 | );
46 |
47 | const adaptData = dataAdapter(data, config);
48 | chart.source(adaptData, defs);
49 |
50 | const radius = config.radius < 0 ? 1 : config.radius;
51 | chart.coord('polar', {
52 | radius: Math.min(radius, 1),
53 | });
54 | chart.axis('x', config.xAxis);
55 | chart.axis('y', config.yAxis);
56 |
57 | g2Tooltip(chart, config, config.tooltip, {
58 | crosshairs: null,
59 | });
60 |
61 | const colors = getFinalGeomColors(data, this.consoleTheme);
62 | config.colors = colors;
63 |
64 | drawLine(chart, config);
65 |
66 | g2Legend(chart, config, config.legend);
67 | g2Guide(chart, config, config.guide);
68 |
69 | chart.render();
70 | },
71 | };
72 |
73 | const ConsoleRadarChart: any = g2Factory(COMPONENT_NAME, cfg);
74 |
75 | export default ConsoleRadarChart;
76 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-combo-chart
3 | zhName: 混合图
4 | ---
5 |
6 | # 混合图API
7 |
8 | # 引入方式
9 | ```javascript
10 | import { ConsoleComboChart } from '@alicloud/console-chart';
11 | ```
12 |
13 | # 示例 Demo
14 |
15 | ## 基础混合图
16 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
17 |
18 | ## 纵坐标设置颜色
19 | [MDXInstruction:importDemo:YAxisColor](./demo/YAxisColor.tsx)
20 |
21 | ## 单个纵坐标
22 | [MDXInstruction:importDemo:SingleYAxis](./demo/SingleYAxis.tsx)
23 |
24 | ## 光滑曲线
25 | [MDXInstruction:importDemo:Smooth](./demo/Smooth.tsx)
26 |
27 | ## 堆叠图
28 | [MDXInstruction:importDemo:Stack](./demo/Stack.tsx)
29 |
30 | ## 自定义颜色
31 | [MDXInstruction:importDemo:Color](./demo/Color.tsx)
32 |
33 | # 配置 Config
34 |
35 | # 数据列配置
36 | | 属性 | 说明 | 类型 | 默认值 | 可选值 |
37 | | --- | --- | --- | --- | --- |
38 | | name | 数据列名称 | String | - | - |
39 | | type | 类型 | String | - | ['bar', 'line'] |
40 | | yAxis | 坐标轴下标 | Number | 0 | [0,1] |
41 | | data | 数据 | - | - | - |
42 | | color | 自定义当前数据列颜色 | String | 主题`color_24` | - |
43 |
44 | ## 通用配置
45 |
46 | | 属性 | 说明 |
47 | | --- | --- |
48 | | padding | 配置绘图内边距 |
49 | | xAxis | 配置x轴 |
50 | | yAxis | 配置y轴 |
51 | | legend | 配置图例 |
52 | | guide | 配置辅助元素 |
53 | | tooltip | 配置提示信息 |
54 | | label | 配置图形文本 |
55 | | size | 配置自定义大小 |
56 | | style | 配置自定义样式 |
57 |
58 | ## 专属配置
59 |
60 | ### grid: Boolean
61 | 是否显示网格线
62 |
63 | ### dodgeStack: Boolean
64 | 柱状图是否为分组柱状图
65 |
66 | ### stack: Boolean
67 | 柱状图是否为堆叠柱状图
68 |
69 | ### yAxisColor: Boolean
70 | Y 轴是否开启坐标轴颜色
71 |
72 | ### autoSmoothNumber: Number
73 | 在数值大于指定的条数时,条形图变成线图,并且关闭数据点的展示。
74 |
75 | ### barSize
76 | 自定义柱状图 size,优先级:`config.barSize` > `config.size`
77 |
78 | ### lineSize
79 | 自定义线图 size,优先级:`config.lineSize` > `config.size`
80 |
81 | ### barStyle
82 | 自定义柱状图 style,优先级:`config.barStyle` > `config.style`
83 |
84 | ### lineStyle
85 | 自定义线图 style,优先级:`config.lineStyle` > `config.style`
86 |
87 | ### lineLabel
88 | 单独配置线图的 `label`, 配置方法和通用`label`一致
89 |
90 | ### barLabel
91 | 单独配置柱状图的 `label`, 配置方法和通用`label`一致
92 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/demo/SelectCircleGuide.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { ConsolePieChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '时长',
7 | data: [
8 | ['1年', 45], ['2年', 26], ['3年', 12], ['4年', 8], ['5年', 10], ['6年以上', 27]
9 | ],
10 | },
11 | ];
12 |
13 | export default class extends React.Component {
14 | state = {
15 | selectKey: '',
16 | }
17 |
18 | onClick = evt => {
19 | const { selectKey } = this.state;
20 | console.log(evt.data._origin);
21 | console.log(selectKey);
22 | if (selectKey === evt.data._origin.x) {
23 | // 点击已被选择的,进行收起
24 | this.setState({ selectKey: '' });
25 | } else {
26 | this.setState({ selectKey: evt.data._origin.x });
27 | }
28 | }
29 |
30 | render() {
31 | const { selectKey } = this.state;
32 |
33 | const findItem = data[0].data.find(x => x[0] === selectKey) || [];
34 | const num = findItem && findItem.length ? findItem[1] : 0;
35 |
36 | const config = {
37 | cycle: true,
38 | guide: {
39 | html: {
40 | position: ['50%', '50%'],
41 | htmlContent:
42 | selectKey? `
43 | ${selectKey}
${num}
44 |
` : ``,
45 | alignX: 'middle',
46 | alignY: 'middle',
47 | },
48 | },
49 | tooltip: {
50 | itemTpl: `
51 |
52 | v{name}: {value}%
53 | `,
54 | },
55 | select: true,
56 | selectData: selectKey || '',
57 | };
58 |
59 | return (
60 |
68 | );
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/common/utils.ts:
--------------------------------------------------------------------------------
1 | import _get from 'lodash/get';
2 | import _merge from 'lodash/merge';
3 | import _isEmpty from 'lodash/isEmpty';
4 | import _isNumber from 'lodash/isNumber';
5 | import _isFunction from 'lodash/isFunction';
6 | import throttle from 'lodash/throttle';
7 |
8 | // @ts-ignore
9 | import G2 from '@antv/g2';
10 |
11 | export { G2, throttle };
12 |
13 | const Util = G2.Util;
14 |
15 | function is(x, y) {
16 | if (x === y) {
17 | return x !== 0 || y !== 0 || 1 / x === 1 / y;
18 | }
19 | return x !== x && y !== y; // NaN == NaN
20 | }
21 |
22 | function length(obj) {
23 | if (Util.isArray(obj)) {
24 | return obj.length;
25 | } else if (Util.isObject(obj)) {
26 | return Object.keys(obj).length;
27 | }
28 |
29 | return 0;
30 | }
31 |
32 | export function get(object, path) {
33 | return _get(object, path);
34 | }
35 |
36 | export function merge(object: any, ...otherArgs: any[]): any {
37 | return _merge(object, ...otherArgs);
38 | }
39 |
40 | export function isEmpty(obj: any) {
41 | return _isEmpty(obj);
42 | }
43 |
44 | export function isNumber(obj: any) {
45 | return _isNumber(obj);
46 | }
47 |
48 | export function isFunction(obj: any) {
49 | return _isFunction(obj);
50 | }
51 |
52 | export function isNumeric(obj) {
53 | var realStringObj = obj && obj.toString();
54 | return !Array.isArray(obj) && realStringObj - parseFloat(realStringObj) + 1 >= 0;
55 | }
56 |
57 | // 只比较第一层的属性是否全等, 深层的对象不再继续比较
58 | export function shallowEqual(objA, objB) {
59 | if (is(objA, objB)) {
60 | return true;
61 | }
62 |
63 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
64 | return false;
65 | }
66 |
67 | if (Util.isArray(objA) !== Util.isArray(objB)) {
68 | return false;
69 | }
70 |
71 | if (length(objA) !== length(objB)) {
72 | return false;
73 | }
74 |
75 | let ret = true;
76 |
77 | Util.each(objA, (v, k) => {
78 | if (!is(v, objB[k])) {
79 | ret = false;
80 | return ret;
81 | }
82 | return true;
83 | });
84 |
85 | return ret;
86 | }
87 |
--------------------------------------------------------------------------------
/packages/console-rose-chart/src/index.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Utils,
3 | getConsoleConfig,
4 | g2Factory,
5 | g2Tooltip,
6 | g2Legend,
7 | g2Label,
8 | g2Size,
9 | g2Style,
10 | Constants,
11 | dataAdapter,
12 | } from '@alicloud/console-shared-utils';
13 |
14 | const COMPONENT_NAME = 'ConsoleRoseChart';
15 | const cfg = {
16 | getUnifiedProps(props) {
17 | const { config } = props;
18 | const defaultConfig = getConsoleConfig()[COMPONENT_NAME];
19 |
20 | const newConfig = Utils.merge({}, defaultConfig, config);
21 |
22 | const unionProps = Object.assign({}, props, {
23 | config: newConfig,
24 | padding: props.padding || newConfig.padding || 'auto',
25 | });
26 |
27 | return unionProps;
28 | },
29 | // 图表绘制主函数,必选
30 | drawChart(chart, config, data) {
31 | const adaptData = dataAdapter(data, config);
32 | chart.source(adaptData);
33 | chart.coord('polar');
34 |
35 | g2Legend(chart, config, config.legend);
36 |
37 | g2Tooltip(chart, config, config.tooltip, { showTitle: false });
38 |
39 | if (config.axis) {
40 | chart.axis('x', {
41 | grid: {
42 | align: 'center',
43 | hideFirstLine: false,
44 | hideLastLine: false,
45 | },
46 | label: {
47 | offset: 10,
48 | autoRotate: true,
49 | textStyle: {
50 | textAlign: 'center',
51 | },
52 | },
53 | });
54 |
55 | chart.axis('y', {
56 | tickLine: null,
57 | label: null,
58 | line: null,
59 | });
60 | } else {
61 | chart.axis(false);
62 | }
63 |
64 | const colors = config.colors || Utils.get(this, 'consoleTheme.colors_24') || Constants.COLORS_24;
65 |
66 | const geom = chart
67 | .interval()
68 | .position('x*y')
69 | .color('x', colors);
70 |
71 | g2Size(geom, config, config.size);
72 | g2Style(geom, config, config.style);
73 | g2Label(geom, config, config.label);
74 | chart.render();
75 | },
76 | };
77 |
78 | const ConsoleRoseChart: any = g2Factory(COMPONENT_NAME, cfg);
79 |
80 | export default ConsoleRoseChart;
81 |
--------------------------------------------------------------------------------
/packages/console-miniline-chart/src/index.ts:
--------------------------------------------------------------------------------
1 | import {
2 | propertyAssign,
3 | propertyMap,
4 | g2Tooltip,
5 | drawLine,
6 | g2Factory,
7 | getConsoleConfig,
8 | g2Guide,
9 | Utils,
10 | dataAdapter,
11 | getFinalGeomColors,
12 | } from '@alicloud/console-shared-utils';
13 |
14 | const COMPONENT_NAME = 'ConsoleMinilineChart';
15 |
16 | const cfg = {
17 | getUnifiedProps(props) {
18 | const { config } = props;
19 | const defaultConfig = getConsoleConfig()[COMPONENT_NAME];
20 | const newConfig = Utils.merge({}, defaultConfig, config);
21 |
22 | const unionConfig = Object.assign({}, props, {
23 | config: newConfig,
24 | padding: props.padding || newConfig.padding || 'auto',
25 | });
26 | return unionConfig;
27 | },
28 |
29 | drawChart(chart, userConfig, data) {
30 | const config = userConfig;
31 |
32 | const defs: any = {
33 | x: propertyAssign(
34 | propertyMap.xAxis,
35 | {
36 | type: 'cat',
37 | range: [0, 1],
38 | },
39 | config.xAxis
40 | ),
41 | type: {
42 | type: 'cat',
43 | },
44 | };
45 |
46 | if (Array.isArray(config.yAxis)) {
47 | config.yAxis.forEach((axis, yIndex) => {
48 | defs[`y${yIndex}`] = propertyAssign(
49 | propertyMap.yAxis,
50 | {
51 | type: 'linear',
52 | tickCount: 5,
53 | },
54 | axis
55 | );
56 | });
57 | } else {
58 | defs.y = propertyAssign(
59 | propertyMap.yAxis,
60 | {
61 | type: 'linear',
62 | tickCount: 5,
63 | },
64 | config.yAxis
65 | );
66 | }
67 |
68 | const colors = getFinalGeomColors(data, this.consoleTheme);
69 | config.colors = colors;
70 |
71 | const adaptData = dataAdapter(data, config);
72 | chart.source(adaptData, defs);
73 |
74 | chart.axis(false);
75 |
76 | chart.legend(false);
77 |
78 | // tooltip, 迷你图默认关闭tooltip
79 | if (!config.tooltip) {
80 | config.tooltip = false;
81 | }
82 | g2Tooltip(chart, config, config.tooltip);
83 |
84 | // 绘制辅助线,辅助背景区域
85 | g2Guide(chart, config, config.guide);
86 |
87 | drawLine(chart, config);
88 |
89 | chart.render();
90 | },
91 | };
92 |
93 | const ConsoleMinilineChart: any = g2Factory(COMPONENT_NAME, cfg);
94 |
95 | export default ConsoleMinilineChart;
96 |
--------------------------------------------------------------------------------
/packages/console-line-chart/demo/LegendClick.tsx:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import React from 'react';
3 | import { ConsoleLineChart } from '@alicloud/console-chart';
4 |
5 | const data = [
6 | {
7 | name: 'ECS',
8 | data: [
9 | ['201804', 31],
10 | ['201805', 39],
11 | ['201806', 32],
12 | ['201807', 35],
13 | ['201808', 31],
14 | ['201809', 36],
15 | ['201810', 32],
16 | ['201811', 34],
17 | ],
18 | },
19 | {
20 | name: 'OSS',
21 | data: [
22 | ['201804', 12],
23 | ['201805', 12],
24 | ['201806', 12],
25 | ['201807', 11],
26 | ['201808', 10],
27 | ['201809', 14],
28 | ['201810', 12],
29 | ['201811', 11],
30 | ],
31 | },
32 | {
33 | name: 'RDS',
34 | data: [
35 | ['201804', 48],
36 | ['201805', 45],
37 | ['201806', 43],
38 | ['201807', 44],
39 | ['201808', 41],
40 | ['201809', 45],
41 | ['201810', 42],
42 | ['201811', 45],
43 | ],
44 | },
45 | ];
46 |
47 | const ossConfig = {
48 | yAxis: {
49 | min: 30
50 | }
51 | };
52 |
53 | const defaultConfig = {
54 | yAxis: {
55 | min: 0
56 | }
57 | }
58 |
59 | interface State {
60 | keys: string[];
61 | }
62 |
63 | interface Props {}
64 |
65 | class Demo extends React.Component {
66 | constructor(props: Props) {
67 | super(props);
68 | const defaultKeys = data.map(x => x.name);
69 | this.state = {
70 | keys: defaultKeys,
71 | }
72 | }
73 |
74 | handleClick = (ev: any) => {
75 | const { keys } = this.state;
76 | const val = ev.data.value;
77 | let newKeys = [];
78 | if (keys.includes(val)) {
79 | newKeys = keys.filter(x => x !== val);
80 | } else {
81 | newKeys = [...keys, val];
82 | }
83 | this.setState({ keys: newKeys });
84 | };
85 |
86 | render() {
87 | const { keys } = this.state;
88 | console.log(keys);
89 |
90 | const config = !keys.includes('OSS') ? ossConfig : defaultConfig;
91 |
92 | return (
93 |
101 | );
102 | }
103 | }
104 |
105 | export default () => ;
106 |
--------------------------------------------------------------------------------
/docs/11-config-label.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: config-label
3 | zhName: 配置-文本
4 | sort: 11
5 | ---
6 |
7 | # config-图形文本
8 |
9 | 下面提到的 `label` 等同于图形文本
10 |
11 | # 配置方式
12 |
13 | ## 关闭 label
14 |
15 | 若不主动指定`config.label`, HailChart 默认关闭所有图表的 label。
16 |
17 | ```javascript
18 | config.label = null;
19 | // or
20 | config.label = { visible: false };
21 | ```
22 |
23 | ## 开启label
24 |
25 | ### 对默认 field 配置 cfg
26 | ```javascript
27 | // 对值所在的field设置cfg
28 | config.label = {};
29 | ```
30 |
31 | ### 对默认field配置callback
32 | ```javascript
33 | config.label = y => {};
34 | ```
35 |
36 | ### 指定field
37 | 可以显示指定field对应的数据值。
38 | ```javascript
39 | config.label = 'y';
40 | ```
41 |
42 | ### 为指定 field 配置 callback
43 | ```javascript
44 | config.label = ['x', x => {}];
45 | ```
46 |
47 | ### 为指定 field 配置 cfg
48 | ```javascript
49 | // 对自定义field设置label
50 | config.label = ['x', {}];
51 | ```
52 |
53 | ### 为指定field 配置 callback+cfg
54 |
55 | ```javascript
56 | config.label[('x', x => {}, {})];
57 | ```
58 |
59 | # 配置列表
60 |
61 | ## G2
62 |
63 | ### useHtml: boolean
64 |
65 | 是否使用 html 渲染,默认为 false。
66 |
67 | ### formatter: function
68 |
69 | 对显示文本进行格式化。
70 |
71 | ```javascript
72 | config.label = {
73 | formatter: function(text, item, index) {
74 | return text + item.point.y;
75 | },
76 | };
77 | ```
78 |
79 | ### type: string
80 |
81 | 文本布局类型。默认为'default'。
82 |
83 | ### labelLine: Object|Boolean
84 |
85 | 配置文本连线。如果值为 false,表示不展示文本线
86 |
87 | ```javascript
88 | config.label = [
89 | 'x',
90 | {
91 | labelLine: {
92 | lineWidth: 1, // 线的粗细
93 | stroke: '#ff8800', // 线的颜色
94 | lineDash: [2, 1], // 虚线样式
95 | },
96 | },
97 | ];
98 | ```
99 |
100 | 以下属性为 Canvas 专属配置
101 |
102 | ### position: String
103 |
104 | 仅当 chart 的 geom 为 interval 时有效。指定当前 label 与当前图形的相对位置,可选参数为 `middle`, `top`, `bottom`, `left`, `right`。默认为 `top`。
105 |
106 | ### offset: Number|Array
107 |
108 | 设置坐标轴文本 label 距离坐标轴线的距离,可以是数值或数组。默认为[0, 20]。数组可指定当前坐标轴 x,y 方向上的偏移。单个数值指定 y 方向上的偏移。
109 |
110 | ### autoRotate: Boolean
111 |
112 | 文本是否需要自动旋转,默认为 true
113 |
114 | 以下配置 html 专有配置属性
115 |
116 | ### htmlTemplate: Function
117 |
118 | 代码示例, 使用 x 轴的值作为`label`的值。
119 |
120 | ```javascript
121 | config.label = [
122 | 'x',
123 | {
124 | useHtml: true,
125 | htmlTemplate: (text, item, index) => {
126 | return '' + text + '
';
127 | },
128 | },
129 | ];
130 | ```
131 |
--------------------------------------------------------------------------------
/packages/console-sankey-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-sankey-chart
3 | zhName: 桑基图
4 | ---
5 |
6 | # 桑基图API
7 |
8 | 桑基图是关系图的一种,常用来表示流入流出的关系。
9 |
10 | 典型桑基图的特点有:
11 |
12 | - 开始总和 = 结束总和,能量平衡
13 | - 每个流向(即每条边)的宽度有意义,常用来表示当前分支在所在深度的占比
14 | - 每个节点的宽度也有意义,表示这个节点的占比
15 |
16 | # 引入方式
17 |
18 | ```javascript
19 | import { ConsoleSankeyChart } from '@alicloud/console-chart';
20 | ```
21 |
22 | # 示例 Demo
23 |
24 | 关系图情况复杂,使用方式多变,如果有未满足的场景,烦请联系我们。
25 |
26 | ## 基本用法
27 |
28 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
29 |
30 | ## 多列情况
31 |
32 | [MDXInstruction:importDemo:MultiCol](./demo/MultiCol.tsx)
33 |
34 | ## 配置边
35 |
36 | [MDXInstruction:importDemo:LinkStyle](./demo/LinkStyle.tsx)
37 |
38 | ## 垂直布局
39 | 通过`direction`属性来进行改变布局方向,有`vertical`,`horizontal`两个值。
40 |
41 | [MDXInstruction:importDemo:Vertical](./demo/Vertical.tsx)
42 |
43 | ## 节点排列方式
44 | 节点排列方式通过`nodeAlign`属性来进行配置,有`start end center justify`四个值,默认为`justify`
45 |
46 | [MDXInstruction:importDemo:NodeAlign](./demo/NodeAlign.tsx)
47 |
48 | ## 拓扑图
49 | 通过使用`topology`属性来配置拓扑图
50 |
51 | [MDXInstruction:importDemo:Topology](./demo/Topology.tsx)
52 |
53 | ## 垂直拓扑图
54 |
55 | [MDXInstruction:importDemo:TopologyVertical](./demo/TopologyVertical.tsx)
56 |
57 |
58 | # 配置 Config
59 |
60 | # 数据列配置
61 |
62 | 桑基图的数据列分2列,一列为节点数据,另一列为边数据。
63 |
64 | | 属性 | 说明 | 类型 | 默认值 | 说明 |
65 | | --- | --- | --- | --- | --- |
66 | | name | 数据列名称 | String | - | 说明性质,可不填 |
67 | | type | 数据类型 | String | - | 必填,`node`或`link` |
68 | | data | 数据 | Array | - | - |
69 |
70 | 数据示例:
71 | ```js
72 | const data = [
73 | {
74 | type: 'node',
75 | data: [
76 | { "name": "ecs" },
77 | ]
78 | },
79 | {
80 | type: 'link',
81 | data: [
82 | {
83 | "source": 3,
84 | "target": 0,
85 | "value": 5
86 | },
87 | ]
88 | }
89 | ];
90 | ```
91 |
92 | ## 通用配置
93 |
94 | | 属性 | 说明 |
95 | | --- | --- |
96 | | padding | 配置绘图内边距 |
97 | | xAxis | 配置x轴 |
98 | | yAxis | 配置y轴 |
99 | | legend | 配置图例 |
100 | | guide | 配置辅助元素 |
101 | | tooltip | 配置提示信息 |
102 | | label | 配置图形文本 |
103 | | size | 配置自定义大小 |
104 | | style | 配置自定义样式 |
105 |
106 |
107 | ## 专属配置
108 |
109 | ### direction: String
110 | 通过`direction`属性来进行改变布局方向,有`vertical`,`horizontal`两个值。
111 |
112 | ### linkType: String
113 | 用来简单配置边的类型。
114 |
115 | ### nodeAlign: String
116 | 节点排列方式通过`nodeAlign`属性来进行配置,有`start end center justify`四个值,默认为`justify`
117 |
118 | ### topology: Boolean
119 | 是否开启拓扑图模式。在拓扑图模式下,一个节点身上只会有一个连接点,且连接点位于节点的中间处
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/rectAutoTickCount.ts:
--------------------------------------------------------------------------------
1 | import { pxToNumber, isInvalidNumber } from './common';
2 |
3 | /**
4 | * 常见直角坐标系自动计算标签个数。
5 | * @param chart {object} G2图表实例
6 | * @param config {object} 图表配置项
7 | * @param defs {object} 数据列定义
8 | * @param transpose {boolean} 坐标系是否翻转,翻转后使用宽度计算Y轴,高度计算X轴
9 | * */
10 | function rectAutoTickCount(chart, config, defs, transpose) {
11 | // X轴&Y轴对应的长度
12 | const xLen = transpose ? chart.get('height') : chart.get('width');
13 | const yLen = transpose ? chart.get('width') : chart.get('height');
14 |
15 | // 坐标系不翻转时为横向,翻转时为纵向
16 | computerAxis(chart, config.xAxis, defs.x, transpose, xLen);
17 |
18 | // 坐标系不翻转时为纵向,翻转时为横向
19 | if (Array.isArray(config.yAxis)) {
20 | config.yAxis.forEach((axis, yIndex) => {
21 | computerAxis(chart, axis, defs[`y${yIndex}`], !transpose, yLen);
22 | });
23 | } else {
24 | computerAxis(chart, config.yAxis, defs.y, !transpose, yLen);
25 | }
26 | }
27 |
28 | // 计算口径 horizontal 横向 ? vertical 纵向
29 | function computerAxis(chart, axisConfig, def, isVertical, len) {
30 | // 轴设定为不显示 或 tickCount 不是 auto 时,跳过
31 | if (
32 | !axisConfig ||
33 | (axisConfig && axisConfig.visible === false) ||
34 | axisConfig.tickCount !== 'auto'
35 | ) {
36 | return;
37 | }
38 |
39 | let labelFontSize = pxToNumber('12px');
40 | if (
41 | axisConfig.customConfig &&
42 | axisConfig.customConfig.label &&
43 | axisConfig.customConfig.label.textStyle &&
44 | axisConfig.customConfig.label.textStyle.fontSize
45 | ) {
46 | labelFontSize = convertFontSize(axisConfig.customConfig.label.textStyle.fontSize);
47 | }
48 |
49 | let tickCount = 0;
50 |
51 | if (isVertical) {
52 | // 纵向,使用高度计算,除数为 一倍的字体大小 + 三分之四倍字号作为间距
53 | // TODO 需要减去上下padding
54 | tickCount = Math.max(Math.floor((len - 20) / ((labelFontSize * 8) / 3)), 2);
55 | } else if (def.type === 'time' || def.type === 'timeCat') {
56 | // 横向,使用宽度计算,仅支持time类型,取mask的字符长度 * 0.5倍字号作为标签宽度,再乘1.5倍作为除数
57 | const labelWidth = ((def.mask || 'YYYY-MM-DD HH:mm:ss').length * labelFontSize) / 2;
58 | tickCount = Math.max(Math.floor(len / ((labelWidth * 3) / 2)), 2);
59 | }
60 |
61 | if (tickCount) {
62 | console.log(tickCount);
63 | def.tickCount = tickCount;
64 | }
65 | }
66 |
67 | function convertFontSize(fontSize) {
68 | let size = fontSize;
69 | if (typeof size === 'string') {
70 | size = size.replace('px', '');
71 | }
72 | if (isInvalidNumber(size)) {
73 | return pxToNumber('12px');
74 | } else {
75 | return Number(size);
76 | }
77 | }
78 |
79 | export { rectAutoTickCount };
80 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/drawLine.ts:
--------------------------------------------------------------------------------
1 | import g2Label from './label';
2 | import g2Size from './size';
3 | import g2Style from './style';
4 |
5 | function drawLine(chart: any, config: any, yAxisKey = 'y') {
6 | let lineGeom = null;
7 |
8 | const lineShape = config.smooth ? 'smooth' : 'line';
9 | const areaShape = config.smooth ? 'smooth' : 'area';
10 |
11 | let clrsOne = [];
12 | let clrsTwo = [];
13 | (config.colors || []).forEach((x: string | [string, string]) => {
14 | if (Array.isArray(x)) {
15 | clrsOne.push(x[0]);
16 | clrsTwo.push(x[1]);
17 | } else if (typeof x === 'string') {
18 | clrsOne.push(x);
19 | clrsTwo.push(x);
20 | }
21 | });
22 |
23 | if (config.area && config.stack) {
24 | chart
25 | .areaStack()
26 | .position(['x', yAxisKey])
27 | .color('type', clrsTwo)
28 | .shape(areaShape)
29 | .active(false);
30 | lineGeom = chart
31 | .lineStack()
32 | .position(['x', yAxisKey])
33 | .color('type', clrsOne)
34 | .shape(lineShape)
35 | .active(false);
36 | } else if (config.area && !config.stack) {
37 | chart
38 | .area()
39 | .position(['x', yAxisKey])
40 | .color('type', clrsTwo)
41 | .shape(areaShape)
42 | .active(false);
43 | lineGeom = chart
44 | .line()
45 | .position(['x', yAxisKey])
46 | .color('type', clrsOne)
47 | .shape(lineShape)
48 | .active(false);
49 | } else {
50 | lineGeom = chart
51 | .line()
52 | .position(['x', yAxisKey])
53 | .color('type', clrsOne)
54 | .shape(lineShape)
55 | .active(false);
56 | }
57 |
58 | g2Size(lineGeom, config, config.lineSize || config.size);
59 | g2Label(lineGeom, config, config.label, yAxisKey);
60 | g2Style(lineGeom, config, config.style);
61 |
62 | // 曲线默认点
63 | let pointGeom = null;
64 | if (config.symbol) {
65 | if (config.area && config.stack) {
66 | pointGeom = chart
67 | .point()
68 | .adjust('stack')
69 | .position(['x', yAxisKey])
70 | .color('type', config.colors)
71 | .shape('circle')
72 | .active(false);
73 | } else {
74 | pointGeom = chart
75 | .point()
76 | .position(['x', yAxisKey])
77 | .color('type', config.colors)
78 | .shape('circle')
79 | .active(false);
80 | }
81 |
82 | g2Size(pointGeom, config, config.symbolSize || config.size, 'type', 'x*y*type*extra');
83 | g2Label(pointGeom, config, config.symbolLabel);
84 | g2Style(pointGeom, config, config.symbolStyle);
85 | }
86 | }
87 |
88 | export default drawLine;
89 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import path from 'path';
2 | import babel from 'rollup-plugin-babel';
3 | import commonjs from 'rollup-plugin-commonjs';
4 | import postcss from 'rollup-plugin-postcss';
5 | import resolve from 'rollup-plugin-node-resolve';
6 | import json from 'rollup-plugin-json';
7 | import copy from 'rollup-plugin-copy';
8 | import autoExternal from 'rollup-plugin-auto-external';
9 |
10 | const typescript = require('rollup-plugin-typescript2');
11 |
12 | const PACKAGE_ROOT_PATH = process.cwd();
13 | const INPUT_FILE = path.join(PACKAGE_ROOT_PATH, 'src/index.ts');
14 | const PKG_JSON = require(path.join(PACKAGE_ROOT_PATH, 'package.json'));
15 |
16 | const ALL_FORMATS = [
17 | { fmt: 'umd', ts: 'es5', dest: 'dist', file: 'dist/index.js' },
18 | { fmt: 'es', ts: 'esnext', dest: 'es', file: 'es/index.js' },
19 | { fmt: 'cjs', ts: 'es5', dest: 'lib', file: 'lib/index.js' },
20 | ];
21 |
22 | const defaultPluginsCb = () => [typescript(), resolve(), commonjs()];
23 |
24 | const defaultExternalCb = fmt => {
25 | if (fmt === 'umd') {
26 | return ['react', 'react-dom'];
27 | } else {
28 | return [
29 | ...Object.keys(PKG_JSON.dependencies || {}),
30 | ...Object.keys(PKG_JSON.peerDependencies || {}),
31 | ];
32 | }
33 | };
34 |
35 | const defaultGlobalsCb = fmt => {
36 | if (fmt === 'umd') {
37 | return {
38 | react: 'React',
39 | 'react-dom': 'ReactDOM',
40 | };
41 | } else {
42 | return {};
43 | }
44 | };
45 |
46 | export default function generateRollupConfig({
47 | formatArr = ['es'],
48 | input = INPUT_FILE,
49 | plugins = defaultPluginsCb,
50 | external = defaultExternalCb,
51 | output = {},
52 | }) {
53 | const allowFormats = ALL_FORMATS.filter(v => formatArr.includes(v.fmt));
54 | return allowFormats.map(format => {
55 | const processedConfig = {
56 | input,
57 | output: Object.assign(
58 | {
59 | file: path.join(PACKAGE_ROOT_PATH, format.file),
60 | format: format.fmt,
61 | sourcemap: false,
62 | name: PKG_JSON.name,
63 | strict: false,
64 | globals: defaultGlobalsCb(format.fmt),
65 | },
66 | output
67 | ),
68 | };
69 | // 处理external
70 | if (typeof external === 'function') {
71 | processedConfig.external = external(format.fmt);
72 | } else {
73 | processedConfig.external = external;
74 | }
75 | // 处理plugins
76 | processedConfig.plugins = plugins(format);
77 |
78 | return processedConfig;
79 | });
80 | }
81 |
82 | export const plugins = {
83 | babel,
84 | typescript,
85 | resolve,
86 | json,
87 | postcss,
88 | commonjs,
89 | autoExternal,
90 | copy,
91 | };
92 |
--------------------------------------------------------------------------------
/docs/4-props.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: props
3 | zhName: 属性
4 | sort: 4
5 | ---
6 |
7 | # 组件 props
8 |
9 | **Console-Chart** 所有类型的图表组件遵循`React Component`组件规范,且使用统一的`props`。
10 |
11 | ### props 列表
12 | | 属性 | 说明 | 类型 | 默认值 |
13 | | --- | --- | --- | --- |
14 | | data | highcharts 规范的数据格式 | Array | - |
15 | | config | 配置 | Object | - |
16 | | padding | 图表绘制区域的 padding | Array | - |
17 | | width | 图表的宽度 | Number | 父组件的宽度 |
18 | | height | 图表的高度 | Number | 父组件的高度 |
19 | | className | 自定义类名 | String | - |
20 | | style | 自定义样式 | Object | - |
21 | | children | 指定图表的子节点 | ReactNode | - |
22 | | animate | 是否开启动画 | Boolean | false |
23 | | event | [G2 的 event 配置](https://www.yuque.com/antv/g2-docs/api-chart#10b2761d), 支持监听 chart 事件。 | Object | - |
24 | | onGetG2Instance | 获取G2实例 | Function | null |
25 |
26 | ### data
27 | 所有传入图表组件的 `data` 必须是复合Console-Chart数据规范的。
基本的格式如下:
28 |
29 | ```javascript
30 | const data = [{ name: '分类1', data: [] }, { name: '分类2', data: [] }];
31 | ```
32 | 更详细的信息请参考:数据格式说明
33 |
34 | ### config
35 | **Console-Chart**会使用`config` 作为图表的配置入口, `config` 配置分为两类:配置+图表专属配置。
36 |
37 | - 公共配置:所有图表库公用的,配置方法相同
38 | - 专属配置:不同的图表能力各有不同,需要专属的配置
39 |
40 | ```javascript
41 | // 无任何配置
42 | config = {};
43 |
44 | // 设置图表的padding
45 | config = {
46 | padding: [20, 30, 20, 40],
47 | };
48 |
49 | // 设置图表的x轴的类型及展示格式
50 | config = {
51 | xAxis: {
52 | type: 'time',
53 | mask: 'YYYYMMDD',
54 | },
55 | };
56 |
57 | // 设置图表的Y轴
58 | config = {
59 | yAxis: {
60 | label: {
61 | formatter: val => `${val} 万`,
62 | }
63 | },
64 | };
65 | ```
66 |
67 | ### width
68 | **Console-Chart**会优先使用开发者传入的`width`作为图表的绘图宽度,并且不会随父节点的宽度影响。 如果不指定`width`, **Console-Chart**会自动计算父节点的宽度, 并使用该值作为图表的绘图宽度。
69 |
70 | ### height
71 | **Console-Chart**会优先使用开发者传入的 `height` 作为图表的绘图宽度,并且不会随父节点的宽度影响。 如果不指定`width`, **Console-Chart**会自动计算父节点的宽度, 并使用该值作为图表的绘图宽度。
72 |
73 | ### padding
74 | 设置图表的内边距
图表的`padding`可通过`props`传入,也支持通过`config.padding`方式传入。
75 |
76 | ```javascript
77 | padding: [ 20, 30, 20, 30] // CSS 盒模型(上右下左)
78 |
79 | padding: 20 // 四个边都是20px
80 |
81 | padding: { top: 20, right: 30, bottom: 20, left: 30 }
82 |
83 | padding: 'auto'
84 |
85 | padding: [20, 'auto', 30, 'auto']
86 | ```
87 |
88 | - 另外也支持设置百分比,如 `padding: [ '20%', '30%' ]`,该百分比相对于整个图表的宽高。
89 | - padding 为数字以及数组类型时使用方法同 CSS 盒模型(上右下左)。
90 | - padding 中存在 'auto',时会自动计算边框,目前仅考虑 axis 和 legend 占用的边框
91 |
92 | ### event
93 | [G2 的 event 配置](https://www.yuque.com/antv/g2-docs/api-chart#10b2761d), 支持监听 chart 事件。
94 |
95 | ### children
96 | 目前暂不需要使用该属性
97 |
98 | ### onGetG2Instance
99 | 获取 chart 实例的回调。每当生成一个新 chart 时就会调用该函数,并以新生成的 chart 作为回调参数。
100 |
101 | ```javascript
102 | onGetG2Instance = chart => {
103 | chart.animate(false);
104 | }
105 | ```
106 |
107 |
--------------------------------------------------------------------------------
/packages/console-pie-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-pie-chart
3 | zhName: 饼图
4 | ---
5 |
6 | # 饼图API
7 |
8 | # 引入方式
9 |
10 | ```javascript
11 | import { ConsolePieChart } from '@alicloud/console-chart';
12 | ```
13 |
14 | # 示例 Demo
15 |
16 | ## 基本使用
17 |
18 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
19 |
20 | ## 带label指标
21 |
22 | [MDXInstruction:importDemo:Label](./demo/Label.tsx)
23 |
24 | ## 自定义tooltip
25 |
26 | [MDXInstruction:importDemo:Tooltip](./demo/Tooltip.tsx)
27 |
28 | ## 复杂Tooltip
29 |
30 | [MDXInstruction:importDemo:ComplexTooltip](./demo/ComplexTooltip.tsx)
31 |
32 | ## 配置legend
33 |
34 | [MDXInstruction:importDemo:Legend](./demo/Legend.tsx)
35 |
36 | ## legend在右边
37 |
38 | 通过设置Chart的`右Padding`和Legend的`offsetY`属性来控制legend的位置。
39 |
40 | Note: `右Padding`是指圆形的右边界到渲染区域的右边界。`offsetY`是指圆形的右边界到legend的左边界。
41 |
42 | [MDXInstruction:importDemo:LegendRight](./demo/LegendRight.tsx)
43 |
44 | ## legend tip
45 |
46 | 配置`legend`的`tip`属性可开启legend悬浮提示。开启tip配置之后,可进一步配置`tipFormatter`属性来进行格式化tip显示内容(取值优先级:`tipFormatter` => `itemFormatter` => `value`)
47 |
48 | Note: `legend`的`tip`属性是通过`dom`的`title`属性来进行简单实现的,只能满足简单场景。
49 |
50 | [MDXInstruction:importDemo:LegendTip](./demo/LegendTip.tsx)
51 |
52 | ## 单色
53 |
54 | [MDXInstruction:importDemo:SingleColors](./demo/SingleColors.tsx)
55 |
56 | ## 指定颜色
57 |
58 | [MDXInstruction:importDemo:MultiColors](./demo/MultiColors.tsx)
59 |
60 | ## 基础环状图
61 |
62 | [MDXInstruction:importDemo:Circle](./demo/Circle.tsx)
63 |
64 | ## 环间距
65 |
66 | [MDXInstruction:importDemo:CircleSlice](./demo/CircleSlice.tsx)
67 |
68 | ## 环状带Guide
69 |
70 | [MDXInstruction:importDemo:CircleGuide](./demo/CircleGuide.tsx)
71 |
72 | ## 选中状态
73 |
74 | [MDXInstruction:importDemo:Select](./demo/Select.tsx)
75 |
76 | ## 根据选中状态更新环内Guide
77 |
78 | [MDXInstruction:importDemo:SelectCircleGuide](./demo/SelectCircleGuide.tsx)
79 |
80 | # 配置 Config
81 |
82 | ## 数据列配置
83 | | 属性 | 说明 | 类型 | 默认值 | 可选值 |
84 | | --- | --- | --- | --- | --- |
85 | | name | 数据列名称 | String | - | - |
86 | | data | 数据 | Array | - | - |
87 |
88 | ## 通用配置
89 |
90 | | 属性 | 说明 |
91 | | --- | --- |
92 | | padding | 配置绘图内边距 |
93 | | xAxis | 配置x轴 |
94 | | yAxis | 配置y轴 |
95 | | legend | 配置图例 |
96 | | guide | 配置辅助元素 |
97 | | tooltip | 配置提示信息 |
98 | | label | 配置图形文本 |
99 | | size | 配置自定义大小 |
100 | | style | 配置自定义样式 |
101 |
102 | ## 专属配置
103 |
104 | ### autoSort: Boolean
105 | 是否需要按照从大到小的顺序排序
106 |
107 | ### cycle: Boolean
108 | 是否将饼状图转变为环状图
109 |
110 | ### innerRadius: Number
111 | 内圈半径,需要配合`cycle`使用
112 |
113 | ### sliceGap: Number
114 | 需要配合`cycle`使用,环图情况下,可以使用该参数来调整每个环之间的间距,数值范围0-1
115 |
116 | ### select: Boolean
117 | 是否支持选中态
118 |
119 | ### selectData: String
120 | 选中的数据
121 |
122 | ### colors: String|Array
123 | 自定义颜色
--------------------------------------------------------------------------------
/packages/console-sankey-chart/src/transform.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * for Sankey Diagram
3 | * graph data required (nodes, edges)
4 | */
5 | const {
6 | sankey,
7 | sankeyLeft,
8 | sankeyRight,
9 | sankeyCenter,
10 | sankeyJustify
11 | } = require('d3-sankey');
12 |
13 | const isString = val => typeof val === 'string';
14 | const isFunction = val => val && typeof val === 'function';
15 |
16 | const ALIGN_METHOD = {
17 | start: sankeyLeft,
18 | end: sankeyRight,
19 | center: sankeyCenter,
20 | justify: sankeyJustify
21 | };
22 |
23 | const DEFAULT_OPTIONS = {
24 | // nodeId: node => node.index,
25 | value: node => node.value,
26 | source: edge => edge.source,
27 | target: edge => edge.target,
28 | nodeAlign: 'justify',
29 | nodeWidth: 0.02,
30 | nodePadding: 0.02
31 | };
32 |
33 | export default function transform(dv, options, customOptions) {
34 | const {
35 | topology,
36 | } = customOptions;
37 | options = Object.assign({}, DEFAULT_OPTIONS, options);
38 | let nodeAlign = null;
39 | if (isString(options.nodeAlign)) {
40 | nodeAlign = ALIGN_METHOD[options.nodeAlign];
41 | } else if (isFunction(options.nodeAlign)) {
42 | nodeAlign = options.nodeAlign;
43 | }
44 | const sankeyProcessor = sankey()
45 | .links(d => d.edges)
46 | .nodeWidth(options.nodeWidth)
47 | .nodePadding(options.nodePadding)
48 | .extent([[ 0, 0 ], [ 1, 1 ]]);
49 |
50 | if (isFunction(options.nodeId)) {
51 | sankeyProcessor.nodeId(options.nodeId);
52 | }
53 |
54 | if (nodeAlign) {
55 | sankeyProcessor.nodeAlign(nodeAlign);
56 | }
57 |
58 | sankeyProcessor(dv);
59 | // post process (x, y), etc.
60 | dv.nodes.forEach(node => {
61 | const { x0, x1, y0, y1 } = node;
62 | /* points
63 | * 3---2
64 | * | |
65 | * 0---1
66 | */
67 | node.x = [ x0, x1, x1, x0 ];
68 | node.y = [ y0, y0, y1, y1 ];
69 | });
70 | if (topology) {
71 | dv.edges.forEach(edge => {
72 | const {
73 | source,
74 | target
75 | } = edge;
76 | const sx = source.x1;
77 | const tx = target.x0;
78 | const sy = source.y0;
79 | const ty = target.y1;
80 | edge.x = [ sx, sx, tx, tx ];
81 | // const offset = edge.width / 2;
82 | edge.y = [
83 | sy + (source.y1 - source.y0) / 2 ,
84 | sy + (source.y1 - source.y0) / 2 ,
85 | ty + (target.y0 - target.y1) / 2 ,
86 | ty + (target.y0 - target.y1) / 2
87 | ];
88 | });
89 | } else {
90 | dv.edges.forEach(edge => {
91 | const {
92 | source,
93 | target
94 | } = edge;
95 | const sx = source.x1;
96 | const tx = target.x0;
97 | edge.x = [ sx, sx, tx, tx ];
98 | const offset = edge.width / 2;
99 | edge.y = [ edge.y0 + offset, edge.y0 - offset, edge.y1 + offset, edge.y1 - offset ];
100 | });
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/packages/console-tree-graph/demo/Basic.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ConsoleTreeGraph from '@alicloud/console-tree-graph';
3 | // import ConsoleTreeGraph from '../src';
4 |
5 | export default () => {
6 | const config = {
7 | height: 800,
8 | width: 600,
9 | fitView: true,
10 | };
11 | return (
12 |
13 | )
14 | };
15 |
16 | const data = {
17 | name: '根节点',
18 | id: '1',
19 | children: [
20 | {
21 | name: '一级节点-1',
22 | id: '11',
23 | children: [
24 | {
25 | name: '二级节点-1',
26 | id: '111',
27 | children: [
28 | {
29 | name: '三级节点-1',
30 | id: '111211',
31 | },
32 | {
33 | name: '三级节点-2',
34 | id: '111212',
35 | },
36 | {
37 | name: '三级节点-3',
38 | id: '11213',
39 | },
40 | {
41 | name: '三级节点-4',
42 | id: '112114',
43 | },
44 | ],
45 | },
46 | {
47 | name: '二级节点-2',
48 | id: '1112',
49 | children: [
50 | {
51 | name: '三级节点-41',
52 | id: '11121',
53 | },
54 | {
55 | name: '三级节点-42',
56 | id: '11122',
57 | },
58 | {
59 | name: '三级节点-43',
60 | id: '11123',
61 | },
62 | {
63 | name: '三级节点-44',
64 | id: '11124',
65 | },
66 | ],
67 | },
68 | ],
69 | },
70 | {
71 | name: '一级节点-2',
72 | id: '12',
73 | children: [
74 | {
75 | name: '二级节点-21',
76 | id: '121',
77 | children: [
78 | {
79 | name: '三级节点-11',
80 | id: '1211',
81 | },
82 | {
83 | name: '三级节点-12',
84 | id: '1212',
85 | },
86 | {
87 | name: '三级节点-13',
88 | id: '1213',
89 | },
90 | {
91 | name: '三级节点-14',
92 | id: '1214',
93 | },
94 | ],
95 | },
96 | {
97 | name: '二级节点-22',
98 | id: '122',
99 | children: [
100 | {
101 | name: '三级节点-21',
102 | id: '1221',
103 | },
104 | {
105 | name: '三级节点-22',
106 | id: '1222',
107 | },
108 | {
109 | name: '三级节点-23',
110 | id: '1223',
111 | },
112 | {
113 | name: '三级节点-24',
114 | id: '1224',
115 | },
116 | ],
117 | },
118 | ],
119 | },
120 | ],
121 | };
122 |
123 |
--------------------------------------------------------------------------------
/docs/5-data.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: data
3 | zhName: 数据格式
4 | sort: 5
5 | ---
6 |
7 | # 数据格式
8 |
9 | ## 什么是数据列
10 |
11 | 数据列是一组数据集合,例如一条线,一组柱形等。图表中所有点的数据都来自数据列对象,数据列的基本构造是:
12 |
13 | ```javascript
14 | [
15 | {
16 | name: '',
17 | data: [],
18 | },
19 | ];
20 | ```
21 |
22 | 提示:数据列配置是个数组,根据数组中的数据列数量,展示不同类型的图。
23 |
24 | ## 数据列中的属性
25 |
26 | | 属性名称 | 说明 | 类型 | 必填项 |
27 | | --- | --- | --- | --- |
28 | | name | 数据列的名字,并且会显示在提示框(Tooltip)及图例(Legend)中 | String | YES |
29 | | data | 该数据列的数据,是个二维数据 | Array | YES |
30 | | yAxis | 对于需要展示双轴的情况下,需要指定该数据列使用的坐标轴,0:左Y,1:右Y | Number | NO |
31 | | type | 针对混合图,需要制定数据列展示对应图的形态 | String | NO |
32 | | color | 自定义该数据列的对应图的颜色 | String | NO |
33 | | dodge | 对数据列进行分组, 分组堆叠柱状图会用到 | String | NO |
34 |
35 | ## 基础数据格式
36 |
37 | ```javascript
38 | const data = [{ name, data }, { name, data }];
39 | ```
40 |
41 | #### 普通的柱状图数据如下:
42 |
43 | ```javascript
44 | const data = [
45 | {
46 | name: '2018',
47 | data: [['亚洲', 59], ['欧洲', 13], ['美洲', 19], ['中东', 7], ['南非', 7]],
48 | },
49 | ];
50 | ```
51 |
52 | #### 分组柱状图数据格式如下:
53 |
54 | ```javascript
55 | const data = [
56 | {
57 | name: '2018',
58 | data: [['亚洲', 59], ['欧洲', 13], ['美洲', 19], ['中东', 7], ['南非', 7]],
59 | },
60 | {
61 | name: '2019',
62 | data: [['亚洲', 69], ['欧洲', 18], ['美洲', 10], ['中东', 17], ['南非', 20]],
63 | },
64 | ];
65 | ```
66 |
67 | #### 给分组的柱状图指定不同的颜色
68 |
69 | ```javascript
70 | const data = [
71 | {
72 | name: '2018',
73 | color: '#ff0000',
74 | data: [['亚洲', 59], ['欧洲', 13], ['美洲', 19], ['中东', 7], ['南非', 7]],
75 | },
76 | {
77 | name: '2019',
78 | color: '#00ff00',
79 | data: [['亚洲', 69], ['欧洲', 18], ['美洲', 10], ['中东', 17], ['南非', 20]],
80 | },
81 | ];
82 | ```
83 |
84 | - 指定`color`字段, 可以给当前分组的图形设置颜色
85 |
86 | #### 多个坐标轴设置
87 | ```javascript
88 | let data = [
89 | {
90 | name: '产品A',
91 | yAxis: 0,
92 | data: [
93 | ['2018-10', 5],
94 | ['2018-11', 6],
95 | ['2018-12', 2],
96 | ['2019-01', 11],
97 | ['2019-02', 12],
98 | ],
99 | },
100 | {
101 | name: '增长率',
102 | yAxis: 1,
103 | data: [
104 | ['2018-10', 95.97],
105 | ['2018-11', 47.88],
106 | ['2018-12', 20.85],
107 | ['2019-01', 49.2],
108 | ['2019-02', 29.65],
109 | ],
110 | },
111 | ];
112 | ```
113 |
114 | - 通过指定坐标轴上的`yAxis`为数据指定Y坐标轴
115 |
116 | #### 混合图指定图类型
117 | ```javascript
118 | let data = [
119 | {
120 | name: '产品A',
121 | yAxis: 0,
122 | type: 'bar',
123 | data: [
124 | ['2018-10', 5],
125 | ['2018-11', 6],
126 | ['2018-12', 2],
127 | ['2019-01', 11],
128 | ['2019-02', 12],
129 | ],
130 | },
131 | {
132 | name: '增长率',
133 | yAxis: 1,
134 | type: 'line',
135 | data: [
136 | ['2018-10', 95.97],
137 | ['2018-11', 47.88],
138 | ['2018-12', 20.85],
139 | ['2019-01', 49.2],
140 | ['2019-02', 29.65],
141 | ],
142 | },
143 | ];
144 | ```
145 |
146 | - 通过设置`type` 字段指定当前分组的展示类型, 目前只支持`bar`, `line`
147 |
--------------------------------------------------------------------------------
/packages/console-funnel-chart/src/index.ts:
--------------------------------------------------------------------------------
1 | import {
2 | g2Tooltip,
3 | g2Factory,
4 | getConsoleConfig,
5 | Utils,
6 | Constants,
7 | dataAdapter,
8 | g2Style,
9 | g2Guide,
10 | g2Label,
11 | g2Size,
12 | } from '@alicloud/console-shared-utils';
13 |
14 | const COMPONENT_NAME = 'ConsoleFunnelChart';
15 |
16 | const cfg = {
17 | getUnifiedProps(props) {
18 | const { config } = props;
19 | const defaultConfig = getConsoleConfig()[COMPONENT_NAME];
20 | const newConfig = Utils.merge({}, defaultConfig, config);
21 | if (newConfig.pyramid) {
22 | newConfig.align = 'center';
23 | }
24 | const unionProps = Object.assign({}, props, {
25 | padding: props.padding || newConfig.padding || 'auto',
26 | config: newConfig,
27 | });
28 | return unionProps;
29 | },
30 |
31 | drawChart(chart, config, data) {
32 | // 设置数据度量
33 | const defs = {
34 | type: {
35 | type: 'cat',
36 | },
37 | };
38 | const adaptData = dataAdapter(data, config);
39 | chart.source(adaptData, defs);
40 | chart.axis(false);
41 |
42 | // 设置图例
43 | chart.legend(config.legend);
44 |
45 | g2Tooltip(chart, config, config.tooltip, {
46 | showTitle: false,
47 | crosshairs: null,
48 | });
49 |
50 | // 绘制辅助线,辅助背景区域
51 | g2Guide(chart, config, config.guide);
52 |
53 | const { direction = 'vertical', align = 'center' } = config;
54 | // 根据传入的 direction 和 align 设置坐标系,并绘制图形
55 | const drawType = `${direction}-${align}`;
56 | let geom = null;
57 |
58 | switch (drawType) {
59 | case 'vertical-left':
60 | chart
61 | .coord('rect')
62 | .transpose()
63 | .scale(1, -1);
64 | geom = chart.interval();
65 | break;
66 | case 'vertical-center':
67 | chart
68 | .coord('rect')
69 | .transpose()
70 | .scale(1, -1);
71 | geom = chart.intervalSymmetric();
72 | break;
73 | case 'vertical-right':
74 | chart
75 | .coord('rect')
76 | .transpose()
77 | .scale(-1, -1);
78 | geom = chart.interval();
79 | break;
80 | case 'horizontal-top':
81 | chart.coord('rect').reflect('y');
82 | geom = chart.interval();
83 | break;
84 | case 'horizontal-center':
85 | geom = chart.intervalSymmetric();
86 | break;
87 | default:
88 | geom = chart.interval();
89 | }
90 |
91 | const funnelShape = config.align === 'center' && config.pyramid ? 'pyramid' : 'funnel';
92 |
93 | const colors = config.colors || Utils.get(this, 'consoleTheme.colors_24') || Constants.COLORS_24;
94 |
95 | geom
96 | .position('x*y')
97 | .shape(funnelShape)
98 | .color('x', colors);
99 |
100 | g2Label(geom, config, config.label);
101 | g2Size(geom, config, config.size);
102 | g2Style(geom, config, config.style);
103 | chart.render();
104 | },
105 | };
106 |
107 | const ConsoleFunnelChart: any = g2Factory(COMPONENT_NAME, cfg);
108 |
109 | export default ConsoleFunnelChart;
110 |
--------------------------------------------------------------------------------
/packages/console-dot-chart/src/index.ts:
--------------------------------------------------------------------------------
1 | import {
2 | propertyAssign,
3 | propertyMap,
4 | axisX,
5 | axisY,
6 | rectAutoTickCount,
7 | g2Tooltip,
8 | g2Factory,
9 | g2Guide,
10 | g2Label,
11 | g2Legend,
12 | g2Size,
13 | g2Style,
14 | getConsoleConfig,
15 | Utils,
16 | getFinalGeomColors,
17 | dataAdapter,
18 | } from '@alicloud/console-shared-utils';
19 |
20 | const COMPONENT_NAME = 'ConsoleDotChart';
21 |
22 | const cfg = {
23 | getUnifiedProps(props) {
24 | const { config } = props;
25 | const defaultConfig = getConsoleConfig()[COMPONENT_NAME];
26 | const newConfig = Utils.merge({}, defaultConfig, config);
27 | if (newConfig.jitter) {
28 | newConfig.xAxis = Object.assign({}, newConfig.xAxis, { type: 'cat' });
29 | }
30 | const unionProps = Object.assign({}, props, {
31 | config: newConfig,
32 | padding: props.padding || newConfig.padding || 'auto',
33 | });
34 | return unionProps;
35 | },
36 |
37 | drawChart(chart, userConfig, data) {
38 | const config = userConfig;
39 | const { jitter, geomStyle } = config;
40 |
41 | const colors = getFinalGeomColors(data, this.consoleTheme);
42 |
43 | const defs: any = {
44 | x: propertyAssign(
45 | propertyMap.xAxis,
46 | {
47 | type: 'cat',
48 | },
49 | config.xAxis
50 | ),
51 | type: {
52 | type: 'cat',
53 | },
54 | };
55 |
56 | defs.y = propertyAssign(
57 | propertyMap.yAxis,
58 | {
59 | type: 'linear',
60 | tickCount: 5,
61 | },
62 | config.yAxis
63 | );
64 |
65 | rectAutoTickCount(chart, config, defs, false);
66 |
67 | const adaptData = dataAdapter(data, config);
68 |
69 | chart.source(adaptData, defs);
70 |
71 | // 设置X轴
72 | const xAxis: any = {};
73 |
74 | if (config.jitter) {
75 | xAxis.grid = {
76 | align: 'center', // 网格顶点从两个刻度中间开始
77 | lineStyle: {
78 | lineWidth: 1,
79 | },
80 | };
81 | }
82 |
83 | // 扰动点图不能打开垂直网格线
84 | if (config.grid && !config.jitter) {
85 | xAxis.grid = {
86 | lineStyle: {
87 | lineWidth: 1,
88 | },
89 | };
90 | }
91 |
92 | axisX(chart, config, xAxis);
93 |
94 | // 设置单个Y轴
95 | axisY(chart, config);
96 |
97 | g2Tooltip(chart, config, config.tooltip, { crosshair: false });
98 |
99 | g2Legend(chart, config, config.legend, 'type');
100 | g2Guide(chart, config, config.guide);
101 |
102 | const geom = chart
103 | .point()
104 | .color('type', colors)
105 | .position('x*y')
106 | .shape('circle')
107 | .style('x*y*type*extra', geomStyle || {})
108 | .active(false);
109 |
110 | if (jitter) {
111 | geom.adjust('jitter');
112 | }
113 |
114 | g2Label(geom, config, config.label);
115 | g2Size(geom, config, config.size, 'type', 'type');
116 | g2Style(geom, config, config.style);
117 |
118 | chart.render();
119 | },
120 | };
121 |
122 | const ConsolePointChart: any = g2Factory(COMPONENT_NAME, cfg);
123 | export default ConsolePointChart;
124 |
--------------------------------------------------------------------------------
/packages/console-line-chart/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: console-line-chart
3 | zhName: 折线图
4 | ---
5 |
6 | # 线图API
7 |
8 | # 引入方式
9 |
10 | ```javascript
11 | import { ConsoleLineChart } from '@alicloud/console-chart';
12 | ```
13 |
14 | # 示例 Demo
15 |
16 | ## 基本折线图
17 |
18 | [MDXInstruction:importDemo:Basic](./demo/Basic.tsx)
19 |
20 | ## 多组数据
21 |
22 | [MDXInstruction:importDemo:Multi](./demo/Multi.tsx)
23 |
24 | ## 自定义X轴label
25 |
26 | [MDXInstruction:importDemo:XLabel](./demo/XLabel.tsx)
27 |
28 | ## 只有一个点数据时展示线
29 |
30 | [MDXInstruction:importDemo:OneDotToLine](./demo/OneDotToLine.tsx)
31 |
32 | ## 自定义x轴时间刻度间距
33 |
34 | 通过传入`tickInterval`字段,来配置坐标轴上每个刻度之间的差值大小。注意:如果是`type`设置为`time`的话,`tickInterval`字段的值必须是时间戳(毫秒)。
35 |
36 | [MDXInstruction:importDemo:XAxisTickInterval](./demo/XAxisTickInterval.tsx)
37 |
38 | ## 动态显示X轴
39 |
40 | [MDXInstruction:importDemo:XAxisAsync](./demo/XAxisAsync.tsx)
41 |
42 | ## y轴最小值与正整数
43 | 通过设置`yAxis.min`来设置坐标轴显示的最小值,通过`yAxis.formatter`来控制不显示浮点数。
44 |
45 | [MDXInstruction:importDemo:YAxisMin](./demo/YAxisMin.tsx)
46 |
47 | ## 设置双轴
48 |
49 | [MDXInstruction:importDemo:DoubleAxis](./demo/DoubleAxis.tsx)
50 |
51 | ## 配置顶部单位
52 |
53 | [MDXInstruction:importDemo:Unit](./demo/Unit.tsx)
54 |
55 | ## 设置光滑曲线
56 |
57 | [MDXInstruction:importDemo:Smooth](./demo/Smooth.tsx)
58 |
59 | ## 线条带点
60 |
61 | [MDXInstruction:importDemo:Dot](./demo/Dot.tsx)
62 |
63 | ## 面积堆栈图
64 |
65 | [MDXInstruction:importDemo:Stack](./demo/Stack.tsx)
66 |
67 | ## 颜色渐变图
68 |
69 | 通过数据列里的`color`属性来进行指定,如果传入的值为字符串,则将该颜色应用到该数据列的`线图`和`面积图`上,也可以传入一个数组,第一个值指定`线图`的颜色,第二个值指定`面积图`的颜色
70 |
71 | 颜色色值支持传入渐变,渐变规则请看[G2渐变色原始文档](https://g2-v3.antv.vision/zh/docs/api/graphics#%E6%B8%90%E5%8F%98%E8%89%B2)
72 |
73 | [MDXInstruction:importDemo:GradualColor](./demo/GradualColor.tsx)
74 |
75 | ## Legend点击事件
76 |
77 | 通过`event`属性来配置事件,配置`legend-item:click`对应的事件即可以配置图例点击事件。注意,由于内部实现和React自带的Function Component优化有冲突,`event`属性配置的事件不会触发`function component`的更新,所以这时候请使用`class`语法。
78 |
79 | 更多事件请看[G2-图表事件](https://g2-v3.antv.vision/zh/docs/manual/tutorial/event)
80 |
81 | [MDXInstruction:importDemo:LegendClick](./demo/LegendClick.tsx)
82 |
83 | # Config 配置
84 |
85 | # 数据列配置
86 |
87 | | 属性 | 说明 | 类型 | 默认值 |
88 | | --- | --- | --- | --- |
89 | | name | 数据列名称 | String | - |
90 | | yAxis | 坐标轴下标 | Number | 0 |
91 | | data | 数据 | Array | - |
92 | | color | 自定义当前数据列颜色 | String | 主题`color_24` |
93 |
94 | ## 通用配置
95 | | 属性 | 说明 |
96 | | --- | --- |
97 | | padding | 配置绘图内边距 |
98 | | xAxis | 配置x轴 |
99 | | yAxis | 配置y轴 |
100 | | legend | 配置图例 |
101 | | guide | 配置辅助元素 |
102 | | tooltip | 配置提示信息 |
103 | | label | 配置图形文本 |
104 | | size | 配置自定义大小 |
105 | | style | 配置自定义样式 |
106 |
107 | ## 专属配置
108 |
109 | ### grid: Boolean
110 | 是否显示网格线
111 |
112 | ### smooth: Boolean
113 | 是否为圆滑曲线图
114 |
115 | ### lineSize: Number
116 | 配置线的宽度,优先级`config.lineSize` > `config.size`
117 |
118 | ### symbol: Boolean
119 | 线上是否同时存在数据点标记。
120 |
121 | ### symbolSize:
122 | 当`symbol`开启时,配置线上点的`size`, 优先级`config.symbolSize` > `config.size`
123 |
124 | ### area: Boolean
125 | 是否开启面积图
126 |
127 | ### stack: Boolean
128 | 当开启 `area` 时,是否显示堆叠面积图。
129 |
130 | ### yAxisColor: Boolean
131 | 是否开启坐标轴颜色。
132 |
--------------------------------------------------------------------------------
/packages/console-combo-chart/demo/Color.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConsoleComboChart } from '@alicloud/console-chart';
3 |
4 | const data = [
5 | {
6 | name: '使用',
7 | type: 'bar',
8 | color: '#2196F3',
9 | yAxis: 0,
10 | data: [
11 | ['ecs', 1892],
12 | ['disk', 7292],
13 | ['ess', 5714],
14 | ['acs', 5354],
15 | ['batchcompute', 2014],
16 | ['ros', 22],
17 | ['fc', 11023],
18 | ['swas', 5218],
19 | ['ehpc', 8759],
20 | ['ecsgpu', 9981],
21 | ['acr', 4533],
22 | ['xdragon', 11398],
23 | ['scc', 1064],
24 | ['ddh', 6494],
25 | ],
26 | },
27 | {
28 | name: '续费',
29 | type: 'bar',
30 | color: '#2FC25B',
31 | yAxis: 0,
32 | data: [
33 | ['ecs', 1892],
34 | ['disk', 7292],
35 | ['ess', 5714],
36 | ['acs', 5354],
37 | ['batchcompute', 2014],
38 | ['ros', 22],
39 | ['fc', 11023],
40 | ['swas', 5218],
41 | ['ehpc', 8759],
42 | ['ecsgpu', 9981],
43 | ['acr', 4533],
44 | ['xdragon', 11398],
45 | ['scc', 1064],
46 | ['ddh', 6494],
47 | ],
48 | },
49 | {
50 | name: '更换',
51 | type: 'bar',
52 | yAxis: 0,
53 | color: '#FACC14',
54 | data: [
55 | ['ecs', 1892],
56 | ['disk', 7292],
57 | ['ess', 5714],
58 | ['acs', 5354],
59 | ['batchcompute', 2014],
60 | ['ros', 22],
61 | ['fc', 11023],
62 | ['swas', 5218],
63 | ['ehpc', 8759],
64 | ['ecsgpu', 9981],
65 | ['acr', 4533],
66 | ['xdragon', 11398],
67 | ['scc', 1064],
68 | ['ddh', 6494],
69 | ],
70 | },
71 | {
72 | name: '使用增长率',
73 | type: 'line',
74 | yAxis: 1,
75 | color: '#41D9C7',
76 | data: [
77 | ['ecs', 18.92],
78 | ['disk', 72.92],
79 | ['ess', 57.14],
80 | ['acs', 53.54],
81 | ['batchcompute', 20.14],
82 | ['ros', 22],
83 | ['fc', 110.23],
84 | ['swas', 52.18],
85 | ['ehpc', 87.59],
86 | ['ecsgpu', 99.81],
87 | ['acr', 45.33],
88 | ['xdragon', 113.98],
89 | ['scc', 10.64],
90 | ['ddh', 64.94],
91 | ],
92 | },
93 | {
94 | name: '使用增长环比',
95 | type: 'line',
96 | yAxis: 1,
97 | color: '#E6965C',
98 | data: [
99 | ['ecs', 28.92],
100 | ['disk', 32.92],
101 | ['ess', 37.14],
102 | ['acs', 33.54],
103 | ['batchcompute', 20.14],
104 | ['ros', 22],
105 | ['fc', 30.23],
106 | ['swas', 33.18],
107 | ['ehpc', 37.59],
108 | ['ecsgpu', 39.81],
109 | ['acr', 35.33],
110 | ['xdragon', 30.98],
111 | ['scc', 30.64],
112 | ['ddh', 34.94],
113 | ],
114 | },
115 | ];
116 |
117 | const config = {
118 | padding: [40, 52, 45, 60],
119 | xAxis: {
120 | type: 'cat',
121 | tickCount: 5,
122 | },
123 | yAxis: [
124 | {},
125 | {
126 | labelFormatter: val => val + '%',
127 | },
128 | ],
129 | stack: true,
130 | yAxisColor: true,
131 | };
132 |
133 | export default () => (
134 |
135 | );
136 |
--------------------------------------------------------------------------------
/packages/console-shared-utils/src/g2Helper/dataAdapter.ts:
--------------------------------------------------------------------------------
1 | import { isNumeric } from '../common/utils';
2 |
3 | const yValue = val => (isNumeric(val) ? +val : null);
4 |
5 | function dataAdapter(data: any, config: any) {
6 | if (!data) {
7 | return [];
8 | }
9 | if (!Array.isArray(data)) {
10 | data = [data];
11 | }
12 | const newData: any[] = [];
13 | if (Array.isArray(config.yAxis)) {
14 | data.forEach((oneData: any) => {
15 | if (!oneData || !Array.isArray(oneData.data)) {
16 | return;
17 | }
18 |
19 | const { name: dataName, yAxis: yIndex = 0, visible, ...groupExtra } = oneData;
20 |
21 | oneData.data.forEach((d: any, i: number) => {
22 | if (Array.isArray(d)) {
23 | const [x, y, ...extra] = d;
24 | newData.push({
25 | x,
26 | [`y${yIndex}`]: yValue(y),
27 | extra,
28 | groupExtra,
29 | visible,
30 | type: dataName,
31 | });
32 | } else if (config.xAxis && config.xAxis.categories && config.xAxis.categories[i]) {
33 | const x = config.xAxis.categories[i];
34 | const y = isNaN(d) ? d[0] : d;
35 | newData.push({
36 | x,
37 | [`y${yIndex}`]: yValue(y),
38 | extra: [],
39 | groupExtra,
40 | visible,
41 | type: dataName,
42 | });
43 | } else {
44 | const { x, y, ...extra } = d;
45 | newData.push({
46 | x,
47 | [`y${yIndex}`]: yValue(y),
48 | extra,
49 | groupExtra,
50 | visible,
51 | type: dataName,
52 | });
53 | }
54 | });
55 | });
56 | } else {
57 | data.forEach((oneData: any) => {
58 | if (!oneData || !Array.isArray(oneData.data)) {
59 | return;
60 | }
61 |
62 | const { name: dataName, facet, dodge, visible, ...groupExtra } = oneData;
63 |
64 | oneData.data.forEach((d: any, i: number) => {
65 | if (Array.isArray(d)) {
66 | const [x, y, ...extra] = d;
67 | newData.push({
68 | x,
69 | y: yValue(y),
70 | extra,
71 | groupExtra,
72 | facet,
73 | dodge,
74 | visible,
75 | type: dataName,
76 | });
77 | } else if (config.xAxis && config.xAxis.categories && config.xAxis.categories[i]) {
78 | const x = config.xAxis.categories[i];
79 | const y = isNaN(d) ? d[0] : d;
80 | newData.push({
81 | x,
82 | y: yValue(y),
83 | extra: [],
84 | groupExtra,
85 | facet,
86 | dodge,
87 | visible,
88 | type: dataName,
89 | });
90 | } else {
91 | const { x, y, ...extra } = d;
92 | newData.push({
93 | x,
94 | y: yValue(y),
95 | extra,
96 | groupExtra,
97 | facet,
98 | dodge,
99 | visible,
100 | type: dataName,
101 | });
102 | }
103 | });
104 | });
105 | }
106 | return newData;
107 | }
108 |
109 | export default dataAdapter;
110 |
--------------------------------------------------------------------------------