The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Refactor ChartConfig.tsx (#34019)
Joshen Limbc59f5019a6c
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/ChartConfig.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/ChartConfig.tsxindex 29db50066c7..87d93bbd938 100644--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/ChartConfig.tsx+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/ChartConfig.tsx@@ -108,17 +108,6 @@ export const ChartConfig = ({const resultToRender = config.cumulative ? cumulativeResults : results.rows- if (!resultKeys.length) {- return (- <div className="p-2">- <NoDataPlaceholder- size="normal"- description="Execute a query and configure the chart options."- />- </div>- )- }-const getDateFormat = (key: any) => {const value = resultToRender?.[0]?.[key] || ''if (typeof value === 'number') return 'number'@@ -128,61 +117,62 @@ export const ChartConfig = ({const xKeyDateFormat = getDateFormat(config.xKey)- const ChartPanel = () => {- if (!hasConfig) {- return (- <ResizablePanel className="p-4 h-full" defaultSize={75}>- <NoDataPlaceholder- size="normal"- title="Configure your chart"- description="Select your X and Y axis in the chart options panel"- />- </ResizablePanel>- )- }-- if (config.type === 'bar') {- return (- <BarChart- showLegend- size="normal"- xAxisIsDate={xKeyDateFormat === 'date'}- data={resultToRender}- xAxisKey={config.xKey}- yAxisKey={config.yKey}- showGrid={config.showGrid}- XAxisProps={{- angle: 0,- interval: 'preserveStart',- hide: !config.showLabels,- tickFormatter: (idx: string) => {- const value = resultToRender[+idx][config.xKey]- if (xKeyDateFormat === 'date') {- return dayjs(value).format('MMM D YYYY HH:mm')- }- return value- },- }}- YAxisProps={{- tickFormatter: (value: number) => value.toLocaleString(),- hide: !config.showLabels,- domain: [0, 'dataMax'],- }}- />- )- }- }-const onFlip = () => {const newY = config.xKeyconst newX = config.yKeyonConfigChange({ ...config, xKey: newX, yKey: newY })}+ if (!resultKeys.length) {+ return (+ <div className="p-2">+ <NoDataPlaceholder+ size="normal"+ description="Execute a query and configure the chart options."+ />+ </div>+ )+ }+return (<ResizablePanelGroup direction="horizontal" className="flex-grow h-full"><ResizablePanel className="p-4 h-full" defaultSize={75}>- <ChartPanel />+ {!hasConfig ? (+ <ResizablePanel className="p-4 h-full" defaultSize={75}>+ <NoDataPlaceholder+ size="normal"+ title="Configure your chart"+ description="Select your X and Y axis in the chart options panel"+ />+ </ResizablePanel>+ ) : config.type === 'bar' ? (+ <BarChart+ showLegend+ size="normal"+ xAxisIsDate={xKeyDateFormat === 'date'}+ data={resultToRender}+ xAxisKey={config.xKey}+ yAxisKey={config.yKey}+ showGrid={config.showGrid}+ XAxisProps={{+ angle: 0,+ interval: 'preserveStart',+ hide: !config.showLabels,+ tickFormatter: (idx: string) => {+ const value = resultToRender[+idx][config.xKey]+ if (xKeyDateFormat === 'date') {+ return dayjs(value).format('MMM D YYYY HH:mm')+ }+ return value+ },+ }}+ YAxisProps={{+ tickFormatter: (value: number) => value.toLocaleString(),+ hide: !config.showLabels,+ domain: [0, 'dataMax'],+ }}+ />+ ) : null}</ResizablePanel><ResizableHandle withHandle /><ResizablePanel