We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem with column series color fill when placing it on secondary Y axis

Hi there,


When I create a chart with Column series on Primary Y and Line series on Secondary Y, column series gets filled with colour properly but on placing, Column series on Secondary Y and Line series on Primary Y, column series doesn’t get filled with any colour. Please check the below code:

Code:

Presentation pres = new Presentation();

//Access first slide
ISlide sld = pres.Slides[0];

// Add chart with default data
IChart chart = sld.Shapes.AddChart(ChartType.ClusteredColumn, x, y, 700, 200);

//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;

//Getting the chart data worksheet
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

//Delete default generated series and categories
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
//Adding new categories
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, “Caetegoty 1”));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 1, “Caetegoty 2”));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 1, “Caetegoty 3”));

//Add first chart series
IChartSeries seriesLine = chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, “Line Series”), ChartType.LineWithMarkers);
seriesLine.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 1, 0, 2));
seriesLine.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 2, 0, 5));
seriesLine.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 3, 0, 8));

foreach (IChartDataPoint dp in seriesLine.DataPoints)
{
IDataLabel dataLabel = dp.Label;
dataLabel.DataLabelFormat.ShowValue = true;
dataLabel.TextFormat.PortionFormat.FontHeight = 9;
}

//Add second chart series
IChartSeries series = chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, “Column Series 1”), ChartType.ClusteredColumn);
series.PlotOnSecondAxis = true;

//Now populating series data

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));

//Setting fill color for series
series.Format.Fill.FillType = FillType.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Red;

foreach (IChartDataPoint dp in series.DataPoints)
{
IDataLabel dataLabel = dp.Label;
dataLabel.DataLabelFormat.ShowValue = true;
dataLabel.TextFormat.PortionFormat.FontHeight = 9;
}
//Add third chart series
series = chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 3, “Column Series 2”), ChartType.ClusteredColumn);
series.PlotOnSecondAxis = true;

//Now populating series data
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60));

//Setting fill color for series
series.Format.Fill.FillType = FillType.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Green;

foreach (IChartDataPoint dp in series.DataPoints)
{
IDataLabel dataLabel = dp.Label;
dataLabel.DataLabelFormat.ShowValue = true;
dataLabel.TextFormat.PortionFormat.FontHeight = 9;
}

//Setting Major and minor grid lines format for value axis
chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
chart.Axes.VerticalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;

//Setting value axis title
chart.Axes.VerticalAxis.HasTitle = true;
chart.Axes.VerticalAxis.Title.AddTextFrameForOverriding("");
IPortion valtitle = chart.Axes.VerticalAxis.Title.TextFrameForOverriding.Paragraphs[0].Portions[0];
valtitle.Text = “”;

valtitle.PortionFormat.FillFormat.FillType = FillType.Solid;
// valtitle.PortionFormat.FillFormat.SolidFillColor.Color = Color.Gray;
valtitle.PortionFormat.FontHeight = 11;
valtitle.PortionFormat.FontBold = NullableBool.False;

chart.Axes.VerticalAxis.TextFormat.PortionFormat.FontHeight = 10;
chart.Axes.HorizontalAxis.TextFormat.PortionFormat.FontHeight = 10;

if (chart.Axes.SecondaryVerticalAxis != null)
{
chart.Axes.SecondaryVerticalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
chart.Axes.SecondaryVerticalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;

//Setting value axis title
chart.Axes.SecondaryVerticalAxis.HasTitle = true;
chart.Axes.SecondaryVerticalAxis.Title.AddTextFrameForOverriding("");
IPortion secondaryValtitle = chart.Axes.SecondaryVerticalAxis.Title.TextFrameForOverriding.Paragraphs[0].Portions[0];
secondaryValtitle.Text = “”;

secondaryValtitle.PortionFormat.FillFormat.FillType = FillType.Solid;
secondaryValtitle.PortionFormat.FontHeight = 11;
secondaryValtitle.PortionFormat.FontBold = NullableBool.False;

chart.Axes.SecondaryVerticalAxis.TextFormat.PortionFormat.FontHeight = 10;
}

if (chart.Axes.SecondaryHorizontalAxis != null)
{
//Setting visiblity for Secondary Horizontal Axis
chart.Axes.SecondaryHorizontalAxis.IsVisible = false;
chart.Axes.SecondaryHorizontalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
chart.Axes.SecondaryHorizontalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
}

chart.PlotArea.Height = 0.8f; //
chart.PlotArea.Width = 0.9f; //

chart.PlotArea.X = 0.0f;
chart.PlotArea.Y = 0.0f;

# region Legend

chart.Legend.Position = LegendPositionType.Bottom;

// chart.Style = ac.StyleType.Style1;

//Setting Legends Text Properties
IChartPortionFormat txtleg = chart.Legend.TextFormat.PortionFormat;
txtleg.FontBold = NullableBool.False;
txtleg.FontHeight = 11;

pres.Save(“demo_Chart.pptx”, SaveFormat.Pptx);

Please find attached presentation for help.

Hi Pradeep,

Thank you for sharing the sample code.

I am able to reproduce your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: SLIDESNET-36052. We will notify you via this forum thread once the issue gets resolved.

Thanks & Regards,

The issues you have found earlier (filed as SLIDESNET-36052) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.