@@ -83,7 +83,10 @@ function PieChart({
8383 legendShow ?: boolean ;
8484} ) {
8585 const total = data . reduce ( ( sum , row ) => sum + ( Number ( row [ yKey ] ) || 0 ) , 0 ) ;
86- if ( total === 0 ) return < div className = "flex items-center justify-center h-full text-muted-foreground" > No data</ div > ;
86+ if ( total === 0 )
87+ return (
88+ < div className = "flex items-center justify-center h-full text-muted-foreground" > No data</ div >
89+ ) ;
8790
8891 const slices : { label : string ; value : number ; pct : number ; color : string } [ ] = [ ] ;
8992 let cumAngle = - Math . PI / 2 ;
@@ -149,7 +152,10 @@ function PieChart({
149152 < div className = "flex flex-wrap gap-x-4 gap-y-1 justify-center text-xs" >
150153 { slices . map ( ( s , i ) => (
151154 < div key = { i } className = "flex items-center gap-1.5" >
152- < span className = "w-2.5 h-2.5 rounded-full inline-block flex-shrink-0" style = { { backgroundColor : s . color } } />
155+ < span
156+ className = "w-2.5 h-2.5 rounded-full inline-block flex-shrink-0"
157+ style = { { backgroundColor : s . color } }
158+ />
153159 < span className = "text-muted-foreground truncate max-w-[120px]" > { s . label } </ span >
154160 < span className = "font-medium" > { formatNumber ( s . value ) } </ span >
155161 </ div >
@@ -188,7 +194,12 @@ export const ChartVisualizationPro: React.FC<ChartVisualizationProProps> = ({
188194
189195 // Transform data based on configuration
190196 const transformedData = useMemo ( ( ) => {
191- return transformData ( result , localConfig . transform , localConfig . xAxis , localConfig . yAxis || localConfig . series ) ;
197+ return transformData (
198+ result ,
199+ localConfig . transform ,
200+ localConfig . xAxis ,
201+ localConfig . yAxis || localConfig . series
202+ ) ;
192203 } , [ result , localConfig . transform , localConfig . xAxis , localConfig . yAxis , localConfig . series ] ) ;
193204
194205 const handleConfigChange = ( updates : Partial < ChartConfig > ) => {
@@ -238,7 +249,9 @@ export const ChartVisualizationPro: React.FC<ChartVisualizationProProps> = ({
238249 await exportChartAsPNG ( chartRef . current , fileName , bg ) ;
239250 toast . success ( "Chart exported as PNG" ) ;
240251 } catch ( error ) {
241- toast . error ( `Failed to export chart: ${ error instanceof Error ? error . message : "Unknown error" } ` ) ;
252+ toast . error (
253+ `Failed to export chart: ${ error instanceof Error ? error . message : "Unknown error" } `
254+ ) ;
242255 }
243256 } ;
244257
@@ -274,13 +287,16 @@ export const ChartVisualizationPro: React.FC<ChartVisualizationProProps> = ({
274287 } ) ;
275288
276289 // Determine Y keys
277- const yKeys : string [ ] = chartConfig . series ?. map ( ( s ) => s . column ) ?? ( chartConfig . yAxis ? [ chartConfig . yAxis ] : [ ] ) ;
290+ const yKeys : string [ ] =
291+ chartConfig . series ?. map ( ( s ) => s . column ) ?? ( chartConfig . yAxis ? [ chartConfig . yAxis ] : [ ] ) ;
278292 const colors = chartConfig . colors || DEFAULT_COLORS ;
279293 const isDark = theme === "dark" ;
280294
281295 // Convert to uPlot columnar data: [xs, ...series]
282296 const xs = chartData . map ( ( _ , i ) => i ) ;
283- const seriesData = yKeys . map ( ( key ) => chartData . map ( ( row ) => ( Number ( row [ key ] ) || 0 ) as number ) ) ;
297+ const seriesData = yKeys . map ( ( key ) =>
298+ chartData . map ( ( row ) => ( Number ( row [ key ] ) || 0 ) as number )
299+ ) ;
284300
285301 // For stacked charts, compute stacked values
286302 const isStacked = chartConfig . type === "stacked_bar" || chartConfig . type === "stacked_area" ;
@@ -361,7 +377,11 @@ export const ChartVisualizationPro: React.FC<ChartVisualizationProProps> = ({
361377 {
362378 stroke : isDark ? "#888" : "#666" ,
363379 grid : chartConfig . showGrid
364- ? { stroke : isDark ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.08)" , width : 1 , dash : [ 4 , 4 ] }
380+ ? {
381+ stroke : isDark ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.08)" ,
382+ width : 1 ,
383+ dash : [ 4 , 4 ] ,
384+ }
365385 : { show : false } ,
366386 ticks : { stroke : isDark ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)" , width : 1 } ,
367387 values : ( _u : uPlot , vals : number [ ] ) => vals . map ( ( v ) => formatNumber ( v ) ) ,
@@ -397,8 +417,8 @@ export const ChartVisualizationPro: React.FC<ChartVisualizationProProps> = ({
397417
398418 // Stacked: render in reverse order so first series is on top visually
399419 const data : uPlot . AlignedData = isStacked
400- ? [ xs , ...finalSeriesData . reverse ( ) ] as uPlot . AlignedData
401- : [ xs , ...finalSeriesData ] as uPlot . AlignedData ;
420+ ? ( [ xs , ...finalSeriesData . reverse ( ) ] as uPlot . AlignedData )
421+ : ( [ xs , ...finalSeriesData ] as uPlot . AlignedData ) ;
402422
403423 return { uPlotOptions : opts , uPlotData : data } ;
404424 } , [ chartConfig , transformedData , theme ] ) ;
@@ -417,8 +437,8 @@ export const ChartVisualizationPro: React.FC<ChartVisualizationProProps> = ({
417437 < div className = "text-center space-y-2 max-w-md" >
418438 < h3 className = "text-lg font-semibold" > Create Your Chart</ h3 >
419439 < p className = "text-muted-foreground text-sm" >
420- Configure chart settings above to visualize your data. Choose a chart type, select your axes, and
421- customize to your needs.
440+ Configure chart settings above to visualize your data. Choose a chart type, select
441+ your axes, and customize to your needs.
422442 </ p >
423443 { suggestedTypes . length > 0 && (
424444 < div className = "pt-4" >
@@ -515,7 +535,10 @@ export const ChartVisualizationPro: React.FC<ChartVisualizationProProps> = ({
515535 { /* X-Axis */ }
516536 < div className = "space-y-2" >
517537 < label className = "text-xs font-medium" > X-Axis</ label >
518- < Select value = { localConfig . xAxis || "" } onValueChange = { ( value ) => handleConfigChange ( { xAxis : value } ) } >
538+ < Select
539+ value = { localConfig . xAxis || "" }
540+ onValueChange = { ( value ) => handleConfigChange ( { xAxis : value } ) }
541+ >
519542 < SelectTrigger >
520543 < SelectValue placeholder = "Select column" />
521544 </ SelectTrigger >
0 commit comments