@@ -15,6 +15,7 @@ import {
1515 formatUpdatedAt ,
1616 observeElementHeight ,
1717} from "./utils" ;
18+ import { isArray } from "echarts/types/src/export/api/util.js" ;
1819
1920export type ChartWrapperProps = {
2021 id ?: string ;
@@ -84,7 +85,7 @@ export default function ChartWrapper(props: ChartWrapperProps) {
8485 const [ activeTab , setActiveTab ] = useState < number > ( 0 ) ;
8586
8687 const tableData = showDataTransposed && data . data ? transposeData ( data . data ) : data . data ;
87- const csvData = dataToCSV ( tableData ) ;
88+ const csvData = tableData && Array . isArray ( tableData ) && dataToCSV ( tableData ) ;
8889
8990 const formattedUpdatedAt = formatUpdatedAt ( data . updatedAt ) ;
9091 const infoClean = cleanupInfoText ( text ) ;
@@ -99,6 +100,10 @@ export default function ChartWrapper(props: ChartWrapperProps) {
99100 const [ chartAreaRowHeight , setChartAreaRowHeight ] = useState < number > ( 400 ) ;
100101 const wrapRef = useRef ( null ) ;
101102
103+ const chartType = data . chart || "bar" ;
104+ const hasData = ! ( chartType == "cmap" || chartType == "kpi" || chartType == "kpiGroup" ) && Array . isArray ( data . data ) && data . data . length > 0 ;
105+ const hasPic = ! ( chartType == "cmap" || chartType == "kpi" || chartType == "kpiGroup" ) ;
106+
102107 useEffect ( ( ) => {
103108 return observeElementHeight (
104109 ( ) => wrapRef . current as unknown as HTMLElement | null ,
@@ -176,7 +181,8 @@ export default function ChartWrapper(props: ChartWrapperProps) {
176181 ) }
177182 </ div >
178183
179- < div
184+
185+ { hasData && < div
180186 id = { `tab2-${ id } -content` }
181187 role = "tabpanel"
182188 aria-labelledby = { `tab2-${ id } ` }
@@ -185,6 +191,7 @@ export default function ChartWrapper(props: ChartWrapperProps) {
185191 >
186192 < DataTable id = { id } data = { tableData as any [ ] } poweredByLabel = "" />
187193 </ div >
194+ }
188195
189196 < div
190197 id = { `tab3-${ id } -content` }
@@ -219,7 +226,7 @@ export default function ChartWrapper(props: ChartWrapperProps) {
219226 ) }
220227
221228 < div className = "cw-actions" >
222- { enableDownloadData && (
229+ { enableDownloadData && hasData && (
223230 < button
224231 type = "button"
225232 className = "cw-btn cw-btn--primary"
@@ -239,7 +246,7 @@ export default function ChartWrapper(props: ChartWrapperProps) {
239246 </ button >
240247 ) }
241248
242- { enableDownloadImage && (
249+ { enableDownloadImage && hasPic && (
243250 < button
244251 type = "button"
245252 className = "cw-btn cw-btn--primary"
0 commit comments