Skip to content

Commit

Permalink
Merge pull request #2244 from scottsut/dev
Browse files Browse the repository at this point in the history
fix: Bug fixes
  • Loading branch information
scottsut authored Sep 19, 2023
2 parents df210f7 + 7db0d1f commit f71c1be
Show file tree
Hide file tree
Showing 37 changed files with 889 additions and 315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const ChartDrillContextMenu: FC<{
} else {
rows = groupSection?.rows?.filter(v => v.uid === allFields[0].uid);
}
rows = rows?.filter(row => row.type === DataViewFieldType.DATE);
return getRuntimeDateLevelFields(rows);
}, [drillOption, chartConfig?.datas, currentFields]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class BasicBarChart extends Chart implements IChartLifecycle {
return {
tooltip: {
trigger: 'item',
confine: true,
formatter: this.getTooltipFormatterFunc(
chartDataSet,
groupConfigs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class BasicDoubleYChart extends Chart {
axisPointer: {
type: 'cross',
},
confine: true,
formatter: this.getTooltipFormmaterFunc(
styleConfigs,
groupConfigs,
Expand Down Expand Up @@ -365,10 +366,10 @@ class BasicDoubleYChart extends Chart {
);

const _yAxisTemplate = (position, name): DoubleYChartYAxis => {
const [showAxis, inverse, font, showLabel] = getStyles(
const [showAxis, inverse, font, showLabel, showTitleAndUnit] = getStyles(
styles,
[`${position}Y`],
['showAxis', 'inverseAxis', 'font', 'showLabel'],
['showAxis', 'inverseAxis', 'font', 'showLabel', 'showTitleAndUnit'],
);
const [format] = getStyles(
styles,
Expand All @@ -379,7 +380,7 @@ class BasicDoubleYChart extends Chart {
type: 'value',
position,
showTitleAndUnit: true,
name,
name: showTitleAndUnit ? name : null,
nameLocation: 'middle',
nameGap: 50,
nameRotate: 90,
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/app/components/ChartGraph/BasicDoubleYChart/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ const config: ChartConfig = {
color: '#495057',
},
},
{
label: 'common.showTitleAndUnit',
key: 'showTitleAndUnit',
default: true,
comType: 'checkbox',
},
{
label: 'yAxis.open',
key: 'modal',
Expand Down Expand Up @@ -331,6 +337,12 @@ const config: ChartConfig = {
color: '#495057',
},
},
{
label: 'common.showTitleAndUnit',
key: 'showTitleAndUnit',
default: true,
comType: 'checkbox',
},
{
label: 'yAxis.open',
key: 'modal',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class BasicLineChart extends Chart {
return {
tooltip: {
trigger: 'item',
confine: true,
formatter: this.getTooltipFormmaterFunc(
chartDataSet,
groupConfigs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,22 @@ class BasicOutlineMapChart extends Chart {
areaEmphasisColor,
enableFocus,
borderStyle,
roam,
] = getStyles(
styleConfigs,
['map'],
['level', 'areaColor', 'areaEmphasisColor', 'focusArea', 'borderStyle'],
[
'level',
'areaColor',
'areaEmphasisColor',
'focusArea',
'borderStyle',
'roam',
],
);
return {
map: mapLevelName,
roam: 'move',
roam: roam && 'move',
emphasis: {
focus: enableFocus ? 'self' : 'none',
itemStyle: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,11 @@ class BasicPieChart extends Chart {
}

private getPieSeriesImpl(styleConfigs: ChartStyleConfig[]): PieSeriesImpl {
const [avoidOverlap] = getStyles(styleConfigs, ['label'], ['avoidOverlap']);
return {
type: 'pie',
sampling: 'average',
avoidLabelOverlap: false,
avoidLabelOverlap: avoidOverlap,
...this.getLabelStyle(styleConfigs),
...this.getSeriesStyle(styleConfigs),
...getGridStyle(styleConfigs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ const config: ChartConfig = {
default: true,
comType: 'checkbox',
},
{
label: 'label.avoidOverlap',
key: 'avoidOverlap',
default: false,
comType: 'checkbox',
},
],
},
{
Expand Down Expand Up @@ -284,6 +290,7 @@ const config: ChartConfig = {
showName: '维度值',
showPercent: '百分比',
showValue: '指标值',
avoidOverlap: '强制显示所有标签',
},
legend: {
title: '图例',
Expand Down Expand Up @@ -333,6 +340,7 @@ const config: ChartConfig = {
showName: 'Show Name',
showPercent: 'Show Percentage',
showValue: 'Show Value',
avoidOverlap: 'Force display of all labels',
},
legend: {
title: 'Legend',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* limitations under the License.
*/

import { Table } from 'antd';
import { ConfigProvider, Table } from 'antd';
import { antdLocales } from 'locales/i18n';
import { FC, memo } from 'react';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components/macro';

interface TableStyleConfigProps {
Expand Down Expand Up @@ -47,6 +49,8 @@ const AntdTableWrapper: FC<{
summaryFn?: (data) => { total: number; summarys: [] };
}> = memo(
({ dataSource, columns, children, summaryFn, tableStyleConfig, ...rest }) => {
const { i18n } = useTranslation();

const getTableSummaryRow = pageData => {
if (!summaryFn) {
return undefined;
Expand All @@ -68,13 +72,15 @@ const AntdTableWrapper: FC<{
};

return (
<StyledTable
{...rest}
tableStyleConfig={tableStyleConfig}
dataSource={dataSource}
columns={columns}
summary={getTableSummaryRow}
/>
<ConfigProvider locale={antdLocales[i18n.language]}>
<StyledTable
{...rest}
tableStyleConfig={tableStyleConfig}
dataSource={dataSource}
columns={columns}
summary={getTableSummaryRow}
/>
</ConfigProvider>
);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ const config: ChartConfig = {
color: '#ced4da',
},
},
{
label: 'map.roam',
key: 'roam',
default: true,
comType: 'checkbox',
},
],
},
{
Expand Down Expand Up @@ -310,6 +316,7 @@ const config: ChartConfig = {
focusArea: '聚焦选中区域',
areaColor: '区域颜色',
areaEmphasisColor: '选中区域高亮颜色',
roam: '鼠标平移',
},
levelType: {
china: '中国-省级地图',
Expand Down Expand Up @@ -362,6 +369,7 @@ const config: ChartConfig = {
focusArea: 'Focus Area',
areaColor: 'Area Color',
areaEmphasisColor: 'Area Emphasis Color',
roam: 'Mouse translating',
},
levelType: {
china: 'China',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ const config: ChartConfig = {
color: '#ced4da',
},
},
{
label: 'map.roam',
key: 'roam',
default: true,
comType: 'checkbox',
},
{
label: 'map.cycleRatio',
key: 'cycleRatio',
Expand Down Expand Up @@ -319,6 +325,7 @@ const config: ChartConfig = {
cycleRatio: '气泡大像素比',
areaColor: '区域颜色',
areaEmphasisColor: '选中区域高亮颜色',
roam: '鼠标平移',
},
levelType: {
china: '中国-省级地图',
Expand Down Expand Up @@ -369,6 +376,7 @@ const config: ChartConfig = {
areaColor: 'Area Color',
areaEmphasisColor: 'Area Emphasis Color',
cycleRatio: 'Cycle Ratio',
roam: 'Mouse translating',
},
levelType: {
china: 'China',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ class ChartIFrameEventBroker {

private registerListener(c: IChart): void {
this.subscribe(ChartLifecycle.Mounted, c?.onMount);
this.subscribe(ChartLifecycle.Updated, c?.onUpdated);
this.subscribe(ChartLifecycle.Resize, c?.onResize);
this.subscribe(ChartLifecycle.Updated, c?.onUpdated);
this.subscribe(ChartLifecycle.UnMount, c?.onUnMount);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ const ChartIFrameLifecycleAdapter: FC<{
}, [chart?.meta?.id, isShown]);

/**
* Chart Update Event
* Dependency: 'config', 'dataset', 'widgetSpecialConfig',
* 'containerStatus', 'document', 'window', 'isShown', 'drillOption', 'selectedItems'
* Chart Resize Event
* Dependency: 'style.width', 'style.height', 'document', 'window', 'isShown'
*/
useEffect(() => {
if (
Expand All @@ -167,28 +166,27 @@ const ChartIFrameLifecycleAdapter: FC<{
) {
return;
}

eventBrokerRef.current?.publish(
ChartLifecycle.Updated,
ChartLifecycle.Resize,
buildBrokerOption(),
buildBrokerContext(),
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
config,
dataset,
widgetSpecialConfig,
containerStatus,
style.width,
style.height,
document,
window,
isShown,
drillOption,
selectedItems,
containerStatus,
isLoadingData,
]);

/**
* Chart Resize Event
* Dependency: 'style.width', 'style.height', 'document', 'window', 'isShown'
* Chart Update Event
* Dependency: 'config', 'dataset', 'widgetSpecialConfig',
* 'containerStatus', 'document', 'window', 'isShown', 'drillOption', 'selectedItems'
*/
useEffect(() => {
if (
Expand All @@ -202,20 +200,22 @@ const ChartIFrameLifecycleAdapter: FC<{
) {
return;
}

eventBrokerRef.current?.publish(
ChartLifecycle.Resize,
ChartLifecycle.Updated,
buildBrokerOption(),
buildBrokerContext(),
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
style.width,
style.height,
config,
dataset,
widgetSpecialConfig,
containerStatus,
document,
window,
isShown,
containerStatus,
drillOption,
selectedItems,
isLoadingData,
]);

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/SaveToDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { getCascadeAccess } from 'app/pages/MainPage/Access';
import {
PermissionLevels,
ResourceTypes,
VizResourceSubTypes,
} from 'app/pages/MainPage/pages/PermissionPage/constants';
import { useAddViz } from 'app/pages/MainPage/pages/VizPage/hooks/useAddViz';
import { SaveFormContext } from 'app/pages/MainPage/pages/VizPage/SaveFormContext';
Expand Down Expand Up @@ -136,7 +137,7 @@ const SaveToDashboard: FC<SaveToDashboardTypes> = memo(
selectable: v.relType !== 'FOLDER',
})),
null,
[],
[VizResourceSubTypes.Folder],
{ getIcon, filter: filterTreeNode },
);
}, [vizData, getIcon, filterTreeNode]);
Expand Down
Loading

0 comments on commit f71c1be

Please sign in to comment.