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

How to display complex object

3 Answers 69 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 24 Apr 2013, 11:19 PM
Hello,

We've got a complex domain model and I want to display different series in the chart view. Nothing extremely fancy, something like this:

class Data {
public float Y1 {get;set;}
public float Y2 {get;set;}
public float Y3 {get;set;}
public TimeSpan When {get;set;}
public float Sum {get{return Y1+Y2+Y3;}}
public byte Address {get;set;}
}

And so on, along these lines. We'll want to take an IEnumerable<Data> and GroupBy(x => x.Address) then display each of those groups in a series of their own.

It's actually a little more complex than that, there will be calculators running, and lambdas, but should be transparent to the chart view. SHOULD BE. Oh, and I want to display these ordered in the time domain: When (TimeSpan, time into test) is my X axis. Some function of the Y's are my Y axis.

Thus far I can get the series to at least appear and title themselves in the legend, so I have some visual feedback that that much is working. However, I get no data displaying in the LineSeries at all. It's all flat lines so far, but I do get some series there, so I know it's trying.

How do I instruct the chart to find our data?

Thank you...

3 Answers, 1 is accepted

Sort by
0
Travis
Top achievements
Rank 1
answered on 24 Apr 2013, 11:40 PM
I should also mention, this is all using RadChartView, but it that one isn't ready yet, is there another one I could use?
0
Travis
Top achievements
Rank 1
answered on 25 Apr 2013, 12:33 AM
Some tips would be helpful. I've basically got 'er going with the following line(s).

int count = 0;
var grouped = data.GroupBy(x => new { x.Address, });
foreach (var g in grouped) {
 
var series = new LineSeries() {
  Name = "SuchandSuch"+(count++);
  LegendTitle = "SuchandSuch"+count,
  //...
};
series.DataPoints.AddRange(g.Select(x => new CategoricalDataPoint(x.C, x.When)));
MyChartView.Series.Add(series);
}

Basically something like that. Now we have to work on stylistic elements like series opacity (or rather transparency), but that's all bells and whistles stuff.

Any tips what to do with a dense X axis? Are there averaging features? Or is that a separate service we'll need to wire up around the data source?

Thank you!
0
Peter
Telerik team
answered on 29 Apr 2013, 01:52 PM
Hello Michael,

Thank you for writing.

You approach is correct - you should add a separate LineSeries for each parameter of your object. Please, refer to this help article, which describes how you can use a palette for your chart view. Palettes are a quick and easy way to define a skin for your chart view.

You should manipulate the data by yourself in order to "dense" the X Axis e.g. we do not have methods or services for data summarization.

I hope that you find this information useful.

Kind regards,
Peter
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Tags
ChartView
Asked by
Travis
Top achievements
Rank 1
Answers by
Travis
Top achievements
Rank 1
Peter
Telerik team
Share this question
or