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
115
Sorting by Column with UltraChart
posted

Hi,

I'm looking for a way to sort data by a column as it is displayed in a BarChart.

At present I have the following:

DataTable table;
table.Columns.Add("Key", typeof(int));
table.Columns.Add("Labels", typeof(string)); // the Key in string format
table.Columns.Add("Value1", typeof(double));
table.Columns.Add("Value2", typeof(double));

// ...Populate datatable...

chart.DataSource = table;
chart.DataBind();

      foreach (DataColumn col in table.Columns)
      {
        if(col.ColumnName.Equals("Key"))
        {
          chart.Data.IncludeColumn(col,false);
        }
        else
        {
          chart.Data.IncludeColumn(col, true);
        }
      }

At present the labels are appear (in no useful order) along one of the axes, and the "Value1" and "Value2" are shown as bars for each label.

I'd like to sort the table by "Key" and then have that reordering reflected in the order of the labels on the axis of the chart.

Does anyone know how to do this? I am using v8.2

Many thanks,
Luke