Export Chart Using PhantomJS From WebServer - highcharts

Using HighCharts 3.x and PhantomJS as a webserver how can I send in the correct JSON string when a user clicks on the export button on the webpage? Following along with the documentation here I can see how to set up PhantomJS as a standalone webserver. I can send in a curl command to export sample charts. I want to now use this method to send requests for an export using a website that is hosting a chart such that when the user clicks on export it goes out to the PhantomJS url/port and sends it the JSON of the chart to be exported. I have it set up currently to use my testing server but when I click to export the chart I get the following error:
Failed rendering: SyntaxError: Unable to parse JSON string
This makes sense because the export options, to the best of my knowledge, send out an SVG string. How to make it send the HighCharts JSON string instead?

file download isnĀ“t supported by PhantomJS.. That's why the phantomjs export-module is returning a 64 bit string representation of a image. So, in the end this isn't going to work out of the box.
You get the Unable to Parse JSON error because the PhantomJS script is expecting this format {infile: ... , outfile: ...} and standard export functionality of Highcharts is sending a POST request with post parameters.

Related

Update variable information in the openwrt web interface luci

From the picture we see the value of RSSI, there is a code on lua and sh that displays this value, the script sh writes a value to the file, in lua we write it to a variable from the file and assign it to the label element
os.execute('/bin/rssi')
file = io.open("/tmp/rssi", "r");
d:option(DummyValue, "label", "rssi: "..(file:read("*line")));
file:close();
Everything works, but I want to see information in the web interface every N second. I will be grateful for your help.
It's something that has to be implemented at the frontend (HTML, JS, PHP), not in the Lua backend. I don't know how the kids do it these days, but from what I know, you'd need to use JavaScript to refresh that part of the HTML document every few seconds, as you want.
The way it works is as such:
Request a web page from Chrome/Firefox/Opera/Edge;
Web server opens requested file, if file is a script, script runs;
Script retrieves data from systems, databases, etc.;
3.1 Lua script runs, returns value (of RSSI, for you);
3.2 Script replaces variable by value returned by Lua script;
3.3 Script returns HTML code where variables have been replaced by values from databases, systems, etc.;
Web server sends data over the network;
Client web browser displays the data, usually as a HTML document formatted by CSS, with JavaScript interactivity, and automatic activities.
In your case, you'd want this:
JavaScript in client browser refreshes part of the document, essentially going through steps 1-5, but only replacing a portion of what's being displayed (an HTML element).

url field is not getting recognised in Watson Discovery service during conversion

Inline with this thread
How do we get the document file url using the Watson Discovery Service?,
I tried adding url field inside HTML document under various tags like p, directly as
<"url">...<"/url"> etc inside <"body"> tag.
Whatever I do, this url field that I am trying to add is not getting reflected either under extracted_metadata or under html or under text in the json when I see the resulting json after conversion / enrichment in the discovery tooling. Can someone throw some hint on what I can do to get url field just like title under extracted_metadata section in the json output?

Struts2, type conversion and json plugin (struts2-json-plugin-2.3.14.2)

I have created a web application that simulates an excel spreadsheet.
I would like to use Spanish number format. Example 2.345,67 and not american format: 2,345.67
In the server side I save these values in a List of BigDecimal numbers (List<BigDecimal>).
To send the information from client to server and server to client I am using Ajax with Json.
The problem is that automatically only works the american format (1,234.56). I suppose that I need to create a Type Conversion but It seems that when I am using in the server the package json-default it doesn't work.
Please help.

Display response of Dropbox API thumbnail() in Rails app

I have successfully returned a thumbnail() request (using the Dropbox SDK) in my rails app, but I don't understand how to process the response. I would like to show the thumbnail on a webpage.
I also tried to save the response to a tmp file, but get a UndefinedConversionError ("\xFF" from ASCII-8BIT to UTF-8) error.
I'm actually doing exactly what you are asking for. What I did was to convert the returned bytes into a base64 string. In C# it's quite easy as there is a convert function to do that.
On the webpage you then have to set the src attribute of a img tag to
<img src="data: image/jpg;base64,PlaceBase64StringHere"...../>
There is a little overhead in the converted string, but it's very easy to handle and you use the power of the client browser to render the image.

wkhtmltopdf get/post command

I am trying to get wkhtmltopdf to take a screenshot of http://www.health.ny.gov/professionals/doctors/conduct/license_lookup.htm with the field search for license "lastname,first". Below is what I am currently sending in command line and is not working.
wkhtmltopdf -n post http://www.nysed.gov/COMS/OP001/OPSCR1 lastname,first screenshot.pdf
Any ideas?
If you are trying to get a PDF out of the search results page, the following command works using the latest version at the time of posting (wkhtmltopdf 0.11.0 rc2):
wkhtmltopdf --post profcd 60 --post pname smith http://www.nysed.gov/COMS/OP001/OPSCR1 out.pdf
You can check the version with wkhtmltopdf -V.
You need the profcd to as the backed seems to require it for the searches to work, otherwise you get something like "must select Profession".
Is that what you meant? Or did you want a PDF of the search page itself with the form inputs filled with your values? That will require some trickery I don't think it's impossible.

Resources