Free Support Forum - aspose.com

Set color for inverted bar chart series in php

Hi Team,

I have PPTX file which has lot of charts and im updating its value using php.

But the issue is that the color disappear for inverted bar chart and even when i tried to set it manually it was not possible.

Below is my code to set the color manually for bar chart.

$series = $chart->getChartData()->getSeries()->get_Item(0);

//setting labels for the categories
$chart->getChartData()->getCategories()->get_Item($i)->setValue($labelName);

$series->getFormat()->getFill()->setFillType(‘SOLID’);

//color class initialization
$color = new Java(“java.awt.Color”);

$series->getFormat()->getFill()->getSolidFillColor()->setColor($color->red);

//setting values for the chart series
$series->getDataPoints()->get_Item(0)->getValue()->setData($val);

I have even tried to set the series color automatically even this did not work

$chart->getChartData()->getSeries()->get_Item(0)->getAutomaticSeriesColor();

Hope you could help me to resolve it.

Regards,
Anup

Hi Anup,

I have observed the issue shared by you and it seems related to InvertIfNegative property of chart series. I request you to please try using Aspose.Slides for Java 15.3.0 on your end which has resolve the issue of negative values getting rendered with blank color. Also, try setting the InvertIfNegative property for the chart series as well in your presentation.

series.setInvertIfNegative(false);

Many Thanks,

Hi Mudassir,


Thanks for replying.

How do i use this Aspose.Slides for Java 15.3.0 i have downloaded the package.

I have used

java_autoload(“lib\aspose.slides-15.3.0-jdk16.jar”);

in php windows platform but its not working.

Thanks

Hi Chris,

Please accept my apologies for the delayed response.

I
like to share that Aspose.Slides for Java can be used in PHP using PHP
Java bridge integration. I suggest you to please observe the attached
document for your kind reference. You will have an information about how
to get started with the things.

Many Thanks,

Hi Mudassir,


I have used Aspose.Slides for Java 15.3.0 and i have added series.setInvertIfNegative(false);

But still it does not work.

Hi Chris,

I request you to please share the working sample project with us reproducing the issue. I will use that on my end to verify things and help you further in this regard.

Many Thanks,

Hi Mudassir,


Below is my working code. Please check it and let me know about it,

require_once(“http://localhost:8080/JavaBridgeTemplate621/java/Java.inc”);
java_autoload(“lib\aspose.slides-15.3.0-jdk16.jar”);

$fistream=new Java(“java.io.FileInputStream”,getcwd()."/modules/Survey/data/Aspose.Slides.lic");
//Instantiate the License class
$license=new Java(“com.aspose.slides.License”);
//Set the license through the stream object
$license->setLicense($fistream);
//Closing the stream
$fistream->close();

$pptx = new Java(“com.aspose.slides.Presentation”,$filePath.$fileName);

$sld = $pptx->getSlides()->get_Item(221);
$chart = $sld->getShapes()->get_Item(7);

$series = $chart->getChartData()->getSeries()->get_Item(0);
$series->setInvertIfNegative(false);
//setting labels for the categories
$chart->getChartData()->getCategories()->get_Item($i)->setValue($labelName);

//$series->getFormat()->getFill()->setFillType(‘SOLID’);

//color class initialization
//$color = new Java(“java.awt.Color”);

$series->getFormat()->getFill()->getSolidFillColor()->setColor($color->red);

//setting values for the chart series
$series->getDataPoints()->get_Item(0)->getValue()->setData($val);

Thank You.

Hi Chris,

Thank you for sharing the sample code with us. I have observed that you are using some presentation that you are loading. Please provide the source presentation so that I may use that on my end and try reproducing the issue.

Many Thanks,

Hi Mudassir,


I have attached my PPTX file. Please check slide 23.

Thanks

Hi Anup,

I have observed the chart on slide 23. I have observed that the InvertIfNegative value is
false for the chart in source presentation but still the cells are rendered
blank. Which should not be done. It seems some issue in source presentation. When using your source presentation with Aspose.Slides and InvertIfNegative value is set to false, it is not taking any effect. An issue with ID SLIDESJAVA-34856 has been created in our issue tracking system 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 be resolved.

We are sorry for your inconvenience,

Hi Mudassir,


Actually the ppt file which i have sent is the output of the master slide which i have been updating it. Please check the below presentation slide 221 from which im getting the above ppt.

Hi Anup,

Thank you for sharing the PPT file with us. Please share the working sample java file with us so that I may use that on my end to further investigate the issue. The sample code that has been shared by you is not complete and unusable. Please share the requested information so that I may proceed further with investigation on my end.

Many Thanks,

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


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