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
25
How to set X and Y axis of 3D ultrachart from DataTable (urgent)
posted

Hi,

I am using UltraChart 2009.2 version. Can we set the Source Column of X and Y axis from the DataTable? 

E.g : Consider a Product Table with columns, name, cost, qty:

ultrachart1.DataSource = dt;

ultrachart1.DataBind();

ultrachart1.Axis.X = "name";

ultrachart1.Axis.Y = "cost";

Note: I wanted to create a dynamic 3D chart from code like ColumnChart3D, BarChart3D.

Can we create a 3D chart in a composite chart.

Can Series be used in non composite chart. If yes, how? any examples

Please help!!

 

 

Parents
No Data
Reply
  • 26458
    Verified Answer
    Offline posted

    When binding to the chart, the string column gets automatically assigned as the label column and numeric columns are used as data columns. You can use series if you like, but you cannot use composite charts to render 3d charts. Here are two code snippets that uses chart binding and series binding. Both produce identical results:

    DataTable dt = new DataTable();
    dt.Columns.Add("label", typeof(string));
    dt.Columns.Add("cost", typeof(double));
    dt.Columns.Add("qty", typeof(double));
    dt.Rows.Add("item 1", 29, 100);
    dt.Rows.Add("item 2", 33, 140);
    dt.Rows.Add("item 3", 28, 150);
    dt.Rows.Add("item 4", 35, 170);

    ultraChart1.ChartType = ChartType.ColumnChart3D;

    //option 1: bind data to the chart
    ultraChart1.Data.IncludeColumn(2, false);
    ultraChart1.Data.SwapRowsAndColumns = true;
    ultraChart1.Data.DataSource = dt;
    ultraChart1.Data.DataBind();

    //option 2: bind data to the series
    NumericSeries series = new NumericSeries();
    series.Data.DataSource = dt;
    series.Data.LabelColumn = "label";
    series.Data.ValueColumn = "cost";
    series.DataBind();
    ultraChart1.Series.Add(series);
    ultraChart1.Data.DataBind();

Children