Gallery
Surface Cont Layer Contour Sur 3D
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dnc" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="dotnetCHARTING.Mapping" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates a 3D contour surface chart with a 2d contour layer..
Chart.Size = "650x450";
Chart.TempDirectory = "temp";
Chart.Debug = true;
Chart.Type = ChartType.Surface;
Chart.LegendBox.Visible = false;
Chart.View3D.AngleOfTilt = 50;
Chart.View3D.AngleOfRotation = 65;
Chart.MarginTop = 25;
Chart.XAxis.Label.Text = "X Axis";
Chart.YAxis.Label.Text = "Y Axis";
Chart.ZAxis.Label.Text = "Z Axis";
Chart.DefaultSeries.Type = SeriesTypeSurface.Surface;
Chart.DefaultSeries.Line.Transparency = 70;
SeriesCollection mySC = getRData(true);
mySC[0].InterpolationFillFactor = 3;
mySC[0].Background.Transparency = 60;
mySC[0].Use3D = true;
Chart.SmartPalette = mySC[0].GetSmartPalette(ElementValue.ZValue, Color.Blue, Color.Aqua, Color.LightGreen, Color.Yellow, Color.Orange, Color.Crimson);
Annotation an = new Annotation(getSwatch(510, Chart.SmartPalette, 10, true));
an.ClearColors();
Chart.Annotations.Add(an);
an.Position = new Point(25, 10);
an.DynamicSize = false;
// Add the random data.
Chart.SeriesCollection.Add(mySC);
// Additional series with no data can be added to layer additional surface styles.
Series s1 = new Series();
s1.Type = SeriesTypeSurface.Contour;
Chart.SeriesCollection.Add(s1);
}
SeriesCollection getRData(bool distort)
{
Random myR = new Random();
SeriesCollection SC = new SeriesCollection();
double[][] zVals = new double[9][];
zVals[0] = new double[] { 0.00, -1.75, -3.00, -3.75, -4.00, -3.75, -3.00, -1.75, 0.00 };
zVals[1] = new double[] { 1.75, 0.00, -1.25, -2.00, -2.25, -2.00, -1.25, 0.00, 1.75 };
zVals[2] = new double[] { 3.00, 1.25, 0.00, -0.75, -1.00, -0.75, 0.00, 1.25, 3.00 };
zVals[3] = new double[] { 3.75, 2.00, 0.75, 0.00, -0.25, 0.00, 0.75, 2.00, 3.75 };
zVals[4] = new double[] { 4.00, 2.25, 1.00, 0.25, 0.00, 0.25, 1.00, 2.25, 4.00 };
zVals[5] = new double[] { 3.75, 2.00, 0.75, 0.00, -0.25, 0.00, 0.75, 2.00, 3.75 };
zVals[6] = new double[] { 3.00, 1.25, 0.00, -0.75, -1.00, -0.75, 0.00, 1.25, 3.00 };
zVals[7] = new double[] { 1.75, 0.00, -1.25, -2.00, -2.25, -2.00, -1.25, 0.00, 1.75 };
zVals[8] = new double[] { 0.00, -1.75, -3.00, -3.75, -4.00, -3.75, -3.00, -1.75, 0.00 };
if (distort)
for (int x = 0; x < zVals.Length; x++)
{
for (int i = 0; i < zVals[x].Length; i++)
zVals[x][i] += -.5f + (myR.Next(10) / 10f);
}
Series s = Series.FromSurfaceData("", new double[] { -2, -1.5, -1, -.5, 0, .5, 1, 1.5, 2 }, new double[] { -2, -1.5, -1, -.5, 0, .5, 1, 1.5, 2 }, zVals);
SC.Add(s);
return SC;
}
string getSwatch(int width, SmartPalette sp, int divisions, bool withValues)
{
// Get Maximum Value of the smart palette range
double max = (double)sp.GetScaleRange("*").ValueHigh;
double min = (double)sp.GetScaleRange("*").ValueLow;
string swatch = "", spacers = "";
double step = (max - min) / divisions;
// Width of each division.
int boxWidth = width / divisions;
// Generate swatch string for each division.
for (int i = 0; i <= divisions; i++)
{
spacers += "<Chart:Spacer size='" + boxWidth + "x1'>";
// Get the color of the current division.
string color = getHTMLColor(sp.GetValueColor("", min + (i * (step))));
if (withValues)
swatch += "<block hAlignment='Center' bgColor='" + color + "'>" + Math.Round((min + (i * (step))), 1);
else
swatch += "<block bgColor='" + color + "' fColor='" + color + "'>_";
}
//return the swatch string.
return spacers + "<row>" + swatch;
}
string getHTMLColor(Color c)
{
return "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
</head>
<style type="text/css">
div, p
{
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
}
</style>
<body>
<div align="center">
<dnc:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dnc" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="dotnetCHARTING.Mapping" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates a 3D contour surface chart with a 2d contour layer..
Chart.Size = "650x450"
Chart.TempDirectory = "temp"
Chart.Debug = True
Chart.Type = ChartType.Surface
Chart.LegendBox.Visible = False
Chart.View3D.AngleOfTilt = 50
Chart.View3D.AngleOfRotation = 65
Chart.MarginTop = 25
Chart.XAxis.Label.Text = "X Axis"
Chart.YAxis.Label.Text = "Y Axis"
Chart.ZAxis.Label.Text = "Z Axis"
Chart.DefaultSeries.Type = SeriesTypeSurface.Surface
Chart.DefaultSeries.Line.Transparency = 70
Dim mySC As SeriesCollection = getRData(True)
mySC(0).InterpolationFillFactor = 3
mySC(0).Background.Transparency = 60
mySC(0).Use3D = True
Chart.SmartPalette = mySC(0).GetSmartPalette(ElementValue.ZValue, Color.Blue, Color.Aqua, Color.LightGreen, Color.Yellow, Color.Orange, Color.Crimson)
Dim an As Annotation = New Annotation(getSwatch(510, Chart.SmartPalette, 10, True))
an.ClearColors()
Chart.Annotations.Add(an)
an.Position = New Point(25, 10)
an.DynamicSize = False
' Add the random data.
Chart.SeriesCollection.Add(mySC)
' Additional series with no data can be added to layer additional surface styles.
Dim s1 As Series = New Series()
s1.Type = SeriesTypeSurface.Contour
Chart.SeriesCollection.Add(s1)
End Sub
Function getRData(ByVal distort As Boolean) As SeriesCollection
Dim myR As Random = New Random()
Dim SC As SeriesCollection = New SeriesCollection()
Dim zVals As Double()() = New Double(8)(){}
zVals(0) = New Double() { 0.00, -1.75, -3.00, -3.75, -4.00, -3.75, -3.00, -1.75, 0.00 }
zVals(1) = New Double() { 1.75, 0.00, -1.25, -2.00, -2.25, -2.00, -1.25, 0.00, 1.75 }
zVals(2) = New Double() { 3.00, 1.25, 0.00, -0.75, -1.00, -0.75, 0.00, 1.25, 3.00 }
zVals(3) = New Double() { 3.75, 2.00, 0.75, 0.00, -0.25, 0.00, 0.75, 2.00, 3.75 }
zVals(4) = New Double() { 4.00, 2.25, 1.00, 0.25, 0.00, 0.25, 1.00, 2.25, 4.00 }
zVals(5) = New Double() { 3.75, 2.00, 0.75, 0.00, -0.25, 0.00, 0.75, 2.00, 3.75 }
zVals(6) = New Double() { 3.00, 1.25, 0.00, -0.75, -1.00, -0.75, 0.00, 1.25, 3.00 }
zVals(7) = New Double() { 1.75, 0.00, -1.25, -2.00, -2.25, -2.00, -1.25, 0.00, 1.75 }
zVals(8) = New Double() { 0.00, -1.75, -3.00, -3.75, -4.00, -3.75, -3.00, -1.75, 0.00 }
If distort Then
For x As Integer = 0 To zVals.Length - 1
For i As Integer = 0 To zVals(x).Length - 1
zVals(x)(i) += -.5f + (myR.Next(10) / 10f)
Next i
Next x
End If
Dim s As Series = Series.FromSurfaceData("", New Double() { -2, -1.5, -1, -.5, 0,.5, 1, 1.5, 2 }, New Double() { -2, -1.5, -1, -.5, 0,.5, 1, 1.5, 2 }, zVals)
SC.Add(s)
Return SC
End Function
Function getSwatch(ByVal width As Integer, ByVal sp As SmartPalette, ByVal divisions As Integer, ByVal withValues As Boolean) As String
' Get Maximum Value of the smart palette range
Dim max As Double = CDbl(sp.GetScaleRange("*").ValueHigh)
Dim min As Double = CDbl(sp.GetScaleRange("*").ValueLow)
Dim swatch As String = "", spacers As String = ""
Dim [step] As Double = (max - min) / divisions
' Width of each division.
Dim boxWidth As Integer = width / divisions
' Generate swatch string for each division.
For i As Integer = 0 To divisions
spacers &= "<Chart:Spacer size='" & boxWidth & "x1'>"
' Get the color of the current division.
Dim color As String = getHTMLColor(sp.GetValueColor("", min + (i * ([step]))))
If withValues Then
swatch &= "<block hAlignment='Center' bgColor='" & color & "'>" & Math.Round((min + (i * ([step]))), 1)
Else
swatch &= "<block bgColor='" & color & "' fColor='" & color & "'>_"
End If
Next i
'return the swatch string.
Return spacers & "<row>" & swatch
End Function
Function getHTMLColor(ByVal c As Color) As String
Return "#" & c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2")
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
</head>
<style type="text/css">
div, p
{
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
}
</style>
<body>
<div align="center">
<dnc:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameGallery/P221.aspx
- Version6.2
- Uses DatabaseNo