Oct 01, 2013, 4:05 PM
[CLOSED] live chart with minutes as Unit.
Hi Daniil,
I am trying to develop a live chart with minutes as Unit. This does work fine in terms of displaying it, but I need a live updated chart, and I cant get it working.
The hour/minute/second components of timeaxis ToDate are all 0
This is my update method (just test data):
I am trying to develop a live chart with minutes as Unit. This does work fine in terms of displaying it, but I need a live updated chart, and I cant get it working.
The hour/minute/second components of timeaxis ToDate are all 0
This is my update method (just test data):
Public Class ChartItem
Public Property ChartDate As Date
Public Property ChartValue As Integer
End Class
<DirectMethod()>
Public Sub GetNewLiveData()
Dim chartdata As New List(Of ChartItem)
Dim c1 As New ChartItem
Dim c2 As New ChartItem
c1.ChartDate = DateTime.Now
c1.ChartValue = New Random().Next(0, 100)
c2.ChartDate = DateTime.Now
c2.ChartValue = New Random().Next(0, 100)
Dim timeAxis As TimeAxis = DirectCast(Me.Chart1.Axes(1), TimeAxis)
If (c1.ChartDate.TimeOfDay > timeAxis.ToDate.TimeOfDay) Then
Me.Chart1.SetMarkerIndex(1)
timeAxis.SetToDate(timeAxis.ToDate.AddMinutes(1))
timeAxis.SetFromDate(timeAxis.FromDate.AddMinutes(1))
End If
chartdata.Add(c1)
chartdata.Add(c2)
Me.ChartStore.DataSource = chartdata
Me.ChartStore.DataBind()
End Sub
<ext:Chart
ID="Chart1"
runat="server"
StyleSpec="background:#fff;"
Animate="true" Height="360">
<Store>
<ext:Store ID="ChartStore" runat="server">
<Model>
<ext:Model ID="Model13" runat="server">
<Fields>
<ext:ModelField Name="ChartDate" Type="Date" />
<ext:ModelField Name="ChartValue" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Axes>
<ext:NumericAxis
Fields="ChartValue"
Title="Number of Hits"
Minimum="0"
Maximum="100">
<GridConfig>
<Odd Opacity="1" Fill="#dedede" Stroke="#ddd" StrokeWidth="0.5" />
</GridConfig>
</ext:NumericAxis>
<ext:TimeAxis
Position="Bottom"
Fields="ChartDate"
Title="Day"
DateFormat="hh:mm"
StepUnit="Minute"
Step="1"
Constrain="true"
FromDate="<%# DateTime.Now.AddMinutes(-1)%>"
ToDate="<%# DateTime.Now.addMinutes(2)%>"
Grid="true"
AutoDataBind="true"/>
</Axes>
<Series>
<ext:LineSeries Axes="Left,Bottom" XField="ChartDate" YField="ChartValue">
<MarkerConfig Size="5" Radius="5" />
</ext:LineSeries>
</Series>
</ext:Chart>
Any suggestion how to live update a chart with minutes as unit?
Last edited by Daniil; Oct 15, 2013 at 6:40 AM.
Reason: [CLOSED]