Hola, tengo algunos gráficos diferentes, donde el fondo consiste en diferentes gradientes según la variable y. Actualmente tengo tres creadores de gráficos diferentes, uno para cada variable y. Dado que los gradientes de fondo son las únicas cosas que varían, quería simplificar el código al tener solo un generador de gráficos, pero usando las declaraciones if / else para determinar el fondo correcto para aplicar:
Dispatch(
{},
"Graph Builder",
FrameBox,
{
if(
//graph 1
yAxis == "1",
Background Color( 1 ),
Add Image(Set Blob(green,"png"),
Bounds( Left( -100 ), Right( 100 ), Top( graphMax ), Bottom( if(graphMin>0.51,graphMin,0.51) ) ),
SetSize( {95401, 918} )
),
Add Image(Set Blob(red,"png"),
Bounds( Left( -100 ), Right( 100 ), Top( if(graphMax<0.49,graphMax,0.49) ), Bottom( graphMin ) ),
SetSize( {95401, 918} )
),
//graph 2
yAxis == "2",
Add Image(Set Blob(green,"png"),
Bounds( Left( -100 ), Right( 100 ), Top( if(graphMax<0.75,graphMax,0.75) ), Bottom( if(graphMin>0.55,graphMin,0.55) ) ),
SetSize( {95401, 918} )
),
Add Image(Set Blob(redCogTop,"png"),
Bounds( Left( -100 ), Right( 100 ), Top( graphMax ), Bottom( if(graphMin>0.75,graphMin,0.75 ) )),
SetSize( {95401, 918} )
),
Add Image(Set Blob(red,"png"),
Bounds( Left( -100 ), Right( 100 ), Top( if(graphMax<0.55,graphMax,0.55) ), Bottom( graphMin ) ),
SetSize( {95401, 918} )
),
//all other graphs
Add Image(Set Blob(green,"png"),
Bounds( Left( -100 ), Right( 100 ), Top( graphMax ), Bottom( graphMin ) ),
SetSize( {95401, 918} )
)
),
}
Grid Line Order( 2 ), Reference Line Order( 3 ),
DispatchSeg( BarSeg( 2 ), {Line Color( "Gray" )} )
}
),Aquí está el código original del primer gráfico:
Dispatch(
{},
"Graph Builder",
FrameBox,
{
Background Color( 1 ),
Add Image(Set Blob(green,"png"),
Bounds( Left( -100 ), Right( 100 ), Top( graphMax ), Bottom( if(graphMin>0.51,graphMin,0.51) ) ),
SetSize( {95401, 918} )
),
Add Image(Set Blob(red,"png"),
Bounds( Left( -100 ), Right( 100 ), Top( if(graphMax<0.49,graphMax,0.49) ), Bottom( graphMin ) ),
SetSize( {95401, 918} )
),
Grid Line Order( 2 ), Reference Line Order( 3 ),
DispatchSeg( BarSeg( 2 ), {Line Color( "Gray" )} )}
),
Por supuesto, hay muchas comas en el primer fragmento de código que confunden el if (), por lo que no funciona. ¿Tiene alguna sugerencia sobre cómo podría resolverse este problema?
Montones de gracias,
Mikael
¡Gracias! Sin embargo, no puedo hacer que funcione, incluso usar la función eval (parse ()) en pequeñas partes del código no me funciona. Intentaré subir el código pronto, tal vez eso arroje luz sobre lo que está sucediendo.