c# web Column chart(包含美观的样式)
来源:互联网 发布:淘宝提前收款不能用了 编辑:程序博客网 时间:2024/05/29 17:21
1)前台代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication51.Default" %><%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <asp:Chart ID="Chart1" runat="server" Palette="BrightPastel" BackColor="#D3DFF0" Width="412px" Height="296px" BorderlineDashStyle="Solid" BackGradientStyle="TopBottom" BorderWidth="2" BorderColor="181, 64, 1"> <Titles> <asp:Title ShadowColor="32, 0, 0, 0" Font="Trebuchet MS, 14.25pt, style=Bold" ShadowOffset="3" Text="Money of student" Name="Title1" ForeColor="26, 59, 105"> </asp:Title> </Titles> <Legends> <asp:Legend TitleFont="Microsoft Sans Serif, 8pt, style=Bold" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="False" Enabled="False" Name="Default"> </asp:Legend> </Legends> <BorderSkin SkinStyle="Emboss"></BorderSkin> <Series> <asp:Series Name="Series1" BorderColor="180, 26, 59, 105" ChartType="Column" IsValueShownAsLabel="true"> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BackSecondaryColor="White" BackColor="Transparent" ShadowColor="Transparent" BackGradientStyle="TopBottom"> <Area3DStyle Rotation="10" Perspective="10" Inclination="15" IsRightAngleAxes="False" WallWidth="0" IsClustered="False" /> <AxisY LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8" TitleFont="Trebuchet MS, 10.25pt"> <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" /> <MajorGrid LineColor="64, 64, 64, 64" /> </AxisY> <AxisX LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8" TitleFont="Trebuchet MS, 10.25pt"> <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" IsEndLabelVisible="False" Format="MM-dd" /> <MajorGrid LineColor="64, 64, 64, 64" /> </AxisX> </asp:ChartArea> </ChartAreas> </asp:Chart> </div> </form></body></html>
2)后台代码
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.DataVisualization.Charting;namespace WebApplication51{ public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindStudent(); } } /// <summary> /// 后台绑定 /// </summary> private void BindStudent() { List<Student> items = GetStudents(); Series series = Chart1.Series[0]; foreach (Student item in items) { DataPoint dataPoint = new DataPoint(); dataPoint.SetValueXY(item.Name, item.Money); series.Points.Add(dataPoint); } Chart1.ChartAreas[0].AxisX.Title = "Student Name"; Chart1.ChartAreas[0].AxisY.Title = "Money($)"; } private List<Student> GetStudents() { List<Student> items = new List<Student>(); items.Add(new Student("Chad", 1)); items.Add(new Student("Catherine", 4)); items.Add(new Student("Amamda", 3)); items.Add(new Student("Emily", 2)); return items; } } public class Student { public Student() { } public Student(string _name, decimal _money) { this.Name = _name; this.Money = _money; } public string Name { set; get; } public decimal Money { set; get; } }}
3)错误解决方法
错误:Error executing child request for ChartImg.axd.
解决方法:在web.config 的<system.web>节点小添加如下代码
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
</httpHandlers>
- c# web Column chart(包含美观的样式)
- c# web pie chart(包含美观的样式)
- c# web Line chart(包含美观的样式)
- c# Chart设置样式
- c# Chart设置样式
- 一个美观的gridview样式
- 单选框、复选框美观的样式
- C#的chart图形
- 求助,实用美观的WEB编辑器
- C#一款比较美观的验证码
- 各种美观DIV样式
- Flex: Stacked column chart
- Silverlight Column Chart
- 美观实用的 侧导航菜单样式(JS+CSS)
- 关于ASP.net Chart- Column图改变Points上标Label文字样式
- C# Chart控件的安装
- C# Chart控件的使用方法
- C#内置chart的例子
- 告别程序员生涯,一点感慨,与诸君共勉
- 制作JFFS2镜像以及挂载到PC
- linux服务自动启动
- MRS MSR 缩写
- Installshield自动安装IIS组件
- c# web Column chart(包含美观的样式)
- Java语言的环境搭建
- Android之SQlite学习小结
- 编写MR运行在Hbase上面注意事项
- 通过yum 安装 chrome 和flash 插件
- Log工具-Log4c 使用
- 以无线方式安装应用程序
- Linux安装程序详解
- OC sha1+base64加密 以及 十进制转十六进制