protected void linkRollingVolume_Click( object sender, EventArgs e ) { RenderRollingVolumeChart( ); } |
private void RenderRollingVolumeChart( ) |
{ |
ActiveGraph1Chart = HomePageSectionType.RollingVolumeChart; |
|
linkRollingVolume.Font.Bold = true; |
linkRollingBoarding.Font.Bold = false; |
linkTodaysBoarding.Font.Bold = false; |
|
lblBarChartTitle.Text = "Rolling Volume"; |
radcBarChart.Series.Clear( ); |
|
//setup the Y Axis |
radcBarChart.PlotArea.YAxis.AutoScale = true; |
radcBarChart.PlotArea.YAxis.AxisLabel.Visible = true; |
radcBarChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Volume in 100,000 ($)"; |
radcBarChart.PlotArea.YAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = Color.FromArgb( 107, 129, 143 ); |
radcBarChart.PlotArea.YAxis.AxisLabel.TextBlock.Appearance.TextProperties.Font = new Font( "Arial", 9 ); |
|
//setup the X Axis |
radcBarChart.PlotArea.XAxis.AutoScale = false; |
radcBarChart.PlotArea.XAxis.Items.Clear( ); |
radcBarChart.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = -90; |
|
bool empty = true; |
if( Session["Dashboard_GetRollingVolume"] == null ) |
Session["Dashboard_GetRollingVolume"] = _reportService.GetRollingVolume( base.CurrentUser.PAN ); |
|
RollingVolumeResult[] rollingVolumeResults = Session["Dashboard_GetRollingVolume"] as RollingVolumeResult[]; |
if( rollingVolumeResults != null ) |
{ |
ChartSeries series1 = radcBarChart.CreateSeries( string.Empty, Color.FromArgb( 107, 129, 143 ), Color.FromArgb( 107, 129, 143 ), ChartSeriesType.StackedBar ); |
series1.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; |
series1.Appearance.ShowLabels = false; |
|
ChartSeries series2 = radcBarChart.CreateSeries( string.Empty, Color.FromArgb( 107, 129, 143 ), Color.FromArgb( 107, 129, 143 ), ChartSeriesType.StackedBar ); |
series2.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; |
series2.Appearance.ShowLabels = false; |
|
//iterate through the possible card types |
for(int cardType = 1; cardType <= 2; cardType++) |
{ |
//iterate through the last 13 months |
for( int index = 13; index > 0; index-- ) |
{ |
int month = DateTime.Today.AddMonths(1-index).Month; |
int year = DateTime.Today.AddMonths(1-index).Year; |
decimal captureAmount = 0; |
|
bool found = false; |
foreach( RollingVolumeResult rollingVolumeResult in rollingVolumeResults ) |
{ |
if( rollingVolumeResult.WOMonth == month && rollingVolumeResult.WOYear == year && |
rollingVolumeResult.CardType == cardType ) |
{ |
if( (captureAmount = rollingVolumeResult.CaptureAmount ?? 0) != 0 ) |
empty = false; |
|
found = true; |
break; |
} |
} |
|
ChartSeriesItem item = new ChartSeriesItem( !found ); |
item.YValue = (double)captureAmount; |
item.Appearance.FillStyle.FillType = FillType.Solid; |
item.Name = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month).Substring(0, 3); |
|
if( cardType == 1 ) |
{ |
radcBarChart.PlotArea.XAxis.AddItem(item.Name.ToUpper()); |
item.Appearance.FillStyle.MainColor = _colors[2]; |
item.Appearance.FillStyle.SecondColor = _secondaryColors[2]; |
item.Appearance.FillStyle.FillType = FillType.Gradient; |
series1.Items.Add( item ); |
} |
else |
{ |
item.Appearance.FillStyle.MainColor = _colors[0]; |
item.Appearance.FillStyle.SecondColor = _secondaryColors[0]; |
item.Appearance.FillStyle.FillType = FillType.Gradient; |
series2.Items.Add( item ); |
} |
} |
} |
} |
|
//if there is no data, set the chart origin to zero |
if( empty ) |
{ |
radcBarChart.PlotArea.YAxis.AutoScale = false; |
radcBarChart.PlotArea.YAxis.MinValue = 0; |
radcBarChart.PlotArea.YAxis.IsZeroBased = true; |
} |
} |