K
kkzhao
I have a question on OWC10 charting. Can you help?
I am using the OWC10 in ASP.Net, it works fine if I display only one
series. However, if I add the second series, the second series is being
placed to the right side of the first series. It should be kind of in
the middle based on it value.
It would be better if I can attach the screen shot of my chart here.
In my code the arrProbability[0],
arrProbabilityValue[0],arrProbability[1],arrProbabilityValue[1] contain
the tab delimited value I get from database.
Thank you.
Eric
(e-mail address removed)
(415)768-4070
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.OleDb;
using System.Data.SqlClient;
using OWC10;
namespace TestApp
{
/// <summary>
/// Summary description for RiskCurve.
/// </summary>
public class RiskCurve : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder
phRiskCurve;
protected OWC10.ChartSpace objCSpace;
protected OWC10.ChChart objChart;
protected OWC10.ChartChartTypeEnum c;
protected System.Object obj;
protected int i;
private void Page_Load(object sender,
System.EventArgs e)
{
//
arrProbability[0] = "-2.4 -2.3 -2.2
-2.1 -2 -1.9 -1.8 -1.7 -1.6
-1.5 -1.4 -1.3 -1.2 -1.1 -1
-0.9 -0.8 -0.7 -0.6 -0.5 -0.4
-0.3 -0.2 -0.1 0 0.1 0.2
0.3 0.4 0.5 0.6 0.7 0.8
0.9 "
arrProbabilityValue[0] = "0.0005 0.0005
0.0005 0.0005 0.0005 0.0005 0.0005 0.0005
0.0005 0.0005 0.0005 0.001 0.002 0.003
0.005 0.0085 0.015 0.0255 0.0425 0.0705
0.114 0.1785 0.2705 0.392 0.537 0.6915
0.8305 0.9295 0.9805 0.997 0.9995 0.9995
0.9995 0.9995 "
arrProbability[1] = "0.044538193348157
0.044538193348157 "
arrProbabilityValue[1] = "1 0 "
objCSpace = new OWC10.ChartSpace();
obj = objCSpace.Constants;
objChart = objCSpace.Charts.Add(0);
objChart.Type =
OWC10.ChartChartTypeEnum.chChartTypeSmoothLine;
objChart.HasTitle = false;
objChart.Axes[0].HasTitle=true;
objChart.Axes[0].Title.Caption= "Profit
(Loss): GM%";
objChart.Axes[1].HasTitle=true;
objChart.Axes[1].Title.Caption= "Probability
that GM% will be less than amount shown";
objChart.Axes[1].HasAutoMajorUnit=true;
objChart.Axes[1].MajorUnit = 0.1;
objChart.Axes[1].NumberFormat="0%";
objChart.SeriesCollection.Add(1);
objChart.SeriesCollection.Add(1);
objChart.SeriesCollection.Add(1);
objChart.SeriesCollection[0].SetData(OWC10.Char-
tDimensionsEnum.chDimSeriesNames,(int)OWC10.Cha-
rtSpecialDataSourcesEnum.chDataLiteral,"Risk1");
objChart.SeriesCollection[0].SetData(OWC10.Char-
tDimensionsEnum.chDimCategories,(int)OWC10.Char-
tSpecialDataSourcesEnum.chDataLiteral,arrProbab-
ility[0]);
objChart.SeriesCollection[0].SetData(OWC10.Char-
tDimensionsEnum.chDimValues,(int)OWC10.ChartSpe-
cialDataSourcesEnum.chDataLiteral,arrProbabilit-
yValue[0]);
objChart.SeriesCollection[1].SetData(OWC10.Char-
tDimensionsEnum.chDimSeriesNames,(int)OWC10.Cha-
rtSpecialDataSourcesEnum.chDataLiteral,"Risk2");
objChart.SeriesCollection[1].SetData(OWC10.Char-
tDimensionsEnum.chDimCategories,(int)OWC10.Char-
tSpecialDataSourcesEnum.chDataLiteral,arrProbab-
ility[1]);
objChart.SeriesCollection[1].SetData(OWC10.Char-
tDimensionsEnum.chDimValues,(int)OWC10.ChartSpe-
cialDataSourcesEnum.chDataLiteral,arrProbabilit-
yValue[1]);
objChart.SeriesCollection[2].SetData(OWC10.Char-
tDimensionsEnum.chDimSeriesNames,(int)OWC10.Cha-
rtSpecialDataSourcesEnum.chDataLiteral,"Risk3");
objChart.SeriesCollection[2].SetData(OWC10.Char-
tDimensionsEnum.chDimCategories,(int)OWC10.Char-
tSpecialDataSourcesEnum.chDataLiteral,arrProbab-
ility[2]);
objChart.SeriesCollection[2].SetData(OWC10.Char-
tDimensionsEnum.chDimValues,(int)OWC10.ChartSpe-
cialDataSourcesEnum.chDataLiteral,arrProbabilit-
yValue[2]);
objChart.SeriesCollection[0].Interior.Color =
"Rosybrown";
objChart.SeriesCollection[1].Interior.Color =
"red";
objChart.SeriesCollection[2].Interior.Color =
"blue";
objChart.PlotArea.Interior.Color = "white";
objCSpace.Border.Color="Blue";
string strAbsolutePath = (Server.MapPath(".")) +
"\\Temp\\TestChart.gif";
objCSpace.ExportPicture(strAbsolutePath,"GIF",-
700, 450);
string strRelativePath = "./Temp/TestChart.gif";
string strImageTag = "<img src='" +
strRelativePath + "'/>";
phRiskCurve.Controls.Add(new
LiteralControl(strImageTag));
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET
Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new
System.EventHandler(this.Page_Load);
}
#endregion
}
}
I am using the OWC10 in ASP.Net, it works fine if I display only one
series. However, if I add the second series, the second series is being
placed to the right side of the first series. It should be kind of in
the middle based on it value.
It would be better if I can attach the screen shot of my chart here.
In my code the arrProbability[0],
arrProbabilityValue[0],arrProbability[1],arrProbabilityValue[1] contain
the tab delimited value I get from database.
Thank you.
Eric
(e-mail address removed)
(415)768-4070
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.OleDb;
using System.Data.SqlClient;
using OWC10;
namespace TestApp
{
/// <summary>
/// Summary description for RiskCurve.
/// </summary>
public class RiskCurve : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder
phRiskCurve;
protected OWC10.ChartSpace objCSpace;
protected OWC10.ChChart objChart;
protected OWC10.ChartChartTypeEnum c;
protected System.Object obj;
protected int i;
private void Page_Load(object sender,
System.EventArgs e)
{
//
arrProbability[0] = "-2.4 -2.3 -2.2
-2.1 -2 -1.9 -1.8 -1.7 -1.6
-1.5 -1.4 -1.3 -1.2 -1.1 -1
-0.9 -0.8 -0.7 -0.6 -0.5 -0.4
-0.3 -0.2 -0.1 0 0.1 0.2
0.3 0.4 0.5 0.6 0.7 0.8
0.9 "
arrProbabilityValue[0] = "0.0005 0.0005
0.0005 0.0005 0.0005 0.0005 0.0005 0.0005
0.0005 0.0005 0.0005 0.001 0.002 0.003
0.005 0.0085 0.015 0.0255 0.0425 0.0705
0.114 0.1785 0.2705 0.392 0.537 0.6915
0.8305 0.9295 0.9805 0.997 0.9995 0.9995
0.9995 0.9995 "
arrProbability[1] = "0.044538193348157
0.044538193348157 "
arrProbabilityValue[1] = "1 0 "
objCSpace = new OWC10.ChartSpace();
obj = objCSpace.Constants;
objChart = objCSpace.Charts.Add(0);
objChart.Type =
OWC10.ChartChartTypeEnum.chChartTypeSmoothLine;
objChart.HasTitle = false;
objChart.Axes[0].HasTitle=true;
objChart.Axes[0].Title.Caption= "Profit
(Loss): GM%";
objChart.Axes[1].HasTitle=true;
objChart.Axes[1].Title.Caption= "Probability
that GM% will be less than amount shown";
objChart.Axes[1].HasAutoMajorUnit=true;
objChart.Axes[1].MajorUnit = 0.1;
objChart.Axes[1].NumberFormat="0%";
objChart.SeriesCollection.Add(1);
objChart.SeriesCollection.Add(1);
objChart.SeriesCollection.Add(1);
objChart.SeriesCollection[0].SetData(OWC10.Char-
tDimensionsEnum.chDimSeriesNames,(int)OWC10.Cha-
rtSpecialDataSourcesEnum.chDataLiteral,"Risk1");
objChart.SeriesCollection[0].SetData(OWC10.Char-
tDimensionsEnum.chDimCategories,(int)OWC10.Char-
tSpecialDataSourcesEnum.chDataLiteral,arrProbab-
ility[0]);
objChart.SeriesCollection[0].SetData(OWC10.Char-
tDimensionsEnum.chDimValues,(int)OWC10.ChartSpe-
cialDataSourcesEnum.chDataLiteral,arrProbabilit-
yValue[0]);
objChart.SeriesCollection[1].SetData(OWC10.Char-
tDimensionsEnum.chDimSeriesNames,(int)OWC10.Cha-
rtSpecialDataSourcesEnum.chDataLiteral,"Risk2");
objChart.SeriesCollection[1].SetData(OWC10.Char-
tDimensionsEnum.chDimCategories,(int)OWC10.Char-
tSpecialDataSourcesEnum.chDataLiteral,arrProbab-
ility[1]);
objChart.SeriesCollection[1].SetData(OWC10.Char-
tDimensionsEnum.chDimValues,(int)OWC10.ChartSpe-
cialDataSourcesEnum.chDataLiteral,arrProbabilit-
yValue[1]);
objChart.SeriesCollection[2].SetData(OWC10.Char-
tDimensionsEnum.chDimSeriesNames,(int)OWC10.Cha-
rtSpecialDataSourcesEnum.chDataLiteral,"Risk3");
objChart.SeriesCollection[2].SetData(OWC10.Char-
tDimensionsEnum.chDimCategories,(int)OWC10.Char-
tSpecialDataSourcesEnum.chDataLiteral,arrProbab-
ility[2]);
objChart.SeriesCollection[2].SetData(OWC10.Char-
tDimensionsEnum.chDimValues,(int)OWC10.ChartSpe-
cialDataSourcesEnum.chDataLiteral,arrProbabilit-
yValue[2]);
objChart.SeriesCollection[0].Interior.Color =
"Rosybrown";
objChart.SeriesCollection[1].Interior.Color =
"red";
objChart.SeriesCollection[2].Interior.Color =
"blue";
objChart.PlotArea.Interior.Color = "white";
objCSpace.Border.Color="Blue";
string strAbsolutePath = (Server.MapPath(".")) +
"\\Temp\\TestChart.gif";
objCSpace.ExportPicture(strAbsolutePath,"GIF",-
700, 450);
string strRelativePath = "./Temp/TestChart.gif";
string strImageTag = "<img src='" +
strRelativePath + "'/>";
phRiskCurve.Controls.Add(new
LiteralControl(strImageTag));
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET
Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new
System.EventHandler(this.Page_Load);
}
#endregion
}
}