Sto provando da un po' a scrivere un codice in JSL per gestire la posizione della legenda come segue in base al valore di uni_bat.
Graph builder( ...,<BR /><BR />//If statement...
//if(
//N items(uni_bat) == 1, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 2, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 3, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 4, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 5, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,4,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 6, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,4,5,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 7, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,4,5,6,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 8, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,4,5,6,7,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 9, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,4,5,6,7,8,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 10, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,4,5,6,7,8,9,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 11, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,4,5,6,7,8,9,10,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
//N items(uni_bat) == 12, Dispatch( {}, "400", LegendBox, {Legend Position( {9, [0,1,2,3,4,5,6,7,8,9,10,11,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} )
//);\
// case for uni_bat == 1
Dispatch( {}, "400", LegendBox, {Legend Position( {9,[0,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, -1, -1]} )} ),
Q1.
Se viene eseguita solo una riga come "case for uni_bat==1", il grafico viene creato senza alcun problema.
Tuttavia, l'istruzione IF non è ben riconosciuta nel generatore di grafici.
Come eseguire correttamente la sequenza di numeri che segue la posizione della legenda con l'istruzione IF???
(ex. {9,[0,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 10, [-1, -1, - 1, -1]} )
Q2.
Se Q1 è risolto, c'è un modo per semplificare ulteriormente il codice scritto con l'istruzione IF usando For Loop ?
Come scrivere il codice Legend Position() regolarmente fino a uni_bat==50 utilizzando l'istruzione for.
Sarei molto grato per qualsiasi suggerimento. 