@@ -47,7 +47,7 @@ private void writeHtml(String html, String path, Boolean willOpen) {
4747
4848/**
4949 * Used in simple chart case, render the echarts in html file, in default width,
50- * height and willOpen
50+ * height and willOpen. The html file also provides download chart function.
5151 *
5252 * @param path path to save the html file
5353 * @param chart the chart to be rendered
@@ -85,20 +85,43 @@ public void render(String path, Option option) {
8585 }
8686 }
8787
88+ /**
89+ * Used in simple chart cases, render the echarts in
90+ * customized width, height, and willOpen
91+ *
92+ * @param path path to save the html file
93+ * @param option the option used to init the chart
94+ * @param height the height of the chart, ends with "px" or "%"
95+ * @param width the width of the chart, ends with "px" or "%"
96+ * @param willOpen whether allowing to open the html in browser automatically
97+ * @throws IOException
98+ */
99+ public void render (String path ,Chart <?,?>chart ,String height ,String width ,Boolean willOpen ) {
100+ String jsonStr =EChartsSerializer .toJson (chart .getOption ());
101+ ChartMeta chartMeta =new ChartMeta (height ,width ,jsonStr );
102+ try {
103+ Template template =handlebars .compile ("index" );
104+ String html =template .apply (chartMeta );
105+ writeHtml (html ,path ,willOpen );
106+ }catch (IOException e ) {
107+ log .info ("render: Handlebars cannot find corresponding templates." );
108+ }
109+ }
110+
88111/**
89112 * Used in both simple and advanced chart cases, render the echarts in
90113 * customized width, height, and willOpen
91114 *
92115 * @param path path to save the html file
93116 * @param option the option used to init the chart
94- * @param height the height of the chart
95- * @param width the width of the chart
117+ * @param height the height of the chart, ends with "px" or "%"
118+ * @param width the width of the chart, ends with "px" or "%"
96119 * @param willOpen whether allowing to open the html in browser automatically
97120 * @throws IOException
98121 */
99- public void render (String path ,Option option ,int height ,int width ,Boolean willOpen ) {
122+ public void render (String path ,Option option ,String height ,String width ,Boolean willOpen ) {
100123String jsonStr =EChartsSerializer .toJson (option );
101- ChartMeta chartMeta =new ChartMeta ("600px" , "600px" ,jsonStr );
124+ ChartMeta chartMeta =new ChartMeta (height , width ,jsonStr );
102125try {
103126Template template =handlebars .compile ("index" );
104127String html =template .apply (chartMeta );
@@ -118,7 +141,7 @@ public void render(String path, Option option, int height, int width, Boolean wi
118141 */
119142public String renderHtml (Chart <?, ?>chart ) {
120143String jsonStr =EChartsSerializer .toJson (chart .getOption ());
121- ChartMeta chartMeta =new ChartMeta ("600px " ,"100%" ,jsonStr );
144+ ChartMeta chartMeta =new ChartMeta ("100% " ,"100%" ,jsonStr );
122145Template template =null ;
123146try {
124147template =handlebars .compile ("base" );
@@ -139,7 +162,7 @@ public String renderHtml(Chart<?, ?> chart) {
139162 */
140163public String renderHtml (Option option ) {
141164String jsonStr =EChartsSerializer .toJson (option );
142- ChartMeta chartMeta =new ChartMeta ("600px " ,"100%" ,jsonStr );
165+ ChartMeta chartMeta =new ChartMeta ("100% " ,"100%" ,jsonStr );
143166Template template =null ;
144167try {
145168template =handlebars .compile ("base" );
@@ -150,6 +173,28 @@ public String renderHtml(Option option) {
150173 }
151174 }
152175
176+ /**
177+ * Used in the simple cases, render the echarts in customized
178+ * width and height, without download button
179+ *
180+ * @param option the option to initiate the chart
181+ * @param height the height of the chart, ends with "px" or "%"
182+ * @param width the width of the chart, ends with "px" or "%"
183+ * @return the resulted string in html format
184+ * @throws IOException
185+ */
186+ public String renderHtml (Chart <?,?>chart ,String height ,String width )throws IOException {
187+ String jsonStr =EChartsSerializer .toJson (chart .getOption ());
188+ ChartMeta chartMeta =new ChartMeta (height ,width ,jsonStr );
189+ try {
190+ Template template =handlebars .compile ("base" );
191+ return template .apply (chartMeta );
192+ }catch (IOException e ) {
193+ log .info ("renderHtml: Handlebars cannot find corresponding templates." );
194+ return "" ;
195+ }
196+ }
197+
153198/**
154199 * Used in both the simple and advanced cases, render the echarts in customized
155200 * width and height, without download button
@@ -160,9 +205,9 @@ public String renderHtml(Option option) {
160205 * @return the resulted string in html format
161206 * @throws IOException
162207 */
163- public String renderHtml (Option option ,int height ,int width )throws IOException {
208+ public String renderHtml (Option option ,String height ,String width )throws IOException {
164209String jsonStr =EChartsSerializer .toJson (option );
165- ChartMeta chartMeta =new ChartMeta ("600px" , "100%" ,jsonStr );
210+ ChartMeta chartMeta =new ChartMeta (height , width ,jsonStr );
166211try {
167212Template template =handlebars .compile ("base" );
168213return template .apply (chartMeta );