@@ -88,9 +88,6 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
8888 )
8989 ) ;
9090
91-
92-
93-
9491 const { data : chartDetails , refetch } : { data : any ; refetch : any } = useQuery (
9592 [ `chartdata_${ params . id } ` ] ,
9693 ( ) =>
@@ -179,8 +176,6 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
179176
180177 const [ resourceSchema , setResourceSchema ] = useState < any [ ] > ( [ ] ) ;
181178
182-
183-
184179 useEffect ( ( ) => {
185180 if ( chartId && chartDetails ?. resourceChart ) {
186181 const resource = resourceData ?. datasetResources ?. find (
@@ -219,7 +214,7 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
219214 options : {
220215 aggregateType : resourceChart ?. options ?. aggregateType ,
221216 regionColumn : resourceChart ?. options ?. regionColumn ?. id ,
222- showLegend : resourceChart ?. options ?. showLegend ,
217+ showLegend : resourceChart ?. options ?. showLegend || true ,
223218 timeColumn : resourceChart ?. options ?. timeColumn ,
224219 valueColumn : resourceChart ?. options ?. valueColumn ?. id ,
225220 xAxisColumn : resourceChart ?. options ?. xAxisColumn ?. id ,
@@ -298,6 +293,8 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
298293 } ) ;
299294 } , [ ] ) ;
300295
296+
297+
301298 const { mutate, isLoading : editMutationLoading } = useMutation (
302299 ( chartInput : { chartInput : ResourceChartInput } ) =>
303300 GraphQL (
@@ -324,7 +321,6 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
324321
325322 const handleSave = useCallback (
326323 ( updatedData : ChartData ) => {
327-
328324 if ( JSON . stringify ( previousChartData ) !== JSON . stringify ( updatedData ) ) {
329325 // Filter out empty Y-axis columns
330326 const validYAxisColumns = updatedData . options . yAxisColumn . filter (
@@ -347,26 +343,26 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
347343 // Store current type before mutation
348344 const currentType = updatedData . type ;
349345
350- mutate (
351- { chartInput } ,
352- {
353- onSuccess : ( data ) => {
354- setChartData ( ( prev ) => ( {
355- ...prev ,
356- chart : data . chart ,
357- type : currentType , // Preserve the type from before mutation
358- options : {
359- ...prev . options ,
360- yAxisColumn : validYAxisColumns ,
361- } ,
362- } ) ) ;
363- } ,
364- }
365- ) ;
366- setPreviousChartData ( {
367- ...updatedData ,
368- type : currentType , // Ensure previousChartData also has correct type
369- } ) ;
346+ mutate (
347+ { chartInput } ,
348+ {
349+ onSuccess : ( data ) => {
350+ setChartData ( ( prev ) => ( {
351+ ...prev ,
352+ chart : data . chart ,
353+ type : currentType , // Preserve the type from before mutation
354+ options : {
355+ ...prev . options ,
356+ yAxisColumn : validYAxisColumns ,
357+ } ,
358+ } ) ) ;
359+ } ,
360+ }
361+ ) ;
362+ setPreviousChartData ( {
363+ ...updatedData ,
364+ type : currentType , // Ensure previousChartData also has correct type
365+ } ) ;
370366 }
371367 } ,
372368 [ previousChartData , mutate ]
0 commit comments