仔细看了Scott写的如何开发MSchart,但始终还是有一个地方不明白,原话上说:可用于免费使用ASP.NET 3.5 。但在官方网站上的MSChart板块又看到了license,如果真有人想用的话,可以打微软的销售电话8008203800,或者等我知道了,我会为大家解答,因为这个好东西,我肯定会找机会用在我的项目里
今天又把MSChart拿出来研究,由于没有帮助文档,网上也没有案例和资料,唯一的一个帮助就是Microsoft给的200个例子。于是就看源码,看属性,尝试着每个属性的作用 -_- 这是很辛苦的
ok 终于基本搞懂了一些 首先介绍一下这两个图的做法
我把源码贴出来这是前台的
<asp:chart id="Chart1" runat="server" Height="250px" Width="400px" ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)" Palette="BrightPastel" imagetype="Png" BorderDashStyle="Solid" BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2" backcolor="#D3DFF0" > <legends> <asp:Legend IsTextAutoFit="true" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style="Bold" mce_style="Bold""></asp:Legend> </legends> <borderskin skinstyle="Emboss"></borderskin> <series> <asp:Series Name="2007 Air" CustomProperties="MinPixelPointWidth=1, PixelPointWidth=30, DrawingStyle=Cylinder, MaxPixelPointWidth=30, DrawSideBySide=True, PointWidth=0" Color="224, 224, 224" Font="Times New Roman, 9pt" MarkerColor="Navy" MarkerSize="12" BorderWidth="3" ShadowOffset="2" IsValueShownAsLabel="True" LabelForeColor="64, 0, 0" > <points> <asp:DataPoint YValues="0.9" AxisLabel="BBU" /> <asp:DataPoint YValues="0.9" AxisLabel="MCBU" /> <asp:DataPoint YValues="0.91" AxisLabel="TBU" /> </points> <EmptyPointStyle IsValueShownAsLabel="True" LabelAngle="15" LabelBackColor="Olive" LabelForeColor="RosyBrown" MarkerSize="12" /> <SmartLabelStyle CalloutLineColor="DarkRed" CalloutLineAnchorCapStyle="Diamond" CalloutStyle="None" /> </asp:Series> </series> <chartareas> <asp:ChartArea Name="Air" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent" BackGradientStyle="TopBottom"> <area3dstyle PointDepth="150" PointGapDepth="150" Rotation="15" perspective="2" Inclination="20" LightStyle="Realistic" wallwidth="0" IsClustered="False"></area3dstyle> <axisy linecolor="64, 64, 64, 64" > <labelstyle font="Trebuchet MS, 8.25pt, style="Bold" mce_style="Bold"" /> <majorgrid linecolor="64, 64, 64, 64" /> </axisy> <axisx linecolor="64, 64, 64, 64" > <labelstyle font="Trebuchet MS, 8.25pt, style="Bold" mce_style="Bold"" /> <majorgrid linecolor="64, 64, 64, 64" /> </axisx> </asp:ChartArea> </chartareas> </asp:chart><br /> <asp:chart id="Chart2" runat="server" Height="250px" Width="400px" ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)" Palette="BrightPastel" imagetype="Png" BorderDashStyle="Solid" BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2" backcolor="#D3DFF0" > <legends> <asp:Legend IsTextAutoFit="true" Alignment="Center" Docking="Top" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style="Bold" mce_style="Bold""></asp:Legend> </legends> <borderskin skinstyle="Emboss"></borderskin> <series> <asp:Series Name="TBU int`1 ( Ship/CW)" MarkerSize="8" BorderWidth="3" XValueType="Double" ChartType="Line" MarkerStyle="Circle" ShadowColor="Black" BorderColor="180, 26, 59, 105" Color="Red" ShadowOffset="2" YValueType="Double"> </asp:Series> <asp:Series Name="TBU China (include GSM)(Ship/CW)" ChartType=Line BorderWidth="3" ShadowOffset="2" MarkerSize="8" MarkerStyle="Circle" ShadowColor="Black" BorderColor="180, 26, 59, 105"> </asp:Series> </series> <chartareas> <asp:ChartArea Name="Ship/CW" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent" BackGradientStyle="TopBottom" IsSameFontSizeForAllAxes="True" > <area3dstyle PointDepth="150" PointGapDepth="150" Rotation="15" perspective="2" Inclination="20" LightStyle="Realistic" wallwidth="0" IsClustered="False"></area3dstyle> <axisy linecolor="64, 64, 64, 64" > <labelstyle font="Trebuchet MS, 8.25pt, style="Bold" mce_style="Bold"" /> <majorgrid linecolor="64, 64, 64, 64" /> </axisy> <axisx linecolor="64, 64, 64, 64" > <labelstyle font="Trebuchet MS, 8.25pt, style="Bold" mce_style="Bold"" /> <majorgrid linecolor="64, 64, 64, 64" /> </axisx> </asp:ChartArea> </chartareas> </asp:chart>
这是后台的
protected void Page_Load(object sender, EventArgs e) { showAirExample(); ShowPointExample(); } protected void showAirExample() { Series series = new Series("2008 Air"); series.ChartType = SeriesChartType.Column; series["DrawingStyle"] = "Cylinder"; series.IsValueShownAsLabel = true; series.BorderWidth = 3; series.ShadowOffset = 2; series["PixelPointWidth"] = "30"; // Populate new series with data series.Points.AddY(0.281); series.Points.AddY(1); series.Points.AddY(1); // Add series into the chart's series collection Chart1.Series.Add(series); Chart1.Series["2008 Air"].ChartType = SeriesChartType.Column; // Show as 3D Chart1.ChartAreas["Air"].Area3DStyle.Enable3D = false; // Draw as 3D Cylinder Chart1.Series["2008 Air"]["DrawingStyle"] = "Cylinder"; Chart1.Series["2008 Air"].LabelForeColor = Color.FromArgb(0, 0, 192); } protected void ShowPointExample() { Random random = new Random(); for (int pointIndex = 0; pointIndex < 5; pointIndex++) { Chart2.Series[0].Points.AddY(random.Next(45, 95)); Chart2.Series[1].Points.AddY(random.Next(5, 75)); } // Set point labels //Chart2.Series["TBU int`1 ( Ship/CW)"].IsValueShownAsLabel = true; //Chart2.Series["TBU China (include GSM)(Ship/CW)"].IsValueShownAsLabel = true; // Enable X axis margin Chart2.ChartAreas["Ship/CW"].AxisX.IsMarginVisible = false; // Enable 3D, and show data point marker lines Chart2.ChartAreas["Ship/CW"].Area3DStyle.Enable3D = false; Chart2.Series[0]["ShowMarkerLines"] = "True"; Chart2.Series[1]["ShowMarkerLines"] = "True"; }
如何配置就是我上一篇文章说的那样 可以看这里 vs2008 开发3D 报表 MSChart 开发全过程 带附件下载 开发日志(一)