Showing posts with label highcharts. Show all posts
Showing posts with label highcharts. Show all posts

Tuesday, February 5, 2013

Highcharts Phantomjs Export - TypeError: 'undefined' is not an object

Generating a png file from config-

phantomjs-1.8.1/bin/phantomjs highcharts-convert.js -infile config.json  -outfile out1.png -width 300 -scale 2.5 -constr Chart -callback callback.js

Error-
TypeError: 'undefined' is not an object (evaluating 'svgElem.getAttribute')
phantomjs://webpage.evaluate():20
phantomjs://webpage.evaluate():23
phantomjs://webpage.evaluate():23
TypeError: 'null' is not an object (evaluating 'svg.width')
highcharts-convert.js:89
highcharts-convert.js:322
:/modules/webpage.js:277
view raw gistfile1.js hosted with ❤ by GitHub

Things to check-
1. The following 3 files should be there in same folder or you have to set the paths to these here-
var config = {
                /* define locations of mandatory javascript files */
                HIGHCHARTS: 'highstock.js',
                HIGHCHARTS_MORE: 'highcharts-more',
                JQUERY: 'jquery-1.8.2.min.js'
        },

2. The 'infile' parameter should have an extension of .json, because that is what it uses to decide between svg input and a configuration json.

Friday, February 1, 2013

GWT - Highchart export request - Read multipart/form-data parameters

Getting multipart-form-data request parameters in java servlet-

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
if (!ServletFileUpload.isMultipartContent(req)) {
throw new ServletException("Not a file upload request");
}
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter;
iter = upload.getItemIterator(req);
while (iter.hasNext()) {
FileItemStream item = iter.next();
InputStream stream = item.openStream();
if (item.isFormField()) {
if (item.getFieldName().equalsIgnoreCase("svg")) {
svg = Streams.asString(stream);
}
...
...
}
}
}