Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI All

i am binding Jan2013 to Dec 2013 Values for Asp.NET chart control(Line Graph), if there is no value for the month of Aug 2013 line are not joining between Jul2013 to Sep 2013.

Can any one tell what is the property i need to set to join points the charts even if there is no values for Aug2013..( Line has to join from Jul 2013 to Aug 2013)

I need to join line from july2013 to Sep2013, below is the code

*) In web.config we need to past the code

<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
validate="false" />

Here is the asp.net page code

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("DateName", typeof(string));
table.Columns.Add("DATE", typeof(DateTime));
table.Columns.Add("SPI", typeof(string));
table.Columns.Add("CPI", typeof(string));

table.Rows.Add("Jan 13", "2013-04-01 00:00:00", 1.1, 1.4);
table.Rows.Add("Feb 13", "2013-05-01 00:00:00", 1.1, 1.1);
table.Rows.Add("Mar 13", "2013-06-01 00:00:00", 1.2, 1.2);

table.Rows.Add("Apr 13", "2013-04-01 00:00:00", 1.1, 1.4);
table.Rows.Add("May 13", "2013-05-01 00:00:00", 1.1, 1.1);
table.Rows.Add("Jun 13", "2013-06-01 00:00:00", 1.2, 1.2);
table.Rows.Add("Jul 13", "2013-07-01 00:00:00", 1.9, 1.6);
table.Rows.Add("Aug 13", "2013-08-01 00:00:00", null, null);

table.Rows.Add("Sep 13", "2013-09-01 00:00:00", 1.0, 1.9);
table.Rows.Add("Oct 13", "2013-10-01 00:00:00", 1.1, 1.1);
table.Rows.Add("Nov 13", "2013-11-01 00:00:00", 1.2, 1.9);
table.Rows.Add("Dec 13", "2013-11-01 00:00:00", 1.2, 1.2);

StripLine stpLine = null;
int intYAxisGridLine = 10;
int intMaxScale = 0;
double dblLineInterval = 0;

intMaxScale = 2;
chrCpiSpi.ChartAreas["ChatareaCPISPI"].AxisY.Maximum = intMaxScale;
chrCpiSpi.ChartAreas["ChatareaCPISPI"].AxisY.Interval = 0.2;

chrCpiSpi.ChartAreas["ChatareaCPISPI"].AxisY.Maximum = intMaxScale;
chrCpiSpi.ChartAreas["ChatareaCPISPI"].AxisY.Interval = double.Parse(intMaxScale.ToString()) * 10 / 100;

if (table.Rows.Count > 0)
{
chrCpiSpi.DataSource = table;
chrCpiSpi.Series["SPI"].YValueMembers = "SPI";
chrCpiSpi.Series["CPI"].YValueMembers = "CPI";
chrCpiSpi.Series["SPI"].XValueMember = "DateName";
chrCpiSpi.Series["CPI"].XValueMember = "DateName";


chrCpiSpi.DataBind();

for (int i = 0; i < intYAxisGridLine; i++)
{
stpLine = new StripLine();
stpLine.IntervalOffset = dblLineInterval;
stpLine.StripWidth = intMaxScale - dblLineInterval;
stpLine.BorderWidth = 1;
stpLine.BorderColor = System.Drawing.Color.Gray;
chrCpiSpi.ChartAreas.FindByName("ChatareaCPISPI").AxisY.StripLines.Add(stpLine);
dblLineInterval = dblLineInterval + chrCpiSpi.ChartAreas["ChatareaCPISPI"].AxisY.Interval;
}
}
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>


</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Chart ID="chrCpiSpi" runat="server" ImageLocation="Images/Charts/YTDs_#SEQ(200,1)"
ImageType="Png" ImageStorageMode="UseImageLocation" Width="950px" Height="400px">
<legends>
<asp:Legend LegendStyle="Row" IsTextAutoFit="False" Docking="Bottom" IsDockedInsideChartArea="False"
Name="Default" BackColor="Transparent" Font="Arial, 8.5pt" Alignment="Center">


<series>
<asp:Series Name="SPI" LegendText="Cumulative SPI" ChartType="Line" MarkerStyle="Circle"
Color="#A8C6EA" BorderWidth="2" BorderColor="180, 26, 59, 105" LabelFormat="C"
Font="Arial, 8.5pt" ToolTip="#LEGENDTEXT: #VALY(Click here to see drill down report)" >

<asp:Series Name="CPI" LegendText="Cumulative CPI" ChartType="Line" MarkerStyle="Circle"
Color="#C3D69B" BorderWidth="2" LabelFormat="C" Font="Arial, 8.5pt" ToolTip="#LEGENDTEXT: #VALY(Click here to see drill down report)">


<chartareas>
<asp:ChartArea Name="ChatareaCPISPI" BorderColor="64, 64, 64, 64" BackSecondaryColor="White"
BackColor="White" ShadowColor="Transparent">
<Area3DStyle Rotation="10" Perspective="10" LightStyle="Realistic" Inclination="15"
IsRightAngleAxes="False" WallWidth="0" IsClustered="False" />
<axisy title="Performance Index" linecolor="64, 64, 64, 64" minimum="0" labelautofitstyle="LabelsAngleStep30">
IsLabelAutoFit="true">
<LabelStyle Font="Arial, 8.5pt" />
<majorgrid enabled="false">

<axisx linecolor="64, 64, 64" interval="1" maximum="Auto" intervalautomode="FixedCount">
LabelAutoFitStyle="None" IsLabelAutoFit="false">
<LabelStyle Font="Arial, 8.5pt" />
<majorgrid enabled="false">




</form>
</body>
</html>


Regards
Praveen
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900