How to display complex object

4 posts, 0 answers
  1. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 24 Apr 2013 Link to this post

    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...
  2. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 24 Apr 2013 Link to this post

    I should also mention, this is all using RadChartView, but it that one isn't ready yet, is there another one I could use?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 24 Apr 2013 Link to this post

    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!
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 29 Apr 2013 Link to this post

    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.
Back to Top