Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo: add horizontal funnel demmo to charthub page #61

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
215 changes: 186 additions & 29 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/vchart-arco-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"react-router-dom": "^5.2.0",
"react-device-detect": "^2.2.2",
"redux": "^4.1.2",
"@visactor/vchart": "1.11.0",
"@visactor/vchart": "1.11.6",
"@visactor/react-vchart": "1.11.0",
"@arco-design/webpack-plugin": "^1.6.0",
"@arco-plugins/vite-plugin-svgr": "^0.7.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart-semi-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"vite": "^4.5.0",
"vite-plugin-svgr": "^4.1.0",
"@babel/runtime": "latest",
"@visactor/vchart": "1.11.0",
"@visactor/vchart": "1.11.6",
"@visactor/react-vchart": "1.11.0",
"@douyinfe/semi-ui": "^2.51.3",
"@douyinfe/semi-icons": "latest",
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart-theme-demo-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@arco-design/web-react": "^2.32.2",
"@visactor/vchart-theme-utils": "workspace:1.11.5",
"@visactor/vchart-theme": "workspace:1.11.5",
"@visactor/vchart": "1.11.0",
"@visactor/vchart": "1.11.6",
"@visactor/react-vchart": "1.11.0"
},
"peerDependencies": {
Expand Down
135 changes: 135 additions & 0 deletions packages/vchart-theme-demo-component/src/spec/funnelHorizontal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
export const horizontalFunnelSpec = {
type: 'common',
padding: { left: 20, right: 60 },
data: [
{
id: 'funnel',
values: [
{
value: 100,
name: 'Screening',
percent: 1
},
{
value: 80,
name: 'Evaluating',
percent: 0.8
},
{
value: 50,
name: 'Passed',
percent: 0.5
},
{
value: 30,
name: 'Interview',
percent: 0.3
}
]
}
],
color: {
type: 'ordinal',
range: ['rgb(54,106,253)', 'rgb(103,138,251)', 'rgb(146,173,255)', 'rgb(191,207,255)']
},
series: [
{
type: 'funnel',
categoryField: 'name',
valueField: 'value',
maxSize: '50%',
minSize: '10%',
funnelAlign: 'bottom',
funnelOrient: 'left',
isTransform: true,
shape: 'rect',
transform: {
style: {
fill: 'rgb(222,231,253)'
}
},
label: {
visible: true,
style: {
lineHeight: 16,
limit: (datum, ctx) => Math.abs(ctx.getPoints(datum)[0].x - ctx.getPoints(datum)[3].x),
text: datum => `${datum.percent * 100}%`,
x: (datum, ctx) => ctx.getPoints(datum)[0].x + 10,
y: (datum, ctx) => ctx.getPoints(datum)[0].y - 10,
textAlign: 'left',
textBaseline: 'bottom',
fontSize: 20,
fontStyle: 'italic'
}
},
extensionMark: [
{
type: 'polygon',
dataId: 'funnel',
style: {
points: (datum, ctx) => {
const start = ctx.getPoints(datum)[1];
const end = { x: start.x, y: 0 };
return [start, end];
},
closePath: false,
lineWidth: 2,
stroke: 'rgb(243,244,244)'
}
},
{
type: 'text',
dataId: 'funnel',
style: {
text: (datum, ctx) => {
return {
type: 'rich',
text: [
{ text: `${datum.name}\n`, fontWeight: 'bold', lineHeight: 30 },
{
text: `${datum.value / 10}K\n`,
fontWeight: 'bold',
fontSize: 24,
lineHeight: 40,
fill: 'black'
},
{
text: `Percent: ${datum.percent * 10}%`,
fontWeight: 'bold',
lineHeight: 30
}
]
};
},
x: (datum, ctx) => ctx.getPoints(datum)[0].x + 10,
width: (datum, ctx) => {
return ctx.getPoints(datum)[3].x - ctx.getPoints(datum)[0].x;
},
textAlign: 'left',
y: 10,
stroke: false,
fill: 'grey',
ellipsis: true,
disableAutoWrapLine: true
}
},
{
type: 'image',
dataId: 'funnel',
style: {
image:
'https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/visactor-site/sg/client/img/visactor/vrender-icon.svg',
x: (datum, ctx) =>
ctx.getPoints(datum)[2].x + (ctx.getPoints(datum)[2].x - ctx.getPoints(datum)[1].x) * 0.5 - 36,
y: 10,
align: 'right',
width: 30,
height: 26,
background: 'rgb(238,238,238)',
fillOpacity: 0.2
}
}
]
}
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { barGroupSpec } from '../spec/barGroup';
import { barGroupHorizontalSpec } from '../spec/barGroupHorizontal';
import { barStackedSpec } from '../spec/barStacked';
import { barStackedHorizontalSpec } from '../spec/barStackedHorizontal';
import { horizontalFunnelSpec } from '../spec/funnelHorizontal';
import { gaugeSpec } from '../spec/gauge';
import { horizontalBarSpec } from '../spec/horizontalBar';
import { indicatorSankeySpec } from '../spec/indicatorSankey';
Expand Down Expand Up @@ -37,7 +38,7 @@ export const charts: IChartInfo[] = [
{
title: 'Horizontal Grouped Bar Chart',
spec: barGroupHorizontalSpec,
fileName: 'horizontalBar'
fileName: 'barGroupHorizontal'
},
{
title: 'Horizontal Stacked Bar Chart',
Expand Down Expand Up @@ -81,5 +82,10 @@ export const charts: IChartInfo[] = [
option: {
enableHtmlAttribute: true
}
},
{
title: 'Horizontal Funnel',
spec: horizontalFunnelSpec,
fileName: 'funnelHorizontal'
}
];
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useCallback } from 'react';
import { isMobile } from 'react-device-detect';
import { charts } from './chart-list';
import { VChart as VChartComponent } from '@visactor/react-vchart';
import { VChart as VChartComponent, VChartCore } from '@visactor/react-vchart';
import { i18n } from './i18n';
import VChart from '@visactor/vchart';
import { chartHubLightTheme } from '@visactor/vchart-theme';

import { Button, Card } from '@douyinfe/semi-ui';
Expand All @@ -19,8 +18,8 @@ const gutter = 16;
const DEMO_SOURCE_PREFIX =
'https://raw.githubusercontent.com/VisActor/vchart-theme/develop/packages/vchart-theme-demo-component/src/spec/';

VChart.ThemeManager.registerTheme('chart-hub-light', chartHubLightTheme);
VChart.ThemeManager.setCurrentTheme('chart-hub-light');
VChartCore.ThemeManager.registerTheme('chart-hub-light', chartHubLightTheme as any);
VChartCore.ThemeManager.setCurrentTheme('chart-hub-light');

export interface IProps {
language?: 'en' | 'zh';
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart-theme-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"ts-jest": "~29.1.0",
"@types/jest": "~29.5.0",
"@rushstack/eslint-patch": "~1.1.4",
"@visactor/vchart": "1.11.0",
"@visactor/vchart": "1.11.6",
"@visactor/vchart-types": "1.11.0",
"eslint": "~8.18.0",
"vite": "^4.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"ts-jest": "~29.1.0",
"@types/jest": "~29.5.0",
"@rushstack/eslint-patch": "~1.1.4",
"@visactor/vchart": "1.11.0",
"@visactor/vchart": "1.11.6",
"@visactor/vchart-types": "1.11.0",
"eslint": "~8.18.0",
"vite": "^4.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart-tt-platform-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"vite-plugin-svgr": "^4.1.0",
"node-sass": "^9.0.0",
"@babel/runtime": "latest",
"@visactor/vchart": "1.11.0",
"@visactor/vchart": "1.11.6",
"@visactor/react-vchart": "1.11.0",
"@douyinfe/semi-ui": "^2.51.3",
"@douyinfe/semi-icons": "latest",
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart-ve-o-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"react-redux": "^7.2.6",
"react-device-detect": "^2.2.2",
"redux": "^4.1.2",
"@visactor/vchart": "1.11.0",
"@visactor/vchart": "1.11.6",
"@visactor/react-vchart": "1.11.0",
"@arco-design/webpack-plugin": "^1.6.0",
"@arco-plugins/vite-plugin-svgr": "^0.7.2",
Expand Down
2 changes: 1 addition & 1 deletion share/chart-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@visactor/vchart": ">=1.10.4"
},
"devDependencies": {
"@visactor/vchart": "1.11.0",
"@visactor/vchart": "1.11.6",
"@visactor/vchart-types": "1.11.0",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
Expand Down
Loading