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

improve(style): Remove fixed barWidth for Bar and columnWidth for Column & TinyColumn & DualAxes #558

Merged
merged 2 commits into from
Apr 12, 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
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@
"@babel/cli": "^7.24.1",
"@babel/preset-env": "^7.24.4",
"@chenshuai2144/less2cssinjs": "^1.0.7",
"@ctrl/tinycolor": "^4.0.4",
"@ctrl/tinycolor": "^4.0.3",
"@emotion/babel-preset-css-prop": "^11.11.0",
"@emotion/css": "^11.11.2",
"@emotion/react": "^11.11.4",
"@emotion/server": "^11.11.0",
"@qixian.cs/github-contributors-list": "^2.0.1",
"@rc-component/trigger": "^2.1.1",
"@rc-component/trigger": "^2.0.0",
"@stackblitz/sdk": "^1.9.0",
"@testing-library/dom": "^9.3.4",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.3.0",
"@testing-library/react": "^14.2.2",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/lodash": "^4.17.0",
"@types/node": "^20.12.7",
"@types/react": "^18.2.77",
"@types/node": "^20.12.5",
"@types/react": "^18.2.74",
"@umijs/fabric": "^4.0.1",
"@umijs/test": "^4.1.9",
"@umijs/test": "^4.1.8",
"@vercel/analytics": "^1.2.2",
"antd": "^5.16.1",
"antd-style": "^3.6.2",
Expand Down Expand Up @@ -111,9 +111,9 @@
"react-router-dom": "^6.22.3",
"runscript": "^1.6.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typescript": "^5.4.4",
"vanilla-jsoneditor": "^0.23.1",
"vitest": "^1.4.0",
"vitest": "^1.5.0",
"vitest-canvas-mock": "^0.3.3",
"vitest-fetch-mock": "^0.2.2",
"web-vitals": "^3.5.2"
Expand Down
13 changes: 2 additions & 11 deletions packages/charts/src/Bar/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { Bar } from '@oceanbase/charts';
import type { BarConfig } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';

export default () => {
const data = [
Expand Down Expand Up @@ -34,14 +33,6 @@ export default () => {
position: 'top-left',
},
};
return (
<Row gutter={200}>
<Col span={12}>
<Bar height={200} {...config} />
</Col>
<Col span={12}>
<Bar height={200} {...config} data={data.slice(0, 2)} />
</Col>
</Row>
);

return <Bar {...config} />;
};
21 changes: 5 additions & 16 deletions packages/charts/src/Bar/demo/group.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Bar } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';
import type { BarConfig } from '@oceanbase/charts';

export default () => {
const data = [
Expand Down Expand Up @@ -55,24 +55,13 @@ export default () => {
value: 100,
},
];
const config = {
const config: BarConfig = {
data,
isGroup: true,
xField: 'value',
yField: 'label',
seriesField: 'type',
};
return (
<Row gutter={200}>
<Col span={12}>
<Bar height={250} data={data} {...config} />
</Col>
<Col span={12}>
<Bar
height={250}
data={data.filter(item => ['Mon.', 'Tues.'].includes(item.label))}
{...config}
/>
</Col>
</Row>
);

return <Bar {...config} />;
};
20 changes: 4 additions & 16 deletions packages/charts/src/Bar/demo/percent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Bar } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';
import type { BarConfig } from '@oceanbase/charts';

export default () => {
const data = [
Expand Down Expand Up @@ -110,25 +110,13 @@ export default () => {
value: 628,
},
];
const config = {
const config: BarConfig = {
data,
xField: 'value',
yField: 'year',
seriesField: 'country',
isPercent: true,
isStack: true,
};
return (
<Row gutter={200}>
<Col span={12}>
<Bar height={200} data={data} {...config} />
</Col>
<Col span={12}>
<Bar
height={200}
data={data.filter(item => ['1750', '1800'].includes(item.year))}
{...config}
/>
</Col>
</Row>
);
return <Bar data={data} {...config} />;
};
3 changes: 1 addition & 2 deletions packages/charts/src/Bar/demo/progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ export default () => {
},
];
const config1 = {
isProgress: true,
xField: 'value',
yField: 'type',
isProgress: true,

meta: {
value: {
alias: '比赛进度',
Expand Down
20 changes: 4 additions & 16 deletions packages/charts/src/Bar/demo/range.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Bar } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';
import type { BarConfig } from '@oceanbase/charts';

export default () => {
const data = [
Expand Down Expand Up @@ -37,23 +37,11 @@ export default () => {
values: [18, 34],
},
];
const config = {
const config: BarConfig = {
data,
xField: 'values',
yField: 'type',
isRange: true,
};
return (
<Row gutter={200}>
<Col span={12}>
<Bar height={200} data={data} {...config} />
</Col>
<Col span={12}>
<Bar
height={200}
data={data.filter(item => ['分类一', '分类二'].includes(item.type))}
{...config}
/>
</Col>
</Row>
);
return <Bar {...config} />;
};
20 changes: 4 additions & 16 deletions packages/charts/src/Bar/demo/stack.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Bar } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';
import type { BarConfig } from '@oceanbase/charts';

export default () => {
const data = [
Expand Down Expand Up @@ -80,24 +80,12 @@ export default () => {
type: 'Jon',
},
];
const config = {
const config: BarConfig = {
data,
isStack: true,
xField: 'value',
yField: 'year',
seriesField: 'type',
};
return (
<Row gutter={200}>
<Col span={12}>
<Bar height={200} data={data} {...config} />
</Col>
<Col span={12}>
<Bar
height={200}
data={data.filter(item => ['1991', '1992'].includes(item.year))}
{...config}
/>
</Col>
</Row>
);
return <Bar {...config} />;
};
14 changes: 6 additions & 8 deletions packages/charts/src/Bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const Bar = forwardRef<unknown, BarConfig>(
isPercent,
isRange,
seriesField,
maxBarWidth: themeConfig.barWidth,
minBarWidth: themeConfig.barWidth,
meta: isProgress
? {
...meta,
Expand Down Expand Up @@ -101,12 +99,12 @@ const Bar = forwardRef<unknown, BarConfig>(
isRange
? 2
: !isStack ||
(isStack &&
seriesField &&
// 堆叠条形图仅最后一段末端展示 2px 圆角
datum[seriesField] === lastStackValue)
? [2, 2, 0, 0]
: [],
(isStack &&
seriesField &&
// 堆叠条形图仅最后一段末端展示 2px 圆角
datum[seriesField] === lastStackValue)
? [2, 2, 0, 0]
: [],
};
},
xAxis: {
Expand Down
12 changes: 1 addition & 11 deletions packages/charts/src/Column/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { Column } from '@oceanbase/charts';
import type { ColumnConfig } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';

export default () => {
const data = [
Expand Down Expand Up @@ -47,14 +46,5 @@ export default () => {
position: 'top',
},
};
return (
<Row gutter={200}>
<Col span={12}>
<Column height={200} {...config} />
</Col>
<Col span={12}>
<Column height={200} {...config} data={data.slice(0, 2)} />
</Col>
</Row>
);
return <Column {...config} />;
};
20 changes: 4 additions & 16 deletions packages/charts/src/Column/demo/group.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Column } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';
import type { ColumnConfig } from '@oceanbase/charts';

export default () => {
const data = [
Expand Down Expand Up @@ -55,24 +55,12 @@ export default () => {
value: 100,
},
];
const config = {
const config: ColumnConfig = {
data,
isGroup: true,
xField: 'label',
yField: 'value',
seriesField: 'type',
};
return (
<Row gutter={200}>
<Col span={12}>
<Column height={250} data={data} {...config} />
</Col>
<Col span={12}>
<Column
height={250}
data={data.filter(item => ['Mon.', 'Tues.'].includes(item.label))}
{...config}
/>
</Col>
</Row>
);
return <Column {...config} />;
};
21 changes: 5 additions & 16 deletions packages/charts/src/Column/demo/percent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Column } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';
import type { ColumnConfig } from '@oceanbase/charts';

export default () => {
const data = [
Expand Down Expand Up @@ -110,25 +110,14 @@ export default () => {
value: 628,
},
];
const config = {
const config: ColumnConfig = {
data,
xField: 'year',
yField: 'value',
seriesField: 'country',
isPercent: true,
isStack: true,
};
return (
<Row gutter={200}>
<Col span={12}>
<Column height={250} data={data} {...config} />
</Col>
<Col span={12}>
<Column
height={250}
data={data.filter(item => ['1750', '1800'].includes(item.year))}
{...config}
/>
</Col>
</Row>
);

return <Column {...config} />;
};
21 changes: 5 additions & 16 deletions packages/charts/src/Column/demo/range.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Column } from '@oceanbase/charts';
import { Col, Row } from '@oceanbase/design';
import type { ColumnConfig } from '@oceanbase/charts';

export default () => {
const data = [
Expand Down Expand Up @@ -37,23 +37,12 @@ export default () => {
values: [18, 34],
},
];
const config = {
const config: ColumnConfig = {
data,
xField: 'type',
yField: 'values',
isRange: true,
};
return (
<Row gutter={200}>
<Col span={12}>
<Column height={250} data={data} {...config} />
</Col>
<Col span={12}>
<Column
height={250}
data={data.filter(item => ['分类一', '分类二'].includes(item.type))}
{...config}
/>
</Col>
</Row>
);

return <Column {...config} />;
};
Loading
Loading