style: user rank chart
This commit is contained in:
@@ -9,10 +9,11 @@ import echarts, { ECOption } from '.';
|
|||||||
|
|
||||||
const Chart: React.FC<{
|
const Chart: React.FC<{
|
||||||
options: ECOption;
|
options: ECOption;
|
||||||
|
chartHeight?: number;
|
||||||
height: number | string;
|
height: number | string;
|
||||||
width: number | string;
|
width: number | string;
|
||||||
ref?: any;
|
ref?: any;
|
||||||
}> = forwardRef(({ options, width, height }, ref) => {
|
}> = forwardRef(({ options, width, height, chartHeight }, ref) => {
|
||||||
const container = useRef<HTMLDivElement>(null);
|
const container = useRef<HTMLDivElement>(null);
|
||||||
const chart = useRef<echarts.EChartsType>();
|
const chart = useRef<echarts.EChartsType>();
|
||||||
const resizeable = useRef(false);
|
const resizeable = useRef(false);
|
||||||
@@ -138,7 +139,10 @@ const Chart: React.FC<{
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="chart-wrapper" style={{ width: width, height }}>
|
<div className="chart-wrapper" style={{ width: width, height }}>
|
||||||
<div ref={container} style={{ width: width, height }}></div>
|
<div
|
||||||
|
ref={container}
|
||||||
|
style={{ width: width, height: chartHeight || height }}
|
||||||
|
></div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ export default function useChartConfig() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
token,
|
||||||
tooltip,
|
tooltip,
|
||||||
grid,
|
grid,
|
||||||
legend,
|
legend,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Chart from '@/components/echarts/chart';
|
|||||||
import useChartConfig from '@/components/echarts/config';
|
import useChartConfig from '@/components/echarts/config';
|
||||||
import EmptyData from '@/components/empty-data';
|
import EmptyData from '@/components/empty-data';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { memo, useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { ChartProps } from './types';
|
import { ChartProps } from './types';
|
||||||
|
|
||||||
const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
|
const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
|
||||||
@@ -17,6 +17,7 @@ const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
|
|||||||
title
|
title
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
const {
|
||||||
|
token,
|
||||||
grid,
|
grid,
|
||||||
legend,
|
legend,
|
||||||
title: titleConfig,
|
title: titleConfig,
|
||||||
@@ -44,17 +45,28 @@ const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
|
|||||||
xAxis: {
|
xAxis: {
|
||||||
...xAxis,
|
...xAxis,
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
...xAxis.axisLabel,
|
...xAxis.axisLabel
|
||||||
formatter: labelFormatter
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
...yAxis,
|
...yAxis,
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
...yAxis.axisLabel,
|
...yAxis.axisLabel,
|
||||||
|
show: true,
|
||||||
overflow: 'truncate',
|
overflow: 'truncate',
|
||||||
width: 75,
|
width: 75,
|
||||||
ellipsis: '...'
|
ellipsis: '...',
|
||||||
|
margin: 12,
|
||||||
|
formatter(value: string, index: number) {
|
||||||
|
return `{a|${index + 1}}`;
|
||||||
|
},
|
||||||
|
rich: {
|
||||||
|
a: {
|
||||||
|
fontWeight: 500,
|
||||||
|
fontSize: 14,
|
||||||
|
color: token?.colorTextSecondary
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
@@ -70,9 +82,25 @@ const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
|
|||||||
type: 'bar',
|
type: 'bar',
|
||||||
barWidth: 20,
|
barWidth: 20,
|
||||||
stack: 'Ad',
|
stack: 'Ad',
|
||||||
barGap: '30%',
|
barGap: '20%',
|
||||||
label: {
|
label: {
|
||||||
show: false
|
show: true,
|
||||||
|
formatter(params: any) {
|
||||||
|
if (params.seriesIndex === 0) {
|
||||||
|
return `{value|${params.name}}`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
position: 'left',
|
||||||
|
align: 'left',
|
||||||
|
offset: [5, 18],
|
||||||
|
rich: {
|
||||||
|
value: {
|
||||||
|
textBorderWidth: 0,
|
||||||
|
fontSize: 11,
|
||||||
|
color: token?.colorTextTertiary
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
color: item.color
|
color: item.color
|
||||||
@@ -138,10 +166,14 @@ const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isEmpty ? (
|
{isEmpty ? (
|
||||||
<EmptyData height={height} title={title}></EmptyData>
|
<EmptyData
|
||||||
|
height={height}
|
||||||
|
title={_.get(title, 'text', title || '')}
|
||||||
|
></EmptyData>
|
||||||
) : (
|
) : (
|
||||||
<Chart
|
<Chart
|
||||||
height={height}
|
height={height}
|
||||||
|
chartHeight={typeof height === 'number' ? height - 10 : undefined}
|
||||||
options={dataOptions}
|
options={dataOptions}
|
||||||
width={width || '100%'}
|
width={width || '100%'}
|
||||||
></Chart>
|
></Chart>
|
||||||
@@ -150,4 +182,4 @@ const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(BarChart);
|
export default BarChart;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import useChartConfig from '@/components/echarts/config';
|
|||||||
import EmptyData from '@/components/empty-data';
|
import EmptyData from '@/components/empty-data';
|
||||||
import { genColors } from '@/utils';
|
import { genColors } from '@/utils';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { memo, useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import echarts from '.';
|
import echarts from '.';
|
||||||
import { ChartProps } from './types';
|
import { ChartProps } from './types';
|
||||||
|
|
||||||
@@ -169,4 +169,4 @@ const LineChart: React.FC<ChartProps> = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(LineChart);
|
export default LineChart;
|
||||||
|
|||||||
@@ -158,7 +158,10 @@ const MixLineBarChart: React.FC<
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{!lineSeriesData.length && !barSeriesData.length ? (
|
{!lineSeriesData.length && !barSeriesData.length ? (
|
||||||
<EmptyData height={height} title={title}></EmptyData>
|
<EmptyData
|
||||||
|
height={height}
|
||||||
|
title={_.get(title, 'text', title || '')}
|
||||||
|
></EmptyData>
|
||||||
) : (
|
) : (
|
||||||
<Chart
|
<Chart
|
||||||
height={height}
|
height={height}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ interface TopUserProps {
|
|||||||
const TopUser: React.FC<TopUserProps> = (props) => {
|
const TopUser: React.FC<TopUserProps> = (props) => {
|
||||||
const { userData, topUserList } = props;
|
const { userData, topUserList } = props;
|
||||||
|
|
||||||
|
console.log('TopUser userData:', userData, topUserList);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardWrapper>
|
<CardWrapper>
|
||||||
<HBar
|
<HBar
|
||||||
|
|||||||
Reference in New Issue
Block a user