Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Converting Excel LineScatter chart to WinChart
posted

I am trying to duplicate certain aspects of an Excel chart using UltraWinChart. My Excel chart is of type XY Scatter and an example of how it looks can be seen at the URL: http://www.deatsconsulting.com/images/chart.png

So I'm using a 2D UltraWinChart type ScatterLineChart and providing the same series data my results look something like this: http://www.deatsconsulting.com/images/chart2.png 

 

Questions:
1. I need to know if I am feeding the data properly. So the Excel chart has two series. Each series is a collection of x,y points (pulled using a range formula in Excel). I have many choices for duplicating this behavior in .NET, but it appears the only way to feed data into an UltraWinChart is through a DataTable. So I am creating a DataTable dynamically and programmatically defining the table schema and adding the rows, again my goal to simply have two series of data. In the case of this chart, the X axis data will always be the same for both series so my DataTable has the following numeric columns: X, Y1, Y2. The rows contain identical data to that found in the Excel series and the resulting plot you can see in the png images above. Is there a better way to feed this data? Can I simply create series of X,Y points and add them to the UltraWinChart instead of data binding?

2. I would like a fixed Y axis range from -150 (bottom) to 200 top as demonstrated in the chart.png image above. I did find the .Axis.Y.RangeMin and .Axis.Y.RangeMax values, however these properties seem to be ignored when data binding is used. Can someone explain how to properly set Axis ranges both using data binding and using series data?

3.  At the 0 point on my Y axis I would like a horizontal line with labeled tick marks at each increment (incredment of 1, range 1-14) an example can be seen in the chart.png image at the hyperlink above. I am able to get this data to plot (see chart2.png) but it appears as a green line with no tick marks. Perhaps I'm not using the proper UltraWinChart type to accomplish my goal?

Short code examples greatly appriciated!

  

Parents
  • 185
    posted

    What's provided below are answers to some of my questions. I am still unable to successfully render a a group of x,y series (so if anyone is reading with answers, please help), but I have some details.

     

    1. Series data can be used as an alternative to binding data (i.e. DataTable) for some, but not all chart types. Series data can not be used with ScatterLineChart type, however to mimic the desired Excel chart the  proper WinChart type would be ScatterChart with ConnectWithLines property set to true. The ScatterChart type can use Series data or can be bound to a DataTable. Here's an example of how to apply series data.

    XYSeries s1 = new XYSeries();
    s1.Points.Add(new XYDataPoint(50.0,  100.0,  "",  false);
    ...
    ultraWinChart1.Series.Add(s1);

    To achieve this using a DataTable you would create a three column Table, two numeric columns for the points and a text column for the grouping.

     DataTable dt = new DataTable();
     dt.Columns.Add("X", Type.GetType("System.Double"));
     dt.Columns.Add("Y", Type.GetType("System.Double"));
     dt.Columns.Add("Series", Type.GetType("System.String"));

    // add rows here 

    ultraWinChart.ScatterChart.ColumnX = 0;
    ultraWinChart.ScatterChart.ColumnY= 1;
    ultraWinChart.GroupByColumn = 2;
    ultraWinChart.UseGroupByColumn = true;
    ultraWinChart.DataSource = dt;

     

    2. After setting RangeMin and RangeMax you must set RangeType to Custom to make them take effect. RangeMin and RangeMax will work with bound data and series data. Here is a code example:

      ultraChart1.Axis.X.RangeMin = 0;
      ultraChart1.Axis.X.RangeMax = 14;
      ultraChart1.Axis.Y.RangeMin = -150;
      ultraChart1.Axis.Y.RangeMax = 200;
      ultraChart1.Axis.X.RangeType = Infragistics.UltraChart.Shared.Styles.AxisRangeType.Custom;
      ultraChart1.Axis.Y.RangeType = Infragistics.UltraChart.Shared.Styles.AxisRangeType.Custom;

     

    3. The ScatterChart doesn't support this by default, however the behavior in the Excel Scatter Line chart can probably be recreated by always adding a series with Y set to 0, set the series color to match the chart outline (black) and then use X as the label. 

     

     

Reply Children
No Data