Dynamic handling of mongodb data - javascript

My requirement is to generate charts using fusion charts.
I'm supposed to provide data to fusion charts from MongoDB which is a no SQL database.
MongoDB stores data into collections which is in the json format.and fusion charts accepts the data either in json format or in Xml format.
how should i provide the data to the fusion charts?
Currently I have written a java class to read the collection and put it into the .json file and I am passing this json file to the fusion charts(ie. a program written in html embedded with javascript)separately.I am stuck with the issue that how to call a java function from javascript?
Hence is there any other better alternative for this ??

Well, it isn't an easy task. You must make a Java Web Application with a Servlet, REST service or whatever you want. Then you must deploy the application in an application server like Tomcat or JBoss, so your HTML+Javascript application is able to do request to your Java service.
You can't call a standalone Java class from an HTML+Javascript page.
I think you're trying to do something that you don't know anything about... and must read a lot about the subject.

how should i provide the data to the fusion charts?
FusionCharts has specific data formats for different charts. So if you have got the data from your MongoDB you need to parse and create FusionCharts compatible JSON data. So any JSON data wont work.
I hope I am wrong in assuming that, you have already done so. Otherwise you really need to learn a lot about simple things about reading the basics of any library, you intend to work.

Related

Store data on server without Database

I’m webGL engine developer (ThreeJS) in small company. We have some events in few weeks and my boss just told me that i have to make registration form as soon as possible, also one page should show names, lastnames and company of all registered members. Problem is that i’m very bad in databases and i have really small amount of time to re-learn it. How can i store registration data on Server without Database? I looked up on web and most instructions are unclear(because i’ve not worked on database before) and others are using localstorage (as far as i know its used for cacheing data)
What you're looking for is a flat file database system, try taffyDB it basically use Json to store its data or Papa parse that uses CSV files, you can easily edit with excel for example.
If you're really good with javascript you can consider using a real database after all,mongodb is a bit advance but still not as complicated as mysql or even sqlite.

Django app to run a python ML application

I have a python/pandas application that does data analysis and outputs reports to csv format. I would like to out an interactive front end UI on top of this application so the user can mix and match data, select parameters for scenario testing, have interactive charts and dashboards displayed on screen instead of csv etc.
I am looking to use Django, but for interactive charts, do I need to learn a javascript library (which one), or will Django be sufficient?
I recommend going to agree with Django (and moving your csv into a database). Out of the box Django 2 brings sqlite which is a file based database that would offer you the ability to swap database files if you wanted. I've found this (https://www.fusioncharts.com/django-charts/) django-charts package that incorporates interactive charts with Django, and seems to have lots of examples.

Generate charts without HTML / Browser

I have a node.js application that accesses data of a MySQL database and I want to generate charts from that data dynamically, to pipe it as image (PNG/JPG) through a HTTP server to the user. I've search for a little while now, but I was unable to find a library to do this without the HTML/canvas approach. Since I want to let the server do the rendering to use the graph in emails or also dynamically rendered PDF files, this isn't an option here.
What could be the approach here (with or without a library) ?
Edit to provide proof of own work: I found https://plot.ly, which is in terms of usage and result really close to fulfil my needs, but requires an internet connection, since it calls a remote API.
You could also try asking this in the Software Recs Stack Overflow. But one option that seems like it could fit your needs is ZingChart.
They have a phantomJS build for rendering static versions of charts. In addition, licensed users can access a Node.js build for server side charting.
Full disclosure, I'm on the ZingChart team so please let me know if I can help you review all your options.
There is a node wrapper for the chart library chartist. You could use this library to generate a SVG, and a svg2png lib to convert to PNG.
Well there are multiple options, I would use phantomjs (headless Webkit browser) to render the charts.
Why would this option be good? One of the reasons is that you don't need duplicated code for the server and client side coding, you could simply reuse the code. On server side create a html file with required scripts and data and render it.

Calling Google Visualization API Server-Side

I'm working on a project that involves exporting some HTML reports on a website into PDF format. I'd like to use the excellent flying-saucer Java library to do this but my major stumbling block is that several of these reports use the Google Visualization API to generate charts with JavaScript. Flying-saucer doesn't currently support parsing/executing JS, so those charts don't show up in the generated PDF file.
I was hoping to work around this by seeing if there was some kind of web service I could call instead via server-side code that would return the chart image in Base64 as a variable that I could reference in my view instead of getting it via JS.
The old Google Image Charts API is exactly what I'm looking for, but it has unfortunately been deprecated and it looks like it's slated to be removed completely by next year, so it's not an option.
I'm hoping Google has a newer alternative. If not, is there some other method that's recommended? Thanks!
You can call the getImageURI method of the chart to generate an image/octet stream URI. You can send that data to your server, and you should be able to reconstruct the chart as a .png image file. I've never tried to do this server-side, so I'm not sure precisely how you would go about it, but this java tutorial might be of some assistance to you: http://www.programcreek.com/2009/02/java-convert-image-to-byte-array-convert-byte-array-to-image/
Years ago I wrote Eastwood Charts which implemented the Google Image Charts API as a servlet, backed by JFreeChart, so that you could generate charts without having to rely upon Google, or send your data to their servers. :-)
I don't maintain Eastwood Charts anymore (like Google, I can't be relied upon either) but it is open source and the code works so you might find it helpful. You could also modify it to meet your own requirements, which is something that wasn't possible with the Google service.

Google Fusion Table Javascript UPDATE Query?

I have looked everywhere for a way to update a Google Fusion table using an UPDATE query from a javascript. All I need to do is update one column with an array that is generated from the code itself, after the fusion table information is read and processed. I do not need the user to update the table.
Is there a way to do this using Javascript alone? Or do I really need a combination of OAuth 2.0 and php? Is there a working example of this? All I find is extremely vague or fragmentary.
Thank you.
Yes you need OAuth 2.0 and some kind of server-side code (like PHP). If you don't need the user to update the table, I guess that you are using Fusion Tables as some kind of central database for your application.
For this purpose (i.e. without the user being involved), Google provides so called Service Accounts. If you use such a service account, you can simply give access to your table to this account and then you are able to update the table via server-side code. The PHP OAuth library from Google supports service accounts and is quite easy to use.
If you want to use as much JavaScript code as possible you could provide an interface to the PHP OAuth library to your JavaScript code (see my answer to a similar question for more details). Otherwise just defer the UPDATE statement to the PHP code and you're fine.

Categories

Resources