@@ -214,14 +214,14 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
214214 name : resourceChart . name || '' ,
215215 options : {
216216 aggregateType : resourceChart ?. options ?. aggregateType ,
217- regionColumn : resourceChart ?. options ?. regionColumn ,
217+ regionColumn : resourceChart ?. options ?. regionColumn ?. id ,
218218 showLegend : resourceChart ?. options ?. showLegend ,
219219 timeColumn : resourceChart ?. options ?. timeColumn ,
220- valueColumn : resourceChart ?. options ?. valueColumn ,
220+ valueColumn : resourceChart ?. options ?. valueColumn ?. id ,
221221 xAxisColumn : resourceChart ?. options ?. xAxisColumn ?. id ,
222222 xAxisLabel : resourceChart ?. options ?. xAxisLabel ,
223223 yAxisColumn : resourceChart ?. options ?. yAxisColumn ?. map ( ( col : any ) => ( {
224- fieldName : col . field ,
224+ fieldName : col . field . id ,
225225 label : col . label ,
226226 color : col . color ,
227227 } ) ) ,
@@ -324,29 +324,36 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
324324 const handleSave = useCallback (
325325 ( updatedData : ChartData ) => {
326326 if ( JSON . stringify ( previousChartData ) !== JSON . stringify ( updatedData ) ) {
327+
328+ const validYAxisColumns = updatedData . options . yAxisColumn . filter (
329+ col => col . fieldName && col . fieldName . trim ( ) !== ''
330+ ) ;
331+
327332 const chartInput : ResourceChartInput = {
328333 chartId : updatedData . chartId ,
329334 description : updatedData . description ,
330335 filters : updatedData . filters ,
331336 name : updatedData . name ,
332- options : updatedData . options ,
337+ options : {
338+ ...updatedData . options ,
339+ yAxisColumn : validYAxisColumns
340+ } ,
333341 resource : updatedData . resource ,
334342 type : updatedData . type as ChartTypes ,
335343 } ;
336344
337- // mutate(
338- // { chartInput },
339- // {
340- // onSuccess: (data) => {
341- // setChartData((prev) => ({
342- // ...prev,
343- // chart: data.createChart .chart,
344- // }));
345- // },
346- // }
347- // );
345+ mutate (
346+ { chartInput } ,
347+ {
348+ onSuccess : ( data ) => {
349+ setChartData ( ( prev ) => ( {
350+ ...prev ,
351+ chart : data . chart ,
352+ } ) ) ;
353+ } ,
354+ }
355+ ) ;
348356
349- console . log ( chartInput ) ;
350357 setPreviousChartData ( updatedData ) ;
351358 }
352359 } ,
@@ -400,7 +407,7 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
400407 />
401408 < div className = "mb-6 flex flex-col gap-6 p-8 text-center" >
402409 < Text > Preview</ Text >
403- { chartData . chart && Object . keys ( chartData . chart ) . length > 0 && (
410+ { chartData . chart && Object . keys ( chartData . chart ) . length > 0 && (
404411 < ReactECharts option = { chartData . chart } ref = { chartRef } />
405412 ) }
406413 </ div >
0 commit comments