Below code i using to create Stacked chart ,every month i display schduled ,release.Hold status ,Now i want display schduled column seperatly and need display other column release and Hold one column
Chart2.DataSource = ds;
foreach
(DataRow row
in
dt.Rows)
{
int
total = 0;
//int sch = Convert.ToInt16(ds.Tables[0].Rows[i]["SCHCNT"].ToString());
total += Convert.ToInt16(row[
"Hold"
]);
total += Convert.ToInt16(row[
"SCHCNT"
]);
total += Convert.ToInt16(row[
"Released"
]);
total += Convert.ToInt16(row[
"Addl"
]);
total += Convert.ToInt16(row[
"Notreleased"
]);
row[
"Total"
] = total;
}
// Set series members names for the X and Y values
Chart2.Series[
"Series1"
][
"PixelPointWidth"
] =
"30"
;
Chart2.Series[
"Series2"
][
"PixelPointWidth"
] =
"30"
;
Chart2.Series[
"Series3"
][
"PixelPointWidth"
] =
"30"
;
Chart2.Series[
"Series4"
][
"PixelPointWidth"
] =
"30"
;
Chart2.Series[
"Series5"
][
"PixelPointWidth"
] =
"30"
;
Chart2.Series[
"Series1"
].XValueMember =
"PERD"
;
Chart2.Series[
"Series1"
].YValueMembers =
"SCHCNT"
;
Chart2.Series[
"Series2"
].XValueMember =
"PERD"
;
Chart2.Series[
"Series2"
].YValueMembers =
"Notreleased"
;
Chart2.Series[
"Series3"
].XValueMember =
"PERD"
;
Chart2.Series[
"Series3"
].YValueMembers =
"Released"
;
Chart2.Series[
"Series4"
].XValueMember =
"PERD"
;
Chart2.Series[
"Series4"
].YValueMembers =
"Hold"
;
Chart2.Series[
"Series5"
].XValueMember =
"PERD"
;
Chart2.Series[
"Series5"
].YValueMembers =
"Addl"
;
Chart2.Series[
"Series6"
].XValueMember =
"PERD"
;
Chart2.Series[
"Series6"
].YValueMembers =
"Total"
;
Chart2.DataBind();
foreach
(System.Web.UI.DataVisualization.Charting.Series series
in
Chart2.Series)
{
foreach
(System.Web.UI.DataVisualization.Charting.DataPoint point
in
series.Points)
{
if
(point.YValues.Length > 0 && (
double
)point.YValues.GetValue(0) == 0)
{
point.LegendText = point.AxisLabel;
//In case you have legend
}
else
{
point.IsValueShownAsLabel =
true
;
if
(series.ToString().Trim() ==
"Series-Series1"
)
{
point.LabelUrl =
"DrawingStatus.aspx?mon=#VALX&flag=SCH&cprj="
+ Request.QueryString[
"cprj"
];
}
if
(series.ToString().Trim() ==
"Series-Series2"
)
{
point.LabelUrl =
"DrawingStatus.aspx?mon=#VALX&flag=NOT&cprj="
+ Request.QueryString[
"cprj"
];
}
if
(series.ToString().Trim() ==
"Series-Series3"
)
{
point.LabelUrl =
"DrawingStatus.aspx?mon=#VALX&flag=REL&cprj="
+ Request.QueryString[
"cprj"
];
}
if
(series.ToString().Trim() ==
"Series-Series4"
)
{
point.LabelUrl =
"DrawingStatus.aspx?mon=#VALX&flag=HOL&cprj="
+ Request.QueryString[
"cprj"
];
}
if
(series.ToString().Trim() ==
"Series-Series5"
)
{
point.LabelUrl =
"DrawingStatus.aspx?mon=#VALX&flag=Addl&cprj="
+ Request.QueryString[
"cprj"
];
}
}
}
con.Close();
con.Dispose();
}
}
catch
(Exception ex)
{
if
(con.State != ConnectionState.Closed)
{
con.Close();
con.Dispose();
// con = null;
}
Response.Write(ex.Message);
}
finally
{
con.Close();
con.Dispose();
con =
null
;
}
source code
<
asp:Chart
ID
=
"Chart2"
runat
=
"server"
Height
=
"500px"
Palette
=
"None"
Width
=
"1000px"
SuppressExceptions
=
"True"
BackColor
=
"146, 196, 59"
>
<
Series
>
<
asp:Series
Name
=
"Series1"
ChartArea
=
"ChartArea1"
XValueType
=
"String"
BorderWidth
=
"2"
Color
=
"LightBlue"
IsXValueIndexed
=
"True"
Legend
=
"Legend1"
LabelToolTip
=
"#VALX : #VALY"
LabelForeColor
=
"Black"
LegendText
=
"Scheduled"
LabelBackColor
=
"#CE90D4"
Font
=
"Calibri, 8pt, style=Bold"
MarkerSize
=
"10"
MarkerStyle
=
"Star4"
YValuesPerPoint
=
"4"
ChartType
=
"StackedColumn"
>
<
Points
>
<
asp:DataPoint
MarkerStyle
=
"None"
YValues
=
"0,0,0,0"
BackGradientStyle
=
"None"
BorderWidth
=
"4"
CustomProperties
=
"LabelStyle=Top"
IsEmpty
=
"True"
XValue
=
"2"
/>
</
Points
>
<
EmptyPointStyle
IsValueShownAsLabel
=
"true"
/>
<
SmartLabelStyle
CalloutLineAnchorCapStyle
=
"Diamond"
/>
</
asp:Series
>
<
asp:Series
ChartArea
=
"ChartArea1"
Name
=
"Series3"
XValueType
=
"String"
BorderWidth
=
"2"
Color
=
"Green"
IsXValueIndexed
=
"True"
Legend
=
"Legend1"
LabelToolTip
=
"#VALX : #VALY"
LabelForeColor
=
"Black"
LegendText
=
"Released"
LabelBackColor
=
"Cyan"
Font
=
"Calibri, 8pt, style=Bold"
MarkerSize
=
"10"
MarkerStyle
=
"Star4"
YValuesPerPoint
=
"4"
ChartType
=
"StackedColumn"
>
<
Points
>
<
asp:DataPoint
MarkerStyle
=
"None"
YValues
=
"0,0,0,0"
BackGradientStyle
=
"None"
BorderWidth
=
"4"
CustomProperties
=
"LabelStyle=Top"
IsEmpty
=
"True"
XValue
=
"2"
/>
</
Points
>
<
EmptyPointStyle
/>
<
SmartLabelStyle
CalloutLineAnchorCapStyle
=
"Diamond"
/>
</
asp:Series
>
<
asp:Series
ChartArea
=
"ChartArea1"
Name
=
"Series2"
XValueType
=
"String"
BorderWidth
=
"2"
Color
=
"Red"
IsXValueIndexed
=
"True"
Legend
=
"Legend1"
LabelToolTip
=
"#VALX : #VALY"
LabelForeColor
=
"Black"
LegendText
=
"Not Released"
LabelBackColor
=
"Gray"
Font
=
"Calibri, 8pt, style=Bold"
MarkerSize
=
"10"
MarkerStyle
=
"Star4"
YValuesPerPoint
=
"4"
ChartType
=
"StackedColumn"
>
<
Points
>
<
asp:DataPoint
MarkerStyle
=
"None"
YValues
=
"0,0,0,0"
BackGradientStyle
=
"None"
BorderWidth
=
"4"
CustomProperties
=
"LabelStyle=Top"
IsEmpty
=
"True"
XValue
=
"2"
/>
</
Points
>
<
EmptyPointStyle
/>
<
SmartLabelStyle
CalloutLineAnchorCapStyle
=
"Diamond"
/>
</
asp:Series
>
<
asp:Series
Name
=
"Series4"
ChartArea
=
"ChartArea1"
XValueType
=
"String"
BorderWidth
=
"2"
Color
=
"Yellow"
IsXValueIndexed
=
"True"
Legend
=
"Legend1"
LabelToolTip
=
"#VALX : #VALY"
LabelForeColor
=
"Black"
LegendText
=
"On-Hold"
LabelBackColor
=
"Lavender"
Font
=
"Calibri, 8pt, style=Bold"
MarkerSize
=
"10"
MarkerStyle
=
"Star4"
YValuesPerPoint
=
"4"
ChartType
=
"StackedColumn"
>
<
Points
>
<
asp:DataPoint
MarkerStyle
=
"None"
YValues
=
"0,0,0,0"
BackGradientStyle
=
"None"
BorderWidth
=
"4"
CustomProperties
=
"LabelStyle=Top"
IsEmpty
=
"True"
XValue
=
"2"
/>
</
Points
>
<
EmptyPointStyle
IsValueShownAsLabel
=
"true"
/>
<
SmartLabelStyle
CalloutLineAnchorCapStyle
=
"Diamond"
/>
</
asp:Series
>
<
asp:Series
Name
=
"Series5"
ChartArea
=
"ChartArea1"
XValueType
=
"String"
BorderWidth
=
"2"
Color
=
"Blue"
IsXValueIndexed
=
"True"
Legend
=
"Legend1"
LabelToolTip
=
"#VALX : #VALY"
LabelForeColor
=
"Black"
LegendText
=
"Additional"
LabelBackColor
=
"Gray"
Font
=
"Calibri, 8pt, style=Bold"
MarkerSize
=
"10"
MarkerStyle
=
"Star4"
YValuesPerPoint
=
"4"
ChartType
=
"StackedColumn"
>
<
Points
>
<
asp:DataPoint
MarkerStyle
=
"None"
YValues
=
"0,0,0,0"
BackGradientStyle
=
"None"
BorderWidth
=
"4"
CustomProperties
=
"LabelStyle=Top"
IsEmpty
=
"True"
XValue
=
"2"
/>
</
Points
>
<
EmptyPointStyle
IsValueShownAsLabel
=
"true"
/>
<
SmartLabelStyle
CalloutLineAnchorCapStyle
=
"Diamond"
/>
</
asp:Series
>
<
asp:Series
Name
=
"Series6"
ChartType
=
"Point"
ChartArea
=
"ChartArea1"
XValueType
=
"String"
BorderWidth
=
"2"
Color
=
"Black"
IsXValueIndexed
=
"True"
Legend
=
"Legend1"
LabelToolTip
=
"#VALX : #VALY"
LabelForeColor
=
"DarkBlue"
LegendText
=
"Total"
LabelBackColor
=
"#CE90D4"
Font
=
"Calibri, 8pt, style=Bold"
MarkerSize
=
"10"
MarkerStyle
=
"Star4"
YValuesPerPoint
=
"4"
>
<
Points
>
<
asp:DataPoint
MarkerStyle
=
"None"
YValues
=
"0,0,0,0"
BackGradientStyle
=
"None"
BorderWidth
=
"4"
CustomProperties
=
"LabelStyle=Top"
IsEmpty
=
"True"
XValue
=
"2"
/>
</
Points
>
<
EmptyPointStyle
IsValueShownAsLabel
=
"true"
/>
<
SmartLabelStyle
CalloutLineAnchorCapStyle
=
"Diamond"
/>
</
asp:Series
>
</
Series
>
<
ChartAreas
>
<
asp:ChartArea
Name
=
"ChartArea1"
AlignmentOrientation
=
"All"
BackColor
=
"255, 255, 128"
BackGradientStyle
=
"DiagonalRight"
>
<
AxisY
ArrowStyle
=
"None"
InterlacedColor
=
"White"
IntervalType
=
"Number"
TextOrientation
=
"Rotated270"
Title
=
" No. of Drawings"
MaximumAutoSize
=
"100"
TitleFont
=
"Calibri, 14.25pt, style=Bold"
TitleForeColor
=
"Black"
>
<
MajorGrid
IntervalOffset
=
"Auto"
LineDashStyle
=
"Solid"
IntervalOffsetType
=
"Number"
IntervalType
=
"Number"
Enabled
=
"False"
/>
<
MajorTickMark
Interval
=
"50"
/>
<
StripLines
>
<
asp:StripLine
BackColor
=
"192, 255, 255"
/>
</
StripLines
>
<
LabelStyle
Font
=
"Calibri, 10pt, style=Bold"
ForeColor
=
"Black"
/>
<
ScaleBreakStyle
Spacing
=
"2.5"
StartFromZero
=
"No"
/>
</
AxisY
>
<
AxisX
Title
=
"Month"
Crossing
=
"Min"
Enabled
=
"True"
Interval
=
"1"
IntervalAutoMode
=
"VariableCount"
IsLabelAutoFit
=
"False"
IsMarksNextToAxis
=
"False"
MaximumAutoSize
=
"100"
TitleFont
=
"Calibri, 14.25pt, style=Bold"
TitleForeColor
=
"Black"
>
<
StripLines
>
<
asp:StripLine
/>
</
StripLines
>
<
LabelStyle
Font
=
"Calibri, 10pt, style=Bold"
ForeColor
=
"Black"
Interval
=
"1"
IntervalOffset
=
"Auto"
IntervalOffsetType
=
"Auto"
IntervalType
=
"Number"
/>
<
ScaleBreakStyle
BreakLineStyle
=
"Wave"
Enabled
=
"True"
Spacing
=
"2.5"
StartFromZero
=
"Yes"
/>
<
ScaleView
Position
=
"1"
Size
=
"12"
/>
<
MajorGrid
LineWidth
=
"0"
/>
</
AxisX
>
</
asp:ChartArea
>
</
ChartAreas
>
<
Legends
>
<
asp:Legend
Name
=
"Legend1"
DockedToChartArea
=
"NotSet"
Docking
=
"Bottom"
Alignment
=
"Far"
>
</
asp:Legend
>
</
Legends
>
<
Titles
>
<%-- <
asp:Title
Text
=
"Click on values for details"
Docking
=
"Top"
ForeColor
=
"Red"
Alignment
=
"TopRight"
></
asp:Title
>--%>
</
Titles
>
</
asp:Chart
>