This is a migrated thread and some comments may be shown as answers.

Problems with DateTimeContinousAxis / LinearAxis

3 Answers 186 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ManniAT
Top achievements
Rank 2
ManniAT asked on 05 Jun 2011, 04:47 PM
Hi,

I tried to bind a RadCartesianChart to an ObservableCollection of objects.
The Objects have a DateTime field and an interger value field.

First problem - binding the integer value field doesn't work.
So I changed the type to double which works - at least with design time data.

At runtime I get problems.
When I add my first record my apps hangs somewhere in RadCharting.
I guess this is because I have a single value in there.

By the way - I didn't even want to take the DateTimeContinousAxis, but I couldnt get the things to run with a linear Axis.
Unfortunately there is no example with XAML binding.

Maybe you can help me.
I have an object looking like this:
class TheDataEntry {
public int AgeInSeconds { get; }
public double AgeInSecondsDouble { get { return(AgeInSeconds); //helper for chart binding }
public int TheValue { get; }
public double TheValueDouble { get { return(TheValue); //helper for chart binding }
public DateTime RecordDate { get; }
}
And further I have
class DataHolder {
public ObservableCollection<TheDataEntry> Records { get; }
}
The code (working with design time data) looks like this:
<telerikChart:RadCartesianChart Grid.Row="3" x:Name="radChart1" >
    <telerikChart:RadCartesianChart.XAxis>
        <telerikChart:DateTimeContinuousAxis MajorTickStep="10"
                                 LabelFormat="HH:mm:ss"
                                 PlotMode="OnTicks"
                                 Style="{StaticResource timeLineAxisStyle}">
            <telerikChart:DateTimeContinuousAxis.LabelStyle>
                <Style TargetType="TextBlock" BasedOn="{StaticResource textBlockStyle}">
                    <Setter Property="Width" Value="50"/>
                </Style>
            </telerikChart:DateTimeContinuousAxis.LabelStyle>
        </telerikChart:DateTimeContinuousAxis>
    </telerikChart:RadCartesianChart.XAxis>
    <telerikChart:RadCartesianChart.YAxis>
        <telerikChart:LinearAxis Minimum="0" 
                     LineStroke="Transparent"
                     Style="{StaticResource linearAxisStyle}"/>
    </telerikChart:RadCartesianChart.YAxis>
    <telerikChart:RadCartesianChart.Grid>
        <telerikChart:CartesianChartGrid MajorLinesVisibility="XY" Style="{StaticResource gridStyleDashedAll}" MajorXLinesRenderMode="All"/>
    </telerikChart:RadCartesianChart.Grid>
    <telerikChart:LineSeries Stroke="{StaticResource Series1Brush}" ItemsSource="{Binding TheRecorder.Records}">
        <telerikChart:LineSeries.ValueBinding>
            <telerikChart:PropertyNameDataPointBinding PropertyName="TheValueDouble" />
        </telerikChart:LineSeries.ValueBinding>
        <telerikChart:LineSeries.CategoryBinding>
            <telerikChart:PropertyNameDataPointBinding PropertyName="RecordDate" />
        </telerikChart:LineSeries.CategoryBinding>
    </telerikChart:LineSeries>
  
</telerikChart:RadCartesianChart>


My approach is to bind this data to a LineChart.
So XAxis should be "AgeInSeconds" and YAxis TheValue.

I have no problems using doubles - but ATM I get nothing when I try to use LinearAxis.

Thanks in advance
Manfred
PS: I attached a screenshot of what I get with design time data and the above XAML

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 08 Jun 2011, 03:58 PM
Hi Manfred,

Please, accept my apologies for the delayed answer. We had a problem with our support system not displaying the new threads.

Currently our RadChart supports only Categorical series - that is series that need a Categorical axis in order to be properly plotted. The DateTimeContinuous axis is a hybrid between a linear and a categorical axis and it supports Categorical series. That is why at this stage you cannot setup a chart with two linear axes. We will implement yet another branch of series - the so called Scatter (ScatterLine, ScatterArea, etc.) series which will be plotted either by two linear axes or by linear and a DateTimeContinuous axes.

Regarding the problems you are experiencing:

- Binding to int
This is actually a bug. We are recognizing all numerical types if supplied as ItemsSource directly but not when coming from a business object.

- Adding first point hangs the chart
This is also a bug. The axis will try to calculate the minimum timespan between any two points and when there is only one point this span will be zero, hence an endless loop is entered.

Please, note that a LineChart with a single point will not be visible - at least two points are needed to render a line. You may additionally specify a PointTemplate, which will visualize the point marker itself.

We are just completing the Chart documentation and it should be available on-line tomorrow. We are planning to add more simple examples to our Demo Application that may be used as an entry point for different scenarios. We are also working on a Chart gallery (just like for our Gauges), which will allow you to select a predefined chart template to start from in design-time. This gallery should be available for the BETA 2, expected within 3 weeks.

Thank you very much for your precious feedback - it is much appreciated and helpful. I have added 2000 Telerik points to your account as a token of our gratitude for your time.

Do not hesitate to contact us with any questions/problems you may have - we will be more than happy to help.

All the best,
Georgi
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
ManniAT
Top achievements
Rank 2
answered on 08 Jun 2011, 04:14 PM
Hi Georgi,

thank you for the answer.
A few questions about it:
>>Please, note that a LineChart with a single point will not be visible - at least two points are needed to render a line.
Of course - but with declarative binding there is a point in time, when the one and only first point exists.
Since this is a bug (hangs with one point) it should work as expected in the future. I expect:
-- I add one point (my first datapoint I get) - no line
-- I add (later) a second point - and get a line between the first and the second one

If I understand you right a simple X-Y Plotting is not available. But there is a way to achive this using datetime values.
In simple words - I have an integer X axis. All I have to do is to provide an extra property - type DateTime - use a "Starttime" and add my X value as (let's say) second to this start value.
Instead of a X Series 1,30,50,70, 75 (int) I use 20:17:01,20:17:30, 20:17:50, 20:18:10, 20:18:15 - am I right?
And I guess (hope) I can write some converter which to display the labels as 1, 30, 50,...

Could you pleas tell me if my ideas are some kind of "useable"? :)
Since I love the quality of Telerik controls I'm willing to use some "workarounds with the new ones" till they reach a level where the needed functionallity is "built in".

Thank you
Manfred
0
Georgi
Telerik team
answered on 09 Jun 2011, 11:32 AM
Hi Manfred,

Thanks for getting back to me.

Regarding your questions:

- Yes, LineSeries will not render a line for one point, only the point marker (if specified). Otherwise they will work well with zero, one or more data points.

- You can do that trick with the DateTimeContinuous axis but you have to convert your values to the desired DateTime structure. This approach however will have a performance hit compared to a standard linear axis since the DateTime axis will perform more complex logic in order to build its time slots and to find the appropriate step.

We will do our best to add the Scatter series for the BETA 2 release so that you do not have to do such workarounds :)

Regards,
Georgi
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Chart
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Georgi
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or