Skip to content

Commit

Permalink
chore(widget): add defensive code (#5429)
Browse files Browse the repository at this point in the history
Signed-off-by: samuel.park <samuel.park@megazone.com>
  • Loading branch information
piggggggggy authored Jan 5, 2025
1 parent 5a04959 commit c7e0cb3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ const drawChart = (rawData: WidgetLoadResponse|null) => {
const _seriesData: any[] = [];
let _dataFields: string[] = widgetOptionsState.dataFieldInfo?.data as string[] || [];
if (state.isPivotDataTable) {
const _excludeFields = [...Object.keys(rawData?.labels_info), SUB_TOTAL_NAME];
_dataFields = rawData?.order?.filter((v) => !_excludeFields.includes(v));
const _excludeFields = [...Object.keys(rawData?.labels_info ?? {}), SUB_TOTAL_NAME];
_dataFields = rawData?.order?.filter((v) => !_excludeFields.includes(v)) || [];
}
_dataFields.forEach((field) => {
const _unit: string|undefined = state.unitMap[field];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const state = reactive({
yAxisData: computed<string[]>(() => {
if (!state.data?.results?.length) return [];
if (state.isPivotDataTable) {
const _excludeFields = [...Object.keys(state.data?.labels_info), SUB_TOTAL_NAME];
const _excludeFields = [...Object.keys(state.data?.labels_info ?? {}), SUB_TOTAL_NAME];
return state.data.order?.filter((v) => !_excludeFields.includes(v)) || [];
}
return widgetOptionsState.dataFieldInfo?.data as string[] || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const state = reactive({
yAxisData: computed<string[]>(() => {
if (!state.data?.results?.length) return [];
if (state.isPivotDataTable) {
const _excludeFields = [...Object.keys(state.data?.labels_info), SUB_TOTAL_NAME];
const _excludeFields = [...Object.keys(state.data?.labels_info ?? {}), SUB_TOTAL_NAME];
return state.data.order?.filter((v) => !_excludeFields.includes(v)) || [];
}
return (widgetOptionsState.dataFieldInfo?.data ?? []) as string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ const drawChart = (rawData: WidgetLoadResponse|null) => {
const _defaultValue = widgetOptionsState.missingValueInfo?.type === 'lineToZero' ? 0 : undefined;
let _dataFields: string[] = widgetOptionsState.dataFieldInfo?.data as string[] || [];
if (state.isPivotDataTable) {
const _excludeFields = [...Object.keys(rawData?.labels_info), SUB_TOTAL_NAME];
_dataFields = rawData?.order?.filter((v) => !_excludeFields.includes(v));
const _excludeFields = [...Object.keys(rawData?.labels_info ?? {}), SUB_TOTAL_NAME];
_dataFields = rawData?.order?.filter((v) => !_excludeFields.includes(v)) || [];
}
_dataFields.forEach((_dataField) => {
const _unit: string|undefined = state.unitMap[_dataField];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ const drawChart = (rawData?: WidgetLoadResponse|null) => {
const _seriesData: any[] = [];
let _dataFields: string[] = widgetOptionsState.dataFieldInfo?.data as string[] || [];
if (state.isPivotDataTable) {
const _excludeFields = [...Object.keys(rawData?.labels_info), SUB_TOTAL_NAME];
_dataFields = rawData?.order?.filter((v) => !_excludeFields.includes(v));
const _excludeFields = [...Object.keys(rawData?.labels_info ?? {}), SUB_TOTAL_NAME];
_dataFields = rawData?.order?.filter((v) => !_excludeFields.includes(v)) || [];
}
_dataFields.forEach((_dataField) => {
const _unit: string|undefined = state.unitMap[_dataField];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ const drawChart = (rawData?: WidgetLoadResponse|null) => {
const _seriesData: any[] = [];
let _dataFields: string[] = widgetOptionsState.dataFieldInfo?.data as string[] || [];
if (state.isPivotDataTable) {
const _excludeFields = [...Object.keys(rawData?.labels_info), SUB_TOTAL_NAME];
_dataFields = rawData?.order?.filter((v) => !_excludeFields.includes(v));
const _excludeFields = [...Object.keys(rawData?.labels_info ?? {}), SUB_TOTAL_NAME];
_dataFields = rawData?.order?.filter((v) => !_excludeFields.includes(v)) || [];
}
_dataFields.forEach((_dataField) => {
const _unit: string|undefined = state.unitMap[_dataField];
Expand Down

0 comments on commit c7e0cb3

Please sign in to comment.