⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elementtemplate.aspx

📁 掌握学习.net开发的非常好的资料
💻 ASPX
字号:
<%@ Page Language="C#"  debug="true" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet"  Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>


<script runat="server">

SeriesCollection getRandomData()
{
	SeriesCollection SC = new SeriesCollection();
	Random myR = new Random();
	for(int a = 1; a < 5; a++)
	{
		Series s = new Series();
		s.Name = "Series " + a;
		for(int b = 1; b < 5; b++)
		{
			Element e = new Element();
			e.Name = "Element " + b;
			//e.YValue = -25 + myR.Next(50);
			e.YValue = myR.Next(50);
			s.Elements.Add(e);
		}
		SC.Add(s);
	}

	

	return SC;
}


void Page_Load(Object sender,EventArgs e)
{

	Chart.Type = ChartType.Combo;
	Chart.TempDirectory = "temp";
	
	////////////////////// Using templates //////////////////////
	
	// In this sample we will demonstrate how templates can be used.
	
	// Lets start with the x axis tick labels. The ticks are groups of elements with the same name. 
	// For this group we will show what percenrage of the total data this group represents with the
	// %YPercentOfTotal token. We will also show the average value of the group.
	
	Chart.XAxis.TickLabel.Text = "%Name (%YPercentOfTotal) Avg:%YAverage";
	
	// Because the y axis is a value axis templates can't be used on it.

	// The element labels can also be modified with these templates. Lets show the value, what percent the 
	// group the element makes up and what percent of the total the element is.
	
	// First in order to show the values we have to set the ShowValue property.
	Chart.DefaultSeries.DefaultElement.ShowValue = true;
	
	Chart.DefaultSeries.DefaultElement.LabelTemplate = "%YValue (G: %YPercentOfGroup) (T: %YPercentOfTotal)";
	// OR ( These properties are the same )
	Chart.DefaultSeries.DefaultElement.SmartLabel.Text = "%YValue (G: %YPercentOfGroup) (T: %YPercentOfTotal)";
	
	
	// Even more info can be shown by using templates in tool tips. These are supported for elements and legend entries.
	
	// We'll add a tool tip to the elements here.
	Chart.DefaultSeries.DefaultElement.ToolTip = "%name is \r%YPercentOfSeries of %SeriesName";
	
	////////////////////// Embeding format string into templates //////////////////////
	
	// We can embed format string into our chart by using this syntax: <(token),(FormatString)>
	// To demonstrate we will overwrite the 1st elements template to show the value as currency.
	
	// To begin we will get our data
	SeriesCollection sc = getRandomData();
	
	// The template will look like this:
	sc[0].Elements[0].LabelTemplate = "<%YValue,Currency>";
	
	// Just another example for the second series
	sc[1].Elements[0].LabelTemplate = "<%YValue,{0:#0.000}>";
	

	////////////////////// Creating clickable charts using templates //////////////////////
	
	// We dont have any where to redirect so lets pretend site.aspx is a website that will understand 
	// the info we're going to send
	
	Chart.DefaultSeries.DefaultElement.URL = "clicked.aspx?series=%SeriesName&element=%Name";
	
	// Note: You may also use Element/LegendEntry.URLTarget = "_blank" for example to specify the link target.
	
	
	
	

	// Add the random data.
	Chart.SeriesCollection.Add(sc);
    
    
}
</script>
<HTML><HEAD><TITLE>Elements Template</TITLE></HEAD>
<BODY>
<DIV align=center>
 <dotnet:Chart id="Chart"  runat="server"/>
</DIV>
</BODY>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -