Microsoft Chart Controls使用在頁面背景非白色的時候,會有白色的醜陋外框出現。
使用
Chart1.BorderSkin.PageColor = Color.Transparent;
Chart1.BackColor = Color.Transparent;
可以讓此外框透明化。
 
 

test1.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test1.aspx.cs" Inherits="test1" debug="True" %>

<html>

<head>

<title></title>

</head>

<body bgcolor="#000000">

 

<form id="form1" runat="server">

<asp:chart id="Chart1" runat="server" Height="296px" Width="612px" Palette="BrightPastel" imagetype="Png" BorderDashStyle="Solid" BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2" backcolor="#D3DFF0" BorderColor="26, 59, 105">

<titles>

<asp:Title ShadowColor="32, 0, 0, 0" Font="Trebuchet MS, 14.25pt, style=Bold" ShadowOffset="3" Text="" ForeColor="26, 59, 105"></asp:Title>

</titles>

<legends>

<asp:Legend IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold"></asp:Legend>

<asp:Legend Docking="Top" Name="Legend1" BackColor="Transparent"></asp:Legend>

<asp:Legend Docking="Right" Name="Legend2" BackColor="Transparent"></asp:Legend>

</legends>

<borderskin skinstyle="Emboss"></borderskin>

<series>

<asp:Series Name="test_column" BorderColor="180, 26, 59, 105" LegendText="PC數" Legend="Legend1" ChartType="Column">

<points>

</points>

</asp:Series>

</series>

<chartareas>

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

<area3dstyle Rotation="10" perspective="10" Inclination="15" IsRightAngleAxes="False" wallwidth="0" IsClustered="False"></area3dstyle>

<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>

</form>

 

</body>

</html>

 

test1.aspx.cs

 

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Drawing;

using System.Web.UI.DataVisualization.Charting;

 

public partial class test1: System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack)

{

//設定整張圖的底色為透明,四個角落及四邊不會出現白框,直接透視到底圖

Chart1.BorderSkin.PageColor = Color.Transparent;

Chart1.BackColor = Color.Transparent;

//設定Chart Title-------------------------------------------------

Chart1.Titles[0].Text = "PC數量統計";

//設定Axis Title-------------------------------------------------

Chart1.ChartAreas["ChartArea1"].AxisX.Title = "月份";

Chart1.ChartAreas["ChartArea1"].AxisY.Title = "數量";

//手動建立第一個新的data series及設定屬性-------------------------

Series series = new Series("Spline");

series.ChartType = SeriesChartType.Spline;

series.BorderWidth = 3;

series.ShadowOffset = 2;

series.LegendText = "test筆數曲線";

// Populate new series with data

series.Points.AddY(55);

series.Points.AddY(67);

series.Points.AddY(22);

// Add series into the chart's series collection

Chart1.Series.Add(series);

//手動建立第二個新的data series及設定屬性-------------------------

Series series_2 = new Series("Line");

series_2.ChartType = SeriesChartType.Line;

series_2.BorderWidth = 3;

series_2.ShadowOffset = 2;

series_2.LegendText = "test折線";

Chart1.Series.Add(series_2);

series_2.Points.AddY(45.0);

series_2.Points.AddY(39.1);

series_2.Points.AddY(90);

series_2.Points.AddY(45.4);

series_2.Points.AddY(91.6);

series_2.Points.AddY(208.6);

series_2.Points.AddY(178.3);

Chart1.Series["Line"].IsValueShownAsLabel = true;

//手動建立條狀圖值------------------------------------------------

Chart1.Series["test_column"].Points.Add(Convert.ToInt32(50));

Chart1.Series["test_column"].Points.Add(Convert.ToInt32(80));

Chart1.Series["test_column"].Points.Add(Convert.ToInt32(30));

Chart1.Series["test_column"].Points.Add(Convert.ToInt32(100));

Chart1.Series["test_column"].IsValueShownAsLabel = true;

}

}

}

 
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 adamschen9921 的頭像
    adamschen9921

    昶達的部落格

    adamschen9921 發表在 痞客邦 留言(0) 人氣()