ASP.NET Chart 2y axis distinct bar color -


i trying display 2 y axis values in asp.net chart. can display both of y axis expecting see can't seem separate them different colors.

axisy title="loonies" - can see them. axisy2 title="toonies" - can see them. problem bars in column , in bar graph show same color. have been trying different things , searching google solutions hours stuck. 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);     } } } 

problem solved!

    foreach (var item in chart1.series[0].points)              {                 if (x==0)                 {                     color c = color.fromargb(255, 0, 0);                     item.color = c;                     x++;                 }                 else                 {                     color c = color.fromargb(0, 0, 255);                     item.color = c;                     x = 0;                 } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -