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

Free Support Forum - aspose.com

Updateing a negaive bar chart

I have been trying to update the chart that is in the image using aspose.slides and was wondering how It would be done…


as i cannot really find the method which would aid me in doing so…

the chart had been saved as an image

Hi Tarang,


Thanks for your interest in Aspose.Slides.

I have observed your requirements and like to share that you may use the following code snippet to serve the purpose of generating desired chart. I have shared the sample code that can render the series in negative region. However, there is small issue that when negative or values less then horizontal scale values are rendered, their fill color is removed. This is due to missing property in Aspose.Slides and I have created an issue with ID SLIDESNET-33821 to provide the feature support. I have also shared the image that highlights the missing feature and un-checking the encircled values will fill the unfilled series values. In my opinion, if you are using template chart then this issue may not even occur. But you can verify this on your end.

public static void addBarChart()
{
PresentationEx pres = new PresentationEx();
ChartEx chart = pres.Slides[0].Shapes.AddChart(ChartTypeEx.ClusteredColumn, 20, 20, 500, 400);
//Setting values of Y-axis or Value axis
chart.ValueAxis.IsAutomaticMaxValue = false;
chart.ValueAxis.IsAutomaticMinValue = false;
chart.ValueAxis.CrossType = CrossesTypeEx.Custom;
chart.ValueAxis.MinValue = 0;
chart.ValueAxis.MaxValue = 400;
chart.ValueAxis.CrossAt = 100f;

chart.ChartData.Series.Clear();
int defaultWorksheetIndex = 0;
//Getting the chart data worksheet
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;

//Adding new series
int id=chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, “Series 1”), chart.Type);
ChartSeriesEx series = chart.ChartData.Series[id];


//Now populating series data

series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, 30));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 1, 150));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 1, 320));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 4, 1, 80));

series.Format.Fill.FillType = FillTypeEx.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Red;
series.IsColorVaried = false;
pres.Write(“D:\Aspose Data\SampleChart.pptx”);
}

Please share, if I may help you further in this regard.

Many Thanks,

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(1)

Hi,

I am using Aspose.slide for .Net 14.7.0 but still the issue exists where when set InverifNegative attribute to false even then the series is filled with white color. I have to uncheck and check it again in the exported slide. Could you please help me on this?

Thx,
Priya

Hi Priya,

I have observed that you have made similar request in another forum thread as well. I have shared the feedback with you in this regard as well. An issue with ID SLIDESNET-35738 has been added for Aspose.Slides for .NET in this regard as well to resolve the issue. We will share the feedback with you as soon as the issue will be resolved.

Many Thanks,

Hi Priya,

The issue has been marked as resolved in Aspose.Slides for .NET 15.3.0. We will share the good news with you as soon as the product will be available online.

Many Thanks,

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


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

This doesn’t seem to be working (See attachment).


I set series.setInvertIfNegative(false). That does come through, but all the points are set to true, which overrides the series setting. And there is no similar option for the point.

The negative series is meant to be red. And I don’t see a method to change the other color for a solid fill.

Any suggestions?

Hi Shaun,

I have observed the presentation file shared by you and request you to please share the sample application, source presentation and generated presentation with us. I will investigate the issue further on my end on provision of requested information. Please share the requested information so that I may help you further in this regard.

Many Thanks,

There is no source presentation. Output attached.


No way to change clear “invert if negative” from the points, even though the series is set to false.

public static void main(String[] args) throws Exception {
final Presentation pres = new Presentation();
final IChart c = pres.getSlides()
.get_Item(0)
.getShapes()
.addChart(
ChartType.ClusteredColumn,
0, 0, 720, 540);
final IChartData d = c.getChartData();
d.getSeries().clear();
d.getCategories().clear();
final IChartDataWorkbook wb = d.getChartDataWorkbook();
wb.clear(0);
int categories = 10;
for(int i = 0; i < categories; i++) {
d.getCategories().add(wb.getCell(0, 0, i+1, "Category "+i));
}
final Random r = new Random();
for(int s = 0; s < 3; s++) {
final IChartSeries series =
d.getSeries().add(
wb.getCell(0, s+1, 0, "Series "+s),
c.getType());
for(int i = 0; i < categories; i++) {
int value = r.nextInt(50)+1;
if(s == 2) {
value = -value;
}
series.getDataPoints().addDataPointForBarSeries(
wb.getCell(0, s+1, i+1, value));
}

}
for(int s = 0; s < 3; s++) {
final IChartSeries series =
d.getSeries().get_Item(s);
series.setInvertIfNegative(false);
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.RED);
}
pres.save(“D:/test.pptx”, SaveFormat.Pptx);
Desktop.getDesktop().open(new File(“D:/test.pptx”));
}

Hi Shaun,


I have worked with the sample code shared by you and have been able to observe the issue specified. An issue with ID SLIDESJAVA-34970 has been created in our issue tracking system as regression to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will resolved.

We are sorry for your inconvenience,

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


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