I have a core java project, in which I have to create a data visualization in form of a graph.
This data visualization (a graph) is dumped in HTML file(in Plantuml format), which renders the graph in visual graph.
Now I am looking for a way where I can dump this graph data structure as well(which is actually interlinked java objects) in some format, such that I can read it in java script/jquery thereby reconstructing the whole graph, along with loading the HTML file and update the graph in HTML dynamically, using the graph data structure based on some input from user.
Since plantuml doesn't support dynamic events.
And since the HTML file generated dynamically, so creating JSP and dynamically loading it on server is not feasible.
I have seen some answers suggesting use of JAXB, JSON, but the question wasn't exactly as I needed.
I am thinking to dump it in xml and then read that xml in java script.But not sure how good this idea is.
Is there a better way?
JavaScript is not good at reading XML. The ECMA-357 standard was designed for this, but is all but forgotten. You can still find it in Rhino, but that doesn't suit your purposes.
JSON is really the language to use these days.
GSON or Jackson are common libraries for turning Java objects into JSON.
ECMA-357 - E4X
GSON
Jackson
Related
I am writing an application in which I need to inspect the tree structure of PDF documents, modify this tree structure, and write the result back to another PDF.
The inspection and modification cannot happen in a dedicated library (e.g., PDFBox), since it is already written in a format-independent way for JSON-structured trees.
Ideally, what I need is a lossless conversion from PDF to any tree format (XML, JSON, ...) and back, in JavaScript or any other programming language, or as a command-line tool.
What I considered so far:
Using pdf2json. This converts a PDF to a JSON file. Unfortunately, the other direction (JSON->PDF) is not supported.
One can create a JSON with the Base64-encoded binary content of the PDF. This is lossless and works in both directions, but I am losing the tree structure that I want to inspect. Therefore, this is not an option.
Can anyone recommend a library or program to achieve this?
What Ruby libraries, if any, are there that generate a graph (such as line-graph) and output in html format (possibly using JavaScript/jQuery)?
Ruby is more suited to a backend engine (e.g. on Rails) providing data to a front-end JavaScript library which produces the graphs.
So Ruby would generate data in JSON format for example, which can then be easily read in by a variety of libraries to produce any type of graph (which you can also tailor using CSS if you wish).
See here for a comparison of a lot of them out there:
http://socialcompare.com/en/comparison/javascript-graphs-and-charts-libraries
My personal preference? D3.js which produces very nice SVG graphs.
Edit
You can also find ruby gems that provide tighter integration with a number of these charting libraries.
What would be the best alternative to xml for a javascript app. The app parse the data then uses Highcharts framework to show some charts.
I can't use xml because it has problems running locally on Internet Explorer (access denied error and other problems ....see my other question here).
Also this new thing that should replace xml in this situation should be exported from excel.
I was thinking about csv... but csv can be a little bit messy an not as easy to use as xml.
Thanks!
The best data format that you can use with JavaScript is JSON (JavaScript Object Notation) - it was designed for it.
I am creating a product that as end result will/can create e.g. 10 .sql files, each being a table. The tables will contain various pre-calculated data related to each other.
My users will need to upload these to their website (php, asp, whatever) and will need to make something useful. Only problem, the users may have next to zero understanding of databases, server-side code etc. This means it must be very easy to configure.
So I think thinking upload these .sql (or CSV files, whatever) tables to server, so they are publicly available (i.e. can be retrieved like any other public URL). And then find a Javascript in-memory database engine that can load .sql database files. Does this exist?
I imagine a Javascript solution could work well if amount of data could be kept somewhat down... Otherwise I may need to look for a PHP/ASP solution as well. (Any ideas for libraries that can init in-memory databases from .sql or similar files?)
Preferably I should be able to re-distribute this Javascript library. (So users can get a complete "directory" of .sql files + example page + Javascript database engine to upload)
So to make the question clear: Anyone knows a Javascript-based in-memory database engine that can run inside browser?
If you wish to use javascript and need some 'userfriendly' bridge database, you could use json or xml, because the format are simple text files (like csv as well) for wich you can find smart small editors for your users.
More json is made for javascript parsing and has an understanding tree format, but you should load only some part of sql datas in memory, saying data buffers in xml or json, with php requested with some javascript ajax call. Php do the sql database access work and then you can output json, and with javascript, it is for user's interface, you'll be able to display them.
You can use mysql to store a database in memory:
http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html
Here's a pure JS SQL engine that stores everything in memory, https://github.com/moxley/sqittle
It flatly denies being useful for anything though, and has a limited set of supported commands (see readme on above link.
http://diveintohtml5.ep.io/storage.html might be what you are looking for.
That question seems very old. You might want to look at LokiJS now.
I have a website with a table that is populated with data from various external XML feeds. The table is generated using Javascript as after some reading, I found that this seemed to be the best approach for creating an HTML table from XML data (please correct me if wrong!).
I now want to parse this HTML table in to an RSS feed and I'm struggling to find the best way to do so. I have php code that will parse an HTML table, but because this table is generated using JS (ie. client side) the PHP parser does not work. Can anyone tell me the best way to go about this?
As you've probably gathered, I'm quite new to programming so layman terms would be much appreciated where possible.
Thanks a lot.
I found that this seemed to be the best approach for creating an HTML table from XML data (please correct me if wrong!).
As a rule of thumb, if instant feedback isn't required (and it isn't if you are fetching data from multiple external sources), if you can do it server side, then do it server side. You only have one server side environment to deal with instead of dozens of different client side environments (some of which could have JS turned off).
I now want to parse this HTML table in to an RSS feed and I'm struggling to find the best way to do so. I have php code that will parse an HTML table, but because this table is generated using JS (ie. client side) the PHP parser does not work. Can anyone tell me the best way to go about this?
Write PHP to get the data from wherever the JS gets its data from. You already have the logic to query it in JS, so you should be able to do a fairly straight port of that.
It is not possible to generate an RSS feed from pure JavaScript, as most RSS clients don't speak JavaScript, and the standard doesn't provide for it - you won't be able to run the commands required to create the data.
Replicate the functionality of your JavaScript aggregator using some server-side language like PHP, and build an RSS feed from it. It will require rewriting your entire code, but probably is the best way to go.