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.
Related
I know that it's possible to transform avdl to series of avsc files using java tools provided by Apache.
But despite the website lists plenty of implementations on different languages too, including JS, it seems to be that there is no support for avdl -> avsc conversion in these.
What would be your recommendation how to perform this conversion in pure JavaScript? Does such library even exists or we're forced to go through pure Java implementation always?
Java seems to be the only language that they implemented the compilation from avdl to avsc. The easiest route is probably just to have the avro-tools.jar somewhere and then have your JS code call out to that in some sub process to compile the schemas.
The other option would be to re-implement the IDL compiler in JS. I wouldn't do that, but the Java implementation is pretty much all contained within https://github.com/apache/avro/blob/master/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj if you wanted to take a look.
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
Our web application(many d3 charts) is set up by vue, and I could export our
webpage to pdf by the combination of canvg, html2canvas(convert web content to
png) and emit png file to server and use nodejs to download it automatically
and periodically(weekly report).
However, I was asked to use different render method from client-side to
server side rendering and use wkhtmltopdf or phantomjs to download pdf.
My question is that is it difficult to render many complicated d3 chart and edit
css in server side rendering by using vue or another technique?
Thanks!
The wkhtmltopdf is a popular library for converting complex html content to pdf.
You don't have to worry about your complicated d3 chart or css. It will handle it. But you have to install wkhtmltopdf command line tool on your system.
SVG DOM elements can be convert into different images format using server side rendering option. Apache Batik such a library to convert SVG DOM elements into pdf,png,jpg,word.
Batik is a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) format for various purposes, such as display, generation or manipulation.
The project’s ambition is to give developers a set of core modules that can be used together or individually to support specific SVG solutions. Examples of modules are the SVG Parser, the SVG Generator and the SVG DOM. Another ambition for the Batik project is to make it highly extensible —for example, Batik allows the developer to handle custom SVG elements. Even though the goal of the project is to provide a set of core modules, one of the deliverables is a full fledged SVG browser implementation which validates the various modules and their inter-operability.
I'm looking to use this chart generation library: http://www.jqchart.com/
Ideally, I would prefer to use a PHP charting library for the current project I'm working, but, by the looks of it, this is the only library I've found that can handle what I need to do (given a somewhat unconventional requirement for the charts).
The issue is that I need to get the generated graphs as images (at the moment each graph seems to be a combination of images) to the server so that I can generate some PDF documents, etc.
I'm thinking of attempting to create an image using JS, pushing this back to the server and then generating the PDF although this pretty nasty and will probably cause issues between different versions of the browser.
So now what I'm looking for is a solution that will allow me to generate the graphs and turn them into images on the backend.
Any ideas?
EDIT: For the requirement that led me to rule out a number of other charting libraries, see here: Complex charts in Google Charts
That really isn't all that relevant to the question of processing Javascript on the server, though.
You can render a javascript graph on the server using phantomjs. Here is an example.
Not sure what your requirements are, but I'd check out Google Chart Tools: http://code.google.com/apis/chart/. It's really simple to use. All the data is in the image URL get request, so you can generate charts using client-side JavaScript too.
I have Javascript, Django templates, Python code, and CSS which all work with the same configuration data. Where's the best place to configure it?
Specifically, I have a browser-side entry widget in Javascript which controls an embedded Java app. When the user is done, the Javascript asks the Java applet for an image of the result, which will be embeded in the HTML. The user can specify if the image should be small, medium, or large. That image and the choice are sent via an AJAX call to my Django app, which does some input validation. When the HTML is displayed it includes my CSS, which has special a[href^=http://internal.server] markup to show those images in a different way than other images.
While someone asked a similar question, the answers were either: "use a DSL" or "use a format like XML or JSON." Neither of which work with CSS.
The two solutions I came up with are:
put the data in Python and have it generate the HTML through a Django form/template. Also have Django dynamically generate the Javascript configuration and generate that CSS.
I don't like this because I would rather serve all my Javascript and CSS statically.
Introduce a build step where configuration data gets applied to a template to build the respective Javascript, HTML, CSS, and Python files.
Which makes things more complicated because I'll have special "*.in" or such files which build the actual files, and everyone will have to watch out that they know which files are the ones to edit.
What do you do?
Use JSON. Generate the CSS dynamically, using caching to reduce load.
I think an really good approach would be to effectively have a DSL expressed indirectly via JSON data structures laid out using some sort of coding convention, coupled with a separate build step that used that to create the configuration files needed. If the tool(s) for this build step were written in Python, creating, maintaining, and enhancing it or them ought to be relatively easy.