Salut, j'ai différents graphiques, où le fond est composé de différents gradients en fonction de la variable y. J'ai actuellement trois constructeurs de graphes différents - un pour chaque variable y. Comme les dégradés d'arrière-plan sont les seules choses qui varient, j'ai voulu simplifier le code en n'ayant qu'un seul générateur de graphique, mais en utilisant des instructions if / else pour déterminer le bon arrière-plan à appliquer:
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" )} )
}
),Voici le code original du premier graphique:
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" )} )}
),
Bien sûr, il y a beaucoup de virgules dans le premier extrait de code qui confondent if (), donc cela ne fonctionne pas. Avez-vous des suggestions sur la façon dont ce problème pourrait être résolu?
Merci beaucoup,
Mikael
Merci! Cependant, je ne peux pas le faire fonctionner - même utiliser la fonction eval (parse ()) sur de petites parties du code ne fonctionne pas pour moi. Je vais essayer de télécharger le code bientôt, peut-être que cela jette la lumière sur ce qui se passe.