Highcharts charts svg should be rendered using htmlunit-driver same as it is any other browser like chrome, edge, firefox etc
But the charts rendered are too small. Generated svg has a few NaN
in the width attributes of couple rect
tags. Moreover linearGradient
and clipPath
tags are all lowercased in the svg.
I have copied my sample project jdoodle. But it is not able to download maven dependencies. Anyways you can check my code for reference and copy the project to your local to run it:
https://www.jdoodle.com/ia/BEk
Brief structure of my example project:
- highcharts-export.html (My custom html file to be used by htmlunitt)
- highcharts-export.js (My custom js file to be used by htmlunit)
- highcharts and highcharts-more js files
- HighchartsExport.java the java code which uses selenium and htmlunit to execute the above html/js code to generate highcharts chart.
maven deps:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.7.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>4.7.2</version>
</dependency>
</dependencies>