吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6054|回复: 2
收起左侧

[其他转载] 【笔记】vs2010自带chart(饼图)

[复制链接]
ogre_zl 发表于 2015-12-2 08:37
本帖最后由 奋斗丶小Z 于 2015-12-2 22:47 编辑

开发环境vs2010 webform,自带chart(工具箱----数据----Chart)
饼图,效果图如下
4.jpg
前台代码:
[C#] 纯文本查看 复制代码
<asp:Chart ID="Chart3" runat="server" Width="900px">
                            <Legends>
                                <asp:Legend BackColor="Transparent" Alignment="Center" Font="Trebuchet MS, 8.25pt, style=Bold"
                                    IsTextAutoFit="False" Name="Default" LegendStyle="Column">
                                </asp:Legend>
                            </Legends>
                            <ChartAreas>
                                <asp:ChartArea Name="ChartArea1">
                                    <Area3DStyle Rotation="0" />
                                    <AxisY LineColor="64, 64, 64, 64">
                                        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
                                        <MajorGrid LineColor="64, 64, 64, 64" />
                                    </AxisY>
                                    <AxisX LineColor="64, 64, 64, 64">
                                        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
                                        <MajorGrid LineColor="64, 64, 64, 64" />
                                    </AxisX>
                                </asp:ChartArea>
                            </ChartAreas>
                        </asp:Chart>

后台代码
[C#] 纯文本查看 复制代码
Chart3.BackColor = Color.Moccasin;
            Chart3.BackGradientStyle = GradientStyle.DiagonalRight;
            Chart3.BorderlineDashStyle = ChartDashStyle.Solid;
            Chart3.BorderlineColor = Color.Gray;
            Chart3.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;

            // forma the chart area
            Chart3.ChartAreas[0].BackColor = Color.Wheat;
            // add and format the title
            Chart3.Titles.Add("个人成绩质量分布图表");
            Chart3.Titles[0].Font = new Font("Utopia", 14, FontStyle.Bold);

            Chart3.Series.Add(new Series("Pie")
            {
                ChartType = SeriesChartType.Pie,
                ShadowOffset = 2
            });
            Chart3.Series[0].Label = "#VALX \n\n #PERCENT{P}";//显示百分比和说明
            Chart3.Series[0].LegendText = "#VALX";
            double[] yValues = { 23, 12, 26, 39, };
            string[] xValues = { "优秀", "不及格", "良好", "及格" };
            //饼状图的标签方位
            Chart3.Series[0]["PieLabelStyle"] = "Outside";
            Chart3.Series[0]["PieLineColor"] = "Black";
            Chart3.Series[0].Points.DataBindXY(xValues, yValues);

            //每个部分开花
            foreach (DataPoint point in Chart3.Series[0].Points)
            {
                point["Exploded"] = "true";
            }

免费评分

参与人数 1热心值 +1 收起 理由
Christophernt + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Enter_R 发表于 2015-12-2 09:22
<asp:ChartArea Name="ChartArea1">
                                    <Area3DStyle Rotation="0" />
                                    <AxisY LineColor="64, 64, 64, 64">
                                        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
                                        <MajorGrid LineColor="64, 64, 64, 64" />
                                    </AxisY>
                                    <AxisX LineColor="64, 64, 64, 64">
                                        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
                                        <MajorGrid LineColor="64, 64, 64, 64" />
                                    </AxisX>
                                </asp:ChartArea>
                            </ChartAreas>
                        </asp:Chart>
Cizel 发表于 2015-12-2 22:47
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-9-23 05:31

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表