Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A tool generating local images based on ECharts-Java

License

NotificationsYou must be signed in to change notification settings

ECharts-Java/Snapshot-PhantomJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  • Local unit testing
  • Docker
  • OS
    • Linux
    • Windows
    • MacOS
  • Integration Test with Snapshot version

Introduction

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.).

Prerequisite

To use this library, make sure you've installedphantomjs.

For Mac users using brew,

brew install phantomjs

For 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/phantomjs

For 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.

Installation

For a maven project, includes the following in your pom.xml

TBC

For a gradle project, includes the following

TBC

Usage

Snapshot.java is providing several APIs to be used, which includes takeSnapshot() and saveSnapshot().

SnapshotSettingsBuilder.java

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.

takeSnapshot(SnapshotSettingsBuilder settings)

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);

saveSnapshot(String imageData, String path)

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

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp