Jul 23, 2015, 8:10 AM
[CLOSED] Change gauge color dinamically
Hello, i have to upgrade my project from ext.net 2.* to 3.2.
I have a problem with code to change colors of a gauge when store data is changing. There is no error but colors are not changed.
here is my definition of gauge and store:
And here my function javascript for change colors:
I have a problem with code to change colors of a gauge when store data is changing. There is no error but colors are not changed.
here is my definition of gauge and store:
<ext:Store ID="StoreSLAGrouped" runat="server" RemoteSort="false" >
<Model>
<ext:Model ID="ModelSLAGrouped" runat="server">
<Fields>
<ext:ModelField Name="AdOperatore" Type="Int" />
<ext:ModelField Name="Risposte" Type="Int" />
<ext:ModelField Name="Risposte30" Type="Int" />
<ext:ModelField Name="ForAbb" Type="Int" />
<ext:ModelField Name="Abb" Type="Int" />
<ext:ModelField Name="SLA30" Type="Float"/>
<ext:ModelField Name="OLTRESLA30" Type="Int"/>
<ext:ModelField Name="PAbb" Type="Float"/>
<ext:ModelField Name="OLTREPAbb" Type="Int"/>
</Fields>
</ext:Model>
</Model>
<Listeners>
<DataChanged Fn="GaugeChange"/>
</Listeners>
</ext:Store>
<ext:PolarChart ID="PolarOltreSLA30"
runat="server"
StyleSpec="background:#fff;"
InsetPadding="25" Flex="1" StoreID="StoreSLAGrouped" Title="SLA 30" Animation="true">
<Axes>
<ext:NumericAxis Position="Gauge" Minimum="0" Maximum="100" MajorTickSteps="10" Margin="-10" >
<Label FillStyle="#7F8C8D" FontSize="9" Font="Calibri" />
<TitleConfig FontSize="12" Font="Calibri" TextAlign="Center" X="95" Y="90" />
</ext:NumericAxis>
</Axes>
<Series>
<ext:GaugeSeries Field="SLA30" Donut="0" Colors="#F49D10,#FFFFFF" TotalAngleDegrees="180" >
</ext:GaugeSeries>
</Series>
</ext:PolarChart>
And here my function javascript for change colors:
var GaugeChange = function (item, newValue, oldValue) {
var it = item.data.getAt(0);
if (typeof (it) !== 'undefined') {
var value = it.data.OLTRESLA30;
var chart = App.PolarOltreSLA30;
var oldcolors = chart.colors;
var styles = chart.series[0].style;
var subStyles = chart.series[0].subStyle;
var axes = chart.axes[0];
if (typeof (value) !== 'undefined') {
if (value < 1) {
chart.series[0].config.colors[0] = '#F75843';//rosso
}
else {
chart.series[0].config.colors[0] = '#16C92B';//verde
}
value = it.data.SLA30;
if (axes.setTitle !== undefined) {
axes.setTitle(Math.round(value * Math.pow(10, 2)) / Math.pow(10, 2) + ' %');
}
chart.redraw();
}
value = it.data.OLTREPAbb;
chart = App.PolarPAbb;
axes = chart.axes[0];
if (typeof (value) !== 'undefined') {
if (value < 1) {
chart.series[0].config.colors[0] = '#F75843';//rosso
}
else {
chart.series[0].config.colors[0] = '#16C92B';//verde
}
value = it.data.PAbb;
if (axes.setTitle !== undefined) {
axes.setTitle(Math.round(value * Math.pow(10, 2)) / Math.pow(10, 2) + ' %');
}
chart.redraw();
}
}
}
Last edited by fabricio.murta; Jul 27, 2015 at 9:21 AM.
Reason: [CLOSED]