From dee063f901183fc9c2c9ca2aa43b44a44e039fa8 Mon Sep 17 00:00:00 2001 From: laixingyou Date: Wed, 3 Jan 2024 11:00:28 +0800 Subject: [PATCH] fix: IsMaintained bar to line (#292) Signed-off-by: laixingyou --- .../IsMaintained.tsx | 49 ++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/apps/web/src/modules/analyze/DataView/CollaborationDevelopmentIndex/IsMaintained.tsx b/apps/web/src/modules/analyze/DataView/CollaborationDevelopmentIndex/IsMaintained.tsx index 38bc94dc..3879e737 100644 --- a/apps/web/src/modules/analyze/DataView/CollaborationDevelopmentIndex/IsMaintained.tsx +++ b/apps/web/src/modules/analyze/DataView/CollaborationDevelopmentIndex/IsMaintained.tsx @@ -1,17 +1,10 @@ import React from 'react'; -import { - getBarOption, - bar, - getTooltipsFormatter, - legendFormat, - getColorWithLabel, -} from '@common/options'; +import useGetLineOption from '@modules/analyze/hooks/useGetLineOption'; import { CollaborationDevelopment } from '@modules/analyze/components/SideBar/config'; import BaseCard from '@common/components/BaseCard'; import ChartWithData from '@modules/analyze/components/ChartWithData'; import EChartX from '@common/components/EChartX'; import { useTranslation } from 'next-i18next'; -import { GenChartOptions } from '@modules/analyze/type'; import CardDropDownMenu from '@modules/analyze/components/CardDropDownMenu'; const IsMaintained = () => { @@ -23,29 +16,15 @@ const IsMaintained = () => { yKey: 'metricCodequality.isMaintained', summaryKey: 'summaryCodequality.isMaintained', }; - const getOptions: GenChartOptions = ( - { xAxis, compareLabels, yResults }, - theme - ) => { - const series = yResults.map(({ label, level, data }) => { - const color = getColorWithLabel(theme, label); - return bar({ - name: label, - data: data, - color, - }); - }); - - return getBarOption({ - xAxisData: xAxis, - series, - legend: legendFormat(compareLabels), - tooltip: { - formatter: getTooltipsFormatter({ compareLabels }), - }, - }); - }; - + const { + getOptions, + showAvg, + showMedian, + setShowAvg, + setShowMedian, + yAxisScale, + setYAxisScale, + } = useGetLineOption(); return ( { } headRight={(ref, fullScreen, setFullScreen) => ( { setFullScreen(b); }} + showAvg={showAvg} + onAvgChange={(b) => setShowAvg(b)} + showMedian={showMedian} + onMedianChange={(b) => setShowMedian(b)} + yAxisScale={yAxisScale} + onYAxisScaleChange={(b) => setYAxisScale(b)} cardRef={ref} yKey={tansOpt['yKey']} />