@SYum,
See the following complete code of StyleChart() method in WriterQuadrantAnalysisBase.cs. Only add 2 code segments. They will start with “Add 1” and "Add 2 and end with “End Add 1” and “End Add 2”.
You do not need to change other code segments much you provide,
“Add 1” is setting points to automatic.
“Add 2” is setting series to automatic.
e.g
Sample code:
protected virtual void StyleChart(Excel.Cells.Charts.Chart chart, string sheetName, double yAxisLargestValue, double yAxisSmallestValue, string connString, int counter, Excel.Cells.Worksheet sheet)
{
chart.Type = Excel.Cells.Charts.ChartType.Bubble;
Console.WriteLine("Styling chart " + chart.Name);
int textSizeForBubbles = TEXT_SIZE_FOR_BUBBLES;
if (sheetName.Contains(ALL_INDUSTRIES))
{
for (int i = 0; i < chart.NSeries.Count; i++)
{
chart.NSeries[i].BubbleScale = 30;
}
}
else
{
for (int i = 0; i < chart.NSeries.Count; i++)
{
chart.NSeries[i].BubbleScale = 50;
}
}
SetChartValues(connString);
Excel.Cells.Charts.Axis yAxis = chart.ValueAxis;
switch (chart.Name)
{
case CHART_NAME_LEV:
case CHART_NAME_PROJ_LEV:
yAxis.CrossAt = Y_AXIS_CROSS_LEV_CHARTS;
yAxis.MinValue = MIN_SCALE_LEV_CHARTS;
yAxis.MaxValue = MAX_SCALE_LEV_CHARTS;
break;
case CHART_NAME_LTV:
case CHART_NAME_PROJ_LTV:
yAxis.CrossAt = Y_AXIS_CROSS_LTV_CHARTS;
yAxis.MinValue = MIN_SCALE_LTV_CHARTS;
yAxis.MaxValue = MAX_SCALE_LTV_CHARTS;
break;
default:
if (yAxisLargestValue > 0)
{
Excel.Cells.Charts.Axis xAxis = chart.CategoryAxis;
if (yAxisLargestValue > 100)
{
yAxisLargestValue += 5000;
yAxisSmallestValue -= 5000;
}
else
{
yAxisLargestValue += 5;
yAxisSmallestValue -= 5;
}
yAxisLargestValue = Math.Round(yAxisLargestValue);
yAxisSmallestValue = Math.Round(yAxisSmallestValue);
yAxis.MaxValue = yAxisLargestValue;
yAxis.MinValue = yAxisSmallestValue;
yAxis.CrossAt = (yAxisLargestValue + yAxisSmallestValue) / 2.0;
}
break;
}
Excel.Cells.Charts.Series recommendationOneSeries = chart.NSeries[0];
Excel.Cells.Charts.Series recommendationTwoSeries = chart.NSeries[1];
Excel.Cells.Charts.Series recommendationThreeSeries = chart.NSeries[2];
Excel.Cells.Charts.Series recommendationFourSeries = chart.NSeries[3];
Excel.Cells.Charts.Series recommendationFiveSeries = chart.NSeries[4];
//Add 1
/*********************************************/
//Set area and border of all poits to automatic
/*********************************/
for (int i = 0; i < chart.NSeries.Count; i++)
{
int pointCount = chart.NSeries[i].Points.Count;
for(int j=0; j < pointCount;j++)
{
ChartPoint p = chart.NSeries[i].Points[j];
p.Area.Formatting = FormattingType.Automatic;
p.Border.FormattingType = ChartLineFormattingType.Automatic;
}
}
/********************************************/
//End Add 1
//Add 2
/*********************************************/
//Set area of all series to automatic
/*********************************/
recommendationOneSeries.Area.FillFormat.FillType = FillType.Automatic;
recommendationTwoSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Automatic;
recommendationThreeSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Automatic;
recommendationFourSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Automatic;
recommendationFiveSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Automatic;
/********************************************/
//End Add 2
float transparency = .25F;
recommendationOneSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Solid;
recommendationOneSeries.Area.Transparency = transparency;
recommendationOneSeries.Area.ForegroundColor = System.Drawing.Color.FromArgb(64, 196, 124);
recommendationTwoSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Solid;
recommendationTwoSeries.Area.Transparency = transparency;
recommendationTwoSeries.Area.ForegroundColor = System.Drawing.Color.FromArgb(191, 221, 170);
recommendationThreeSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Solid;
recommendationThreeSeries.Area.Transparency = transparency;
recommendationThreeSeries.Area.ForegroundColor = System.Drawing.Color.FromArgb(255, 255, 64);
recommendationFourSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Solid;
recommendationFourSeries.Area.Transparency = transparency;
recommendationFourSeries.Area.ForegroundColor = System.Drawing.Color.FromArgb(255, 188, 64);
recommendationFiveSeries.Area.FillFormat.FillType = Excel.Cells.Drawing.FillType.Solid;
recommendationFiveSeries.Area.Transparency = transparency;
recommendationFiveSeries.Area.ForegroundColor = System.Drawing.Color.FromArgb(255, 64, 64);
sheet.Workbook.CalculateFormula();
SetSeriesLabels((Excel.Cells.Charts.Series)recommendationOneSeries, "CI", sheet);
SetSeriesLabels((Excel.Cells.Charts.Series)recommendationTwoSeries, "CQ", sheet);
SetSeriesLabels((Excel.Cells.Charts.Series)recommendationThreeSeries, "CY", sheet);
SetSeriesLabels((Excel.Cells.Charts.Series)recommendationFourSeries, "DG", sheet);
SetSeriesLabels((Excel.Cells.Charts.Series)recommendationFiveSeries, "DO", sheet);
}
Hope, this helps a bit.
Thank you.