Issue with Line chart width and dash type

Hi,

I am trying to increase the width and the dash type of a line chart.
Here’s the code i am using to try and achieve this.

SeriesCollection seriesCollection = chart.getNSeries();
Series series = seriesCollection.get(0);
Line line = series.getBorder();
line.setDashType(MsoLineDashStyle.SOLID);
line.setWeightPt(7);

The issue with this is that only the width and the dash style of the legend entry changes and the actual series does not change at all.
When checking the generated excel, the value which has got changed is Design -> Format Legend -> Border Styles -> Width and Dash type

What I am actually looking to change is Design -> Format Data Series -> Line Style -> Width and Dash Type.

This stems from a bug when generating a PDF where a Dash Type of “dot dot” doesn’t render correctly. (attached excel_rendering vs pdf_rendering)

Can you please help me with how best this issue can be resolved.

Aspose version: 8.1.2
jdk 1.6

Regards,
Akshay

Hi Akshay,

Thanks for your posting and using Aspose.Cells.

We have tested this issue with the following code and it generated the correct results. I have attached the source xlsx file used in this code and output xlsx file generated by it for your reference. I have also attached the screenshot showing the source and output Excel files.

I have tested it with the latest version: Aspose.Cells for Java 8.1.2. If you still find any issue, then please attach your output files and let us know your sample code. We will look into it and help you asap.

Java


String filePath = “F:\Shak-Data-RW\Downloads\source.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.getWorksheets().get(0);


Chart chart = worksheet.getCharts().get(0);


chart.getNSeries().get(0).getBorder().setWeightPt(7);

chart.getNSeries().get(0).getBorder().setDashType(MsoLineDashStyle.ROUND_DOT);


workbook.save(“output.xlsx”);



Hi Shakeel,

This still doesn't work for me.

seriesCollection.get(2).getBorder().setDashType(MsoLineDashStyle.SOLID);

seriesCollection.get(1).getBorder().setDashType(MsoLineDashStyle.DASH_LONG_DASH);

That is my code, and i've attached the result which I get.

Where could this be going wrong? Would it make a difference between excel 2007 vs 2010. I'm using excel 2007

Regards,

Akshay

Hi Akshay,

Thanks for your posting and using Aspose.Cells.

There is a little error in your code. Could you either try index 1 in both lines or 2 in both lines. Please see the red highlighted indices.

seriesCollection.get(2).getBorder().setDashType(MsoLineDashStyle.SOLID);


seriesCollection.get(1).getBorder().setDashType(MsoLineDashStyle.DASH_LONG_DASH);

I have tried the above code and it worked fine.

If your problem still persists, then please provide us your source Excel file and the runnable sample code so that we could diagnose this and help you resolve it.

Hi Shakeel,

Thanks for the help on that.

One more issue remains.

When we save this as a PDF, the pdf is unable to render dash or dot dashTypes. The only dashType that can be seen on a pdf is SOLID.

Attaching the input excel (input.xlsx), the output pdf

Here's the java code being used to generate the pdf

try {

String filePath = "C:\\devTest\\input.xlsx";

Workbook workbook = new Workbook(filePath);

Worksheet worksheet = workbook.getWorksheets().get(1);

Chart chart = worksheet.getCharts().get(0);

SeriesCollection seriesCollection = chart.getNSeries();

seriesCollection.get(3).getBorder().setDashType(MsoLineDashStyle.DASH_LONG_DASH);

workbook.save("C:\\devTest\\output.xlsx");

workbook.save("C:\\devTest\\output.pdf",FileFormatType.PDF);

}

catch(Exception e) {

e.printStackTrace();

}

Regards,

Akshay

Hi Akshay,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue after running your code with your source file using the latest version: Aspose.Cells for Java 8.1.2. Aspose.Cells is unable to render the Dash or Dot Dash Type series.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSJAVA-40934.

I have attached the screenshot highlighting the issue for a reference.

Hi,

We have evaluated your issue further.

Well, I am afraid, we don’t support generating chart in EMF format with dash type line. Please insert the following code segment before creating PDF to fix your issue.

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

pdfSaveOptions.setImageType(ImageFormat.*getPng*());

workbook.save(path + "Png.PDF", pdfSaveOptions);

Let us know if you still find any issue.

Thank you.

Hi,


Please try our latest version/fix: Aspose.Cells for Java v8.4.0:
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/entry614286.aspx

We have fixed the following issue in it:
CELLSJAVA-40934 - Unable to render Dash or Dot Dash Type Series

Let us know your feedback.

Thank you.