- Notifications
You must be signed in to change notification settings - Fork2
A tool generating local images based on ECharts-Java
License
ECharts-Java/Snapshot-PhantomJS
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- Local unit testing
- Docker
- OS
- Linux
- Windows
- MacOS
- Integration Test with Snapshot version
This library is used to take snapshots of the charts generated by ECharts-Java. Now it supports images in PNG and JPEG formats with pixelRatio control. Base64 is also supported. We plan to support SVG in the near future. (It is still in the testing stage, please file an issue if you spot a bug.).
To use this library, make sure you've installedphantomjs.
For Mac users using brew,
brew install phantomjsFor AWS Linux users,
sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2sudo mkdir /opt/phantomjsbzip2 -d phantomjs-2.1.1-linux-x86_64.tar.bz2sudo tar -xvf phantomjs-2.1.1-linux-x86_64.tar --directory /opt/phantomjs/ --strip-components 1sudo ln -s /opt/phantomjs/bin/phantomjs /usr/bin/phantomjsFor other users, please refer to the official website ofphantomjs for downloading details.
For Mac users, if you encounter the error "phantomjs cannot be opened because the developer cannot be verified.", please refer to the solutionhere.
For a maven project, includes the following in your pom.xml
TBCFor a gradle project, includes the following
TBCSnapshot.java is providing several APIs to be used, which includes takeSnapshot() and saveSnapshot().
It constructs an object with the following properties as the metadata of the snapshot.
Required:
String fileType: the fileType of the image. Now we support "png", "jpg", and "txt". Note that for "txt" file, the image will be stored into the text file as base 64 encoding.Option option: must have this field if Chart chart is not specified. This is the option object of ECharts.Chart<?,?> chart: must have this field if Option option is not specified. This is the chart object defined in ECharts-Java.
Optional:
height: the height of the image - supports "px" or "%". Default is "100%".width: the width of the image - supports "px" or "%". Default is "100%".double pixelRation: the pixel ration of an image. It is definedhere.
This function takes an object related to the settings of snapshot, and returns a base64 string of the image.
SnapshotSettingsBuilderbuilder =newSnapshotSettingsBuilder(option,"png");returnSnapshot.takeSnapshot(builder);
This function takes the base64 string of an image, and saves the image by the suffix specified bypath. E.g. if the path is./test.png, it will store the image as png file. Now only PNG and JPG are supported. Any other file types will lead to a file with plain base64 string of that image. Note that the file type should be consistent with the one used in takeSnapshot.
SnapshotSettingsBuilderbuilder =newSnapshotSettingsBuilder(option,"jpg",1,2);Snapshot.saveSnapshot(Snapshot.takeSnapshot(builder),"./test.jpg");
About
A tool generating local images based on ECharts-Java
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.