Ciao,
Provo a scrivere un grafico a barre come questo.
Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables(
Y( :Name( "A" ) ),
Y( :Name( "B" ), Position( 1 ) ),
Y( :Name( "C" ), Position( 1 ) ),
),
Elements(
Bar(
Y( 1 ),
Y( 2 ),
Y( 3 ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
)
La sfida è che ho le variabili Y in una lista che verrà modificata di volta in volta (ad esempio {A, B, D, Test, Bla}).
Mi piacerebbe avere il grafico a barre regolato automaticamente in base alla lista "l" ad esempio:
l = {"A", "B", "D", "Test", "Bla"};
...the script should then be looks like this:
Variables(
Y( :Name( "A" ) ),
Y( :Name( "B" ), Position( 1 ) ),
Y( :Name( "D" ), Position( 1 ) ),
Y( :Name( "Test" ), Position( 1 ) ),
Y( :Name( "Bla" ), Position( 1 ) ),
),
Elements(
Bar(
Y( 1 ),
Y( 2 ),
Y( 3 ),
Y( 4 ),
Y( 5 ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
)
...
Dopo una query sul database, l'elenco l verrà modificato e ho bisogno di un aggiornamento automatico del grafico a barre.
Ho già provato a trasformare l'elenco in una colonna e ripetere il ciclo sul numero di voci di elenco, ma genera più anziché un grafico a barre
for (i=1, i <= Nitems(l), i++,
show (l[i]);
dt << Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables(
Y( Eval (l[i] ))
),
Elements(
Bar(
Y( i ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
));
Saluti,
Grazie, questo funziona bene!
Se impili le colonne desiderate, non importa quante ne hai. Questo codice dovrebbe iniziare:
dt1 = New Table( "Untitled 27", Add Rows( 3 ),
New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [6, 5, 4] ) ),
New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [7, 8, 9] ) ),
New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [3, 2, 1] ) )
);
col_list = dt1 << get column names(string);
dt2 = dt1 << Stack(
columns(col_list),
Source Label Column( "Variable" ),
Stacked Data Column( "Value" )
);
dt2 << Graph Builder(
Size( 526, 415 ),
Show Control Panel( 0 ),
Variables( Y( :Value ), Overlay( :Variable ) ),
Elements( Bar( Y, Legend( 8 ), Bar Style( "Stacked" ) ) ),
SendToReport( Dispatch( {}, "X title", TextEditBox, {Set Wrap( 2 )} ) )
)