Click here to Skip to main content
15,886,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a db table with data like below:
date.......chemical.......residual
1/1/2016.....CS-1111.........3
1/5/2016.....CS-1114.........2

I'm binding query to a chart, and can successfully get date and quantity to chart correctly, but I'm trying to find means of labeling each column with chemical name. An alternative would be do have each column be different color based on the chemical, and display that chemical name next to the color in legend. I prefer the first method, by which I can label the column somehow. I'm already showing the value at the top of each column, and I don't mind moving that somewhere else.

What I have tried:

<asp:Chart ID="ResidualsChart" runat="server" ImageStorageMode="UseImageLocation" ImageLocation="~/Charts/ChartPic_#SEQ(300,3)" Visible="False" Width="1000px">
<series>
<asp:Series Name="Residual" IsValueShownAsLabel="True" Legend="Legend1">

<chartareas>
<asp:ChartArea Name="ChartArea1">

<legends>
<asp:Legend Name="Legend1">





code behind:
DataTable dt = new DataTable();
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter("Select testdate, residual, chemical from dbo.Residuals where equipid = @equipid order by testdate", con);
adp.SelectCommand.Parameters.AddWithValue("@equipid", EqID.Text);
adp.Fill(dt);

if (dt.Rows.Count > 0)
{
ResidualsChart.DataSource = dt;
ResidualsChart.Series["Residual"].XValueMember = "testdate";
ResidualsChart.Series["Residual"].YValueMembers = "residual";



ResidualsChart.DataBind();
}
else
{
ResidualsChart.DataSource = null;
ResidualsChart.DataBind();
}
}
catch (Exception ex)
{
Response.Write("Error Occured: " + ex.ToString());
}
finally
{
dt.Clear();
dt.Dispose();
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900