locked
HOW TO ADD SERIES IN CHART DYNAMICALLY ?? NEED REFERENCES !! not able to add series in this program. RRS feed

  • Question

  • FRONT END( WHAT ELSE I HAVE TO RIGHT IN THE FRONT PAGE  ACCORDING TO DYNAMIC UPADTE FROM STORED PROCEDURE )

    --------------------------------------------------------------------------------------------------------------------------------------------

    <asp:Chart ID="chtCampaignHits" runat="server" BackColor="76, 125, 126"
    BorderDashStyle="Solid" BackSecondaryColor="White" BackGradientStyle="DiagonalLeft"
    BorderWidth="2px" BorderColor="#1A3B69">
    <BorderSkin SkinStyle="Emboss" />

    <ChartAreas>
    <asp:ChartArea Name="MainChartArea" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid"
    BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent"
    BackGradientStyle="TopBottom">
    </asp:ChartArea>
    </ChartAreas>
    </asp:Chart>

    .CS FILE (DYNAMIC UPDATE FROM STORED PROCEDURE)

    -------------------------------------------------------------


    if (dt.Rows.Count != 0)
    {

    //var v = (from row in dt.AsEnumerable()
    // select row.Field<Int64>("Campaigntitle").ToString()).Distinct<string>(); priviouly this code

    var v = (from Rows in dt.AsEnumerable()
    select Rows.Field<string>("Campaigntitle").ToString()).Distinct<string>();

    foreach (string s in v)
    {
    Console.WriteLine(s);

    foreach (DataRow row in dt.Rows)
    {
    if (row.HasErrors)
    {
    Console.WriteLine(row.RowError);
    }
    }
    // SHOULD I USE ROWFILTER OR ITS OPTIONAL.
    dt.DefaultView.RowFilter = "count=" + s;  //TILL THIS THE CODE RUNNING FIND. WHEN COMES TO ADD SERIES IN GOING TO CATCH EXCEPTION. NEED  YOUR HELP !! 
    chtCampaignHits.Series[s].Enabled = true;
    chtCampaignHits.Series.Add(new Series(s)); 
    chtCampaignHits.Series[s].Label = s;

    chtCampaignHits.Series[s].ChartArea = "MainChartArea";
    chtCampaignHits.Series[s].ChartType = SeriesChartType.Line; //priviously chat was SeriesChartType.Spline;
    chtCampaignHits.Series[s].BorderWidth = 3;
    //this was above priviouly
    chtCampaignHits.Series[s].Points.DataBindXY(dt.DefaultView, "Campaigntitle", dt.DefaultView, "hits");

    }
    chtCampaignHits.Legends.Add("Legend1");

    chtCampaignHits.Legends["Legend1"].Enabled = true;
    //chtCampaignHits.Legends["Legend1"].Alignment = System.Drawing.StringAlignment.Near;
    chtCampaignHits.Legends["Legend1"].LegendStyle = LegendStyle.Row;
    chtCampaignHits.Legends["Legend1"].Docking = Docking.Bottom;
    chtCampaignHits.Legends["Legend1"].BackColor = System.Drawing.Color.FromName("#4C7D7E");
    chtCampaignHits.Legends["Legend1"].BackGradientStyle = GradientStyle.DiagonalLeft;
    }
    }
    catch (Exception)
    {

    Response.Write("Error in FillChartInfo");
    }

    Friday, November 6, 2015 7:48 AM