I am trying to display 2 y axis values in an ASP.NET Chart. I can display both of the y axis that I am expecting to see but I can't seem to separate them into different colors.
AxisY Title="Loonies" - I can see them. AxisY2 Title="Toonies" - I can see them. The problem is the bars in a column and in a bar graph all show up as the same color. I have been trying different things and searching google for solutions for hours but I am really stuck. Any help would be greatly appreciated.
ASPX code
<asp:Label ID="lblChartType" runat="server" Text="Select Chart Type" Width="130"> </asp:Label>
<asp:DropDownList ID="ddlChartType" runat="server" AutoPostBack="True">
<asp:ListItem Text="Line Graph" Value="Line"></asp:ListItem>
<asp:ListItem Text="Bar Graph" Value="Bar"></asp:ListItem>
<asp:ListItem Text="Column" Value="Column"></asp:ListItem>
</asp:DropDownList>
<br /><br />
<asp:Chart ID="Chart1" runat="server" Height="275px" Width="500px">
<Titles><asp:Title Text="Coin Levels % (Last 24 Hours)" /></Titles>
<Series>
<asp:Series Name="Series1">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" >
<AxisX Title="Time"> </AxisX>
<AxisY Title="Loonies"> </AxisY>
<AxisY2 Title="Toonies"></AxisY2>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</center>
cs code public partial class Charts: System.Web.UI.Page { Shared s = new Shared();
protected void Page_Load(object sender, EventArgs e)
{
Chart1.Series["Series1"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), ddlChartType.SelectedValue);
GetChartData();
}
private void GetChartData()
{
try
{
using (SqlConnection con = new SqlConnection(s.CS))
{
SqlCommand cmd = new SqlCommand("hiddenSP", con);
cmd.CommandType = CommandType.Text;
cmd.CommandText = "hiddenSP";
Series series = Chart1.Series["Series1"];
Chart1.Series[0].XValueType = ChartValueType.Time;
Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm";
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
series.Points.AddXY(rdr["NEWSTAMP"].ToString().Replace("2016", "").Trim(), rdr["Loonies"].ToString().Replace("%","").Trim());
series.Points.AddXY(rdr["NEWSTAMP"].ToString().Replace("2016", "").Trim(), rdr["Toonies"].ToString().Replace("%", "").Trim());
}
}
}
catch (Exception ex)
{
s.WebError(ex);
}
}
}