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
195
set X2 Axis values to a DataTable column
posted

 Hi,

 I'm using a stacked column chart and would like to set the X2 axis labels to values from a column in a datatable that I am binding the chart to.  The X axis seems to bind to the first column by default.

My chart is attached (I hope).

 My datatable looks like 

dt.Columns.Add("UserId", typeof(System.String));
dt.Columns.Add("Percentage", typeof(System.String));
dt.Columns.Add("DepartedSales", typeof(System.Double));
dt.Columns.Add("ForwardSales", typeof(System.Double));
dt.Columns.Add("Target", typeof(System.Double));

At the moment the first column appears on both X and X2 axis, but I want the 2nd column "Percentage" to appear on the X2 axis whilst keeping "UserId" on the X axis.

 Is there a way to do this?

 Thanks,

James.

Parents
  • 28496
    Offline posted

     to do this, you have to create a class that implements IRenderLabel and set it up to handle the X2 axis formatstring.  this class should store a reference to the chart's datasource, and use the current data row to get the value from the Percentage column.

    string IRenderLabel.ToString(Hashtable context)

    {

    int row = (int)context["DATA_ROW"];

    return this.theData.Rows[row]["Percentage"].ToString();

    }

Reply Children