@@ -4,6 +4,7 @@ import EditRoadIcon from "@mui/icons-material/EditRoad"
44import MoreVertIcon from "@mui/icons-material/MoreVert"
55import { LoadingButton } from "@mui/lab"
66import {
7+ Alert ,
78 Box ,
89 Button ,
910 Card ,
@@ -84,8 +85,6 @@ const GraphByLLMItem: FC<{
8485 }
8586 } , [ plotData , colorTheme ] )
8687
87- if ( plotData . length === 0 ) return null
88-
8988 return (
9089 < Card >
9190 < CardContent sx = { { position : "relative" , padding : theme . spacing ( 1 ) } } >
@@ -193,10 +192,17 @@ const GraphByLLMItem: FC<{
193192 </ Box >
194193 ) }
195194
196- < GraphContainer
197- plotDomId = { plotDomId }
198- graphComponentState = { graphComponentState }
199- />
195+ { plotData . length > 0 ? (
196+ < GraphContainer
197+ plotDomId = { plotDomId }
198+ graphComponentState = { graphComponentState }
199+ />
200+ ) : (
201+ < Alert severity = "warning" sx = { { m : theme . spacing ( 2 ) } } >
202+ No graph data available. Please try regenerating the graph with a
203+ different query.
204+ </ Alert >
205+ ) }
200206 </ CardContent >
201207 </ Card >
202208 )
@@ -233,51 +239,46 @@ export const GraphByLLM: FC<{
233239 } }
234240 >
235241 { render ( ) }
236- { graphs . map (
237- ( graph ) =>
238- graph . plotData . length > 0 && (
239- < GraphByLLMItem
240- key = { graph . id }
241- id = { graph . id }
242- plotDomId = { `${ plotDomIdPrefix } -${ graph . id } ` }
243- title = { graph . title }
244- plotData = { graph . plotData }
245- onDelete = { ( ) =>
246- setGraphs ( ( prev ) => prev . filter ( ( g ) => g . id !== graph . id ) )
247- }
248- reGeneratePlotlyGraph = { (
249- reGeneratePlotlyGraphQueryStr : string
250- ) => {
251- if ( study === null ) return
252- reGeneratePlotlyGraph (
253- study ,
254- graph . functionStr ,
255- reGeneratePlotlyGraphQueryStr
256- ) . then ( ( result ) => {
257- setGraphs ( ( prev ) =>
258- prev . map ( ( g ) => {
259- if ( g . id !== graph . id ) return g
260- if (
261- result . plotData . length === 0 &&
262- result . functionStr === ""
263- ) {
264- // If the regeneration was cancelled, keep the previous graph
265- return g
266- }
267- return {
268- id : g . id ,
269- title : g . title ,
270- functionStr : result . functionStr ,
271- plotData : result . plotData ,
272- }
273- } )
274- )
242+ { graphs . map ( ( graph ) => (
243+ < GraphByLLMItem
244+ key = { graph . id }
245+ id = { graph . id }
246+ plotDomId = { `${ plotDomIdPrefix } -${ graph . id } ` }
247+ title = { graph . title }
248+ plotData = { graph . plotData }
249+ onDelete = { ( ) =>
250+ setGraphs ( ( prev ) => prev . filter ( ( g ) => g . id !== graph . id ) )
251+ }
252+ reGeneratePlotlyGraph = { ( reGeneratePlotlyGraphQueryStr : string ) => {
253+ if ( study === null ) return
254+ reGeneratePlotlyGraph (
255+ study ,
256+ graph . functionStr ,
257+ reGeneratePlotlyGraphQueryStr
258+ ) . then ( ( result ) => {
259+ setGraphs ( ( prev ) =>
260+ prev . map ( ( g ) => {
261+ if ( g . id !== graph . id ) return g
262+ if (
263+ result . plotData . length === 0 &&
264+ result . functionStr === ""
265+ ) {
266+ // If the regeneration was cancelled, keep the previous graph
267+ return g
268+ }
269+ return {
270+ id : g . id ,
271+ title : g . title ,
272+ functionStr : result . functionStr ,
273+ plotData : result . plotData ,
274+ }
275275 } )
276- } }
277- isReGeneratingPlotlyGraph = { isReGeneratePlotlyGraphLoading }
278- />
279- )
280- ) }
276+ )
277+ } )
278+ } }
279+ isReGeneratingPlotlyGraph = { isReGeneratePlotlyGraphLoading }
280+ />
281+ ) ) }
281282 < Box sx = { { display : "flex" } } >
282283 < TextField
283284 id = "graph-by-llm-query"
0 commit comments