Gallery
Normal Distribution 1
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
void Page_Load(Object sender,EventArgs e)
{
// Demonstrates the use of NormalDistribution
// within StatisticalEngine.
// The Distribution Chart
DistributionChart.Title="Distribution";
DistributionChart.TempDirectory = "temp";
DistributionChart.Debug=true;
DistributionChart.Size = "600x300";
DistributionChart.LegendBox.Template ="%icon %name";
DistributionChart.XAxis.ScaleRange.ValueLow =30;
DistributionChart.XAxis.Interval = 5;
DistributionChart.YAxis.Percent = true;
DistributionChart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
DistributionChart.ChartAreaLayout.Mode = ChartAreaLayoutMode.Vertical;
DistributionChart.DefaultSeries.DefaultElement.Marker.Visible = false;
DistributionChart.DefaultElement.SmartLabel.Alignment = LabelAlignment.Center;
double[] normalDistVector = new double[] {40, 55, 70, 85, 115, 130, 145, 160};
Series sampledata = new Series ("Sample1");
for ( int i=0; i < normalDistVector.Length; i++) {
Element el = new Element();
el.XValue = normalDistVector[i];
sampledata.Elements.Add (el);
}
// The second parameter of this method is the standard deviation of the normal probability distribution
Series normalDistribution = StatisticalEngine.NormalDistribution(sampledata, 19 );
normalDistribution.Type = SeriesType.AreaSpline;
normalDistribution.DefaultElement.SmartLabel.Text = "%PercentOfTotal";
normalDistribution.DefaultElement.ShowValue = true;
Series tmpS = new Series("",normalDistribution.Elements);
tmpS.Trim(new ScaleRange(0,70),ElementValue.XValue);
ColorElements(tmpS,Color.Orange,Color.Black);
tmpS = new Series("",normalDistribution.Elements);
tmpS.Trim(new ScaleRange(130,190),ElementValue.XValue);
ColorElements(tmpS,Color.Orange,Color.Black);
tmpS = new Series("",normalDistribution.Elements);
tmpS.Trim(new ScaleRange(71, 85),ElementValue.XValue);
ColorElements(tmpS,Color.Blue,Color.White);
tmpS = new Series("",normalDistribution.Elements);
tmpS.Trim(new ScaleRange(115, 129),ElementValue.XValue);
ColorElements(tmpS,Color.Blue,Color.White);
DistributionChart.SeriesCollection.Add (normalDistribution);
}
void ColorElements(Series s, Color color, Color color2)
{
int count = s.Elements.Count;
int i = 0;
foreach(Element el in s.Elements)
{
//el.ShowValue = true;
el.Color = color;
el.SmartLabel.Color = color2;
el.SmartLabel.Font = new Font("Trebuchet MS", 8.5f, FontStyle.Bold);
i++;
}
}
</script>
</head>
<body>
<div style="text-align:center">
<dotnet:Chart id="DistributionChart" runat="server"/>
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates the use of NormalDistribution
' within StatisticalEngine.
' The Distribution Chart
DistributionChart.Title="Distribution"
DistributionChart.TempDirectory = "temp"
DistributionChart.Debug=True
DistributionChart.Size = "600x300"
DistributionChart.LegendBox.Template ="%icon %name"
DistributionChart.XAxis.ScaleRange.ValueLow =30
DistributionChart.XAxis.Interval = 5
DistributionChart.YAxis.Percent = True
DistributionChart.TitleBox.Position = TitleBoxPosition.FullWithLegend
DistributionChart.ChartAreaLayout.Mode = ChartAreaLayoutMode.Vertical
DistributionChart.DefaultSeries.DefaultElement.Marker.Visible = False
DistributionChart.DefaultElement.SmartLabel.Alignment = LabelAlignment.Center
Dim normalDistVector As Double() = New Double() {40, 55, 70, 85, 115, 130, 145, 160}
Dim sampledata As Series = New Series ("Sample1")
For i As Integer = 0 To normalDistVector.Length - 1
Dim el As Element = New Element()
el.XValue = normalDistVector(i)
sampledata.Elements.Add (el)
Next i
' The second parameter of this method is the standard deviation of the normal probability distribution
Dim normalDistribution As Series = StatisticalEngine.NormalDistribution(sampledata, 19)
normalDistribution.Type = SeriesType.AreaSpline
normalDistribution.DefaultElement.SmartLabel.Text = "%PercentOfTotal"
normalDistribution.DefaultElement.ShowValue = True
Dim tmpS As Series = New Series("",normalDistribution.Elements)
tmpS.Trim(New ScaleRange(0,70),ElementValue.XValue)
ColorElements(tmpS,Color.Orange,Color.Black)
tmpS = New Series("",normalDistribution.Elements)
tmpS.Trim(New ScaleRange(130,190),ElementValue.XValue)
ColorElements(tmpS,Color.Orange,Color.Black)
tmpS = New Series("",normalDistribution.Elements)
tmpS.Trim(New ScaleRange(71, 85),ElementValue.XValue)
ColorElements(tmpS,Color.Blue,Color.White)
tmpS = New Series("",normalDistribution.Elements)
tmpS.Trim(New ScaleRange(115, 129),ElementValue.XValue)
ColorElements(tmpS,Color.Blue,Color.White)
DistributionChart.SeriesCollection.Add (normalDistribution)
End Sub
Sub ColorElements(ByVal s As Series, ByVal color As Color, ByVal color2 As Color)
Dim count As Integer = s.Elements.Count
Dim i As Integer = 0
For Each el As Element In s.Elements
'el.ShowValue = true;
el.Color = color
el.SmartLabel.Color = color2
el.SmartLabel.Font = New Font("Trebuchet MS", 8.5f, FontStyle.Bold)
i += 1
Next el
End Sub
</script>
</head>
<body>
<div style="text-align:center">
<dotnet:Chart id="DistributionChart" runat="server"/>
</div>
</body>
</html>
- Sample FilenameNormalDistribution1.aspx
- Version4.0
- Uses DatabaseNo