1:(1)曲线图
<%@ Page Language="C#" Debug="true" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="dotnetCHARTING"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>dotnetCHARTING Sample</title>
</head>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
//Enable zooming with just one property
Chart.Zoomer.Enabled = true;
//limit the number of elements in view port
Chart.XAxis.Viewport.ElementCount =10;
Chart.Debug = true;
Chart.TempDirectory = "temp";
Chart.ShadingEffect = true;
Chart.YAxis.Label.Text = "Salary / Year";
Chart.YAxis.FormatString = "currency";
Chart.XAxis.Label.Text = "Employee Code";
Chart.PaletteName = dotnetCHARTING.Palette.Bright;
Chart.Type = ChartType.Combo;
Chart.Size = "600x350";
Chart.Title = "A chart with zooming, right click on the chart to access zooming";
Chart.DefaultSeries.Type = SeriesType.Spline;
Chart.LegendBox.Position = LegendBoxPosition.None;
Chart.YAxis.Scale = Scale.Stacked;
Chart.DefaultElement.ShowValue = true;
Chart.DefaultSeries.DefaultElement.ToolTip = "%name of %SeriesName";
SeriesCollection mySC= getRandomData();
Chart.SeriesCollection.Add(mySC);
Element Mean = mySC[0].Calculate("",Calculation.Mean);
AxisMarker am = new AxisMarker("Mean",new Line(Color.Green,1), Mean.YValue);
am.Label.Alignment = StringAlignment.Near;
Chart.YAxis.Markers.Add(am);
}
SeriesCollection getRandomData()
{
SeriesCollection SC = new SeriesCollection();
Random myR = new Random(1);
for(int a = 1; a < 2; a++)
{
Series s = new Series();
s.Name = "Series " + a;
for(int b = 1; b < 100; b++)
{
Element e = new Element();
e.Name = "Emp # " + b;
e.YValue = myR.Next(25000,100000);
s.Elements.Add(e);
}
SC.Add(s);
}
return SC;
}
</script>
<body>
<center>
<dotnet:Chart ID="Chart" runat="server" />
</center>
</body>
</html>
(2)
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="dotnetCHARTING"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
void Page_Load(Object sender,EventArgs e)
{
// This sample demonstrates the use of NormalDistribution method from the StatisticalEngine. This method return the normal distribution for a series when the standard deviation is known. The mean is calculated using the arithmetic mean of the XValues of the given series
// The Probability Chart
ProbabilityChart.Title="Standard Normal distribution";
ProbabilityChart.TempDirectory="temp";
ProbabilityChart.Debug=true;
ProbabilityChart.Size = "600x400";
ProbabilityChart.LegendBox.Template ="%icon %name";
ProbabilityChart.XAxis.Scale = Scale.Normal;
ProbabilityChart.XAxis.Maximum = 5;
ProbabilityChart.YAxis.ScaleRange.ValueHigh = 0.5;
ProbabilityChart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
ProbabilityChart.DefaultSeries.DefaultElement.Marker.Visible = true;
ProbabilityChart.DefaultSeries.Type = SeriesType.Spline;
ProbabilityChart.ChartAreaLayout.Mode = ChartAreaLayoutMode.Vertical;
SeriesCollection sprobability = new SeriesCollection();
// Generate the sample data.
Series sampledata1 = new Series ("Sample Data");
sampledata1.Elements.Add (new Element("",0.0,0.03125));
sampledata1.Elements.Add (new Element("",1.0,0.15625));
sampledata1.Elements.Add (new Element("",2.0,0.31250));
sampledata1.Elements.Add (new Element("",3.0,0.31250));
sampledata1.Elements.Add (new Element("",4.0,0.15625));
sampledata1.Elements.Add (new Element("",5.0,0.003125));
sprobability.Add (sampledata1);
// Add the series collection to the chart
ProbabilityChart.SeriesCollection.Add(sprobability);
// The second parameter of this method is the standard deviation of the normal probability distribution
Series normalDistribution = StatisticalEngine.NormalDistribution(sampledata1, 1);
normalDistribution.Type = SeriesType.Spline;
ProbabilityChart.SeriesCollection.Add (normalDistribution);
}
</script>
</head>
<body>
<div style="text-align:center">
<dotnet:Chart id="ProbabilityChart" runat="server"/>
</div>
</body>
</html>
直方图
<%@ Page Language="C#" Debug="true" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>dotnetCHARTING Sample</title>
</head>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
//This chart is with zooming, right click on the chart to access zooming
Chart.TempDirectory = "temp";
Chart.XAxis.FormatString = "MMM yyyy";
Chart.Debug = true;
Chart.LegendBox.Position = LegendBoxPosition.None;
Chart.ShadingEffect = true;
Chart.PaletteName = dotnetCHARTING.Palette.Bright;
Chart.Type = ChartType.Combo;
Chart.Size = "800x350";
Chart.Title = "Chart without zooming";
Chart.DefaultSeries.Type = SeriesType.Bar;
Chart.XAxis.TimeInterval = TimeInterval.Month;
Chart.YAxis.Interval = 1;
Chart.DefaultSeries.DefaultElement.ToolTip = "%yValue";
Chart.DefaultElement.ShowValue = true;
SeriesCollection mySC2 = getRandomData();
Chart.SeriesCollection.Add(mySC2);
//This chart is with initial zooming, right click on the chart to access zooming.
Chart2.TempDirectory = "temp";
Chart2.XAxis.FormatString = "MMM yyyy";
Chart2.Debug = true;
Chart2.LegendBox.Position = LegendBoxPosition.None;
Chart2.ShadingEffect = true;
Chart2.ShadingEffectMode = ShadingEffectMode.Six;
Chart2.PaletteName = dotnetCHARTING.Palette.Bright;
Chart2.Type = ChartType.Combo;
Chart2.Size = "800x350";
Chart2.Title = "A chart with initial zooming, right click on the chart for zooming options. Hover mouse for bar value.";
Chart2.DefaultSeries.Type = SeriesType.Bar;
Chart2.XAxis.TimeInterval = TimeInterval.Month;
Chart2.YAxis.Interval = 1;
Chart2.DefaultElement.ShowValue = true;
Chart2.DefaultSeries.DefaultElement.ToolTip = "%yValue";
SeriesCollection mySC3= getRandomData();
Chart2.SeriesCollection.Add(mySC3);
//set for initial zooming
Chart2.Zoomer.Enabled =true;
//configures the viewport to display 1 year
Chart2.XAxis.Viewport.TimeInterval = new TimeIntervalAdvanced(new TimeSpan(365, 0, 0, 0));
//displays starting in 2002 (if not set it would display at the first date. This in effect controls the starting scroll position.
Chart2.XAxis.Viewport.ScaleRange = new ScaleRange(new DateTime(2002,1,1),new DateTime(2002,12,31));
}
SeriesCollection getRandomData()
{
Random myR = new Random(3);
SeriesCollection SC = new SeriesCollection();
DateTime dt = new DateTime(2000,1,1);
Series s = new Series();
for(int b = 0; b < 96; b++)
{
Element e = new Element();
e.XDateTime = dt;
dt = dt.AddMonths(1);
e.YValue = myR.Next(50);
s.Elements.Add(e);
}
// give each series element its own color
s.PaletteName = Palette.Two;
SC.Add(s);
return SC;
}
</script>
<body>
<center>
<dotnet:Chart ID="Chart" runat="server" />
<br/>
<dotnet:Chart ID="Chart2" runat="server" />
</center>
</body>
</html>
详细地址:http://122.200.77.71/chart/default.htm