問題:C#Chart控制項自動添加Series;結果:圖形組件Chart動態添加Series

來源:互聯網
上載者:User

標籤:

 Chart1.DataSource = dtb;            string[] strcolor = new string[20];            strcolor[0] = "220, 224, 64, 10";            strcolor[1] = "220, 252, 180, 65";            strcolor[2] = "220, 159, 100, 100";            strcolor[3] = "220, 5, 100, 146";            strcolor[4] = "91,42,0";            strcolor[5] = "19,211,188";            strcolor[6] = "0,93,70";            strcolor[7] = "185,147,240";            strcolor[8] = "194,211,252";            strcolor[9] = "49,0,93";            strcolor[10] = "245,111,5";            strcolor[11] = "203,72,178";            strcolor[12] = "93,93,0";            strcolor[13] = "165,165,147";            strcolor[14] = "124,201,15";            strcolor[15] = "14,112,201";            strcolor[16] = "0,59,93";            strcolor[17] = "5,18,108";            strcolor[18] = "245,15,54";            strcolor[19] = "121,129,234";            Chart1.Series.Clear();            for (int i = 0; i < dt.Rows.Count; i++)            {                Chart1.Series.Add(i.ToString());//添加                Chart1.Series[i.ToString()].ChartType = SeriesChartType.StackedBar;                Chart1.Series[i.ToString()].IsXValueIndexed = true;                Chart1.Series[i.ToString()].XValueMember = "Customer";                Chart1.Series[i.ToString()].YValueMembers = "StickCarQutity" + (i + 1);                Chart1.Series[i.ToString()].LegendText = dt.Rows[i]["level"].ToString();                Chart1.Series[i.ToString()].BorderColor = Color.FromArgb(180, 26, 59, 105);                Chart1.Series[i.ToString()].IsValueShownAsLabel = true;                if (i < 4)                {                    string[] number = strcolor[i].ToString().Split(new Char[] { ‘,‘ });                    int alpha = int.Parse(number[0].ToString());                    int red = int.Parse(number[1].ToString());                    int green = int.Parse(number[2].ToString());                    int blue = int.Parse(number[3].ToString());                    Chart1.Series[i.ToString()].Color = Color.FromArgb(alpha, red, green, blue);//顏色賦值                }                else                {                    if(3<i&&i<20)                    {                        string[] number = strcolor[i].ToString().Split(new Char[] { ‘,‘ });                        int red = int.Parse(number[0].ToString());                        int green = int.Parse(number[1].ToString());                        int blue = int.Parse(number[2].ToString());                        Chart1.Series[i.ToString()].Color = Color.FromArgb(red, green, blue);                    }                    else                    {                                        }                }            }            Chart1.DataBind();

html

<asp:Chart ID="Chart1" runat="server" DataMember="DefaultView" Height="700px" Width="800px">        <Legends>            <asp:Legend Docking="Top" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8pt, style=Bold">            </asp:Legend>        </Legends>        <Series>        </Series>        <ChartAreas>            <asp:ChartArea Name="ChartArea1" IsSameFontSizeForAllAxes="True">                <AxisX LabelAutoFitMaxFontSize="8" LabelAutoFitMinFontSize="5" IsReversed="True">                    <LabelStyle Font="Microsoft Sans Serif, 8pt" Interval="1" IntervalType="Auto" />                    <ScaleBreakStyle CollapsibleSpaceThreshold="10" LineColor="Transparent" BreakLineStyle="None" />                    <MinorGrid Interval="1" IntervalOffset="1" Enabled="False" />                    <MajorGrid Interval="Auto" Enabled="False" />                    <MajorTickMark Interval="Auto" Enabled="False" />                    <MinorTickMark Interval="1" Enabled="False" />                </AxisX>                <AxisY LabelAutoFitMaxFontSize="8" LabelAutoFitMinFontSize="5">                    <LabelStyle Interval="Auto" IntervalType="Auto" />                </AxisY>                <AxisX2 LabelAutoFitMaxFontSize="8" LabelAutoFitMinFontSize="5">                    <MinorGrid Interval="1" IntervalOffset="1" Enabled="False" />                    <MajorGrid Interval="Auto" />                    <MajorTickMark Interval="Auto" />                    <MinorTickMark Interval="1" Enabled="True" />                    <LabelStyle Font="Microsoft Sans Serif, 8pt" />                </AxisX2>                <AxisY2 LabelAutoFitMaxFontSize="8" LabelAutoFitMinFontSize="5">                    <LabelStyle Font="Microsoft Sans Serif, 7pt" />                    <MajorGrid Enabled="False" />                </AxisY2>            </asp:ChartArea>        </ChartAreas>    </asp:Chart>

問題:C#Chart控制項自動添加Series;結果:圖形組件Chart動態添加Series

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.