D3.js and my sql : import and visualise data - javascript

i m working on a project to visualise a network on a php page using D3.js or cytoscape.js
but i don t know how to import data from mysql .
any ideas ? or should i look for an other library ?

It doesn't matter what library you're using. You need to have an HTTP server running that accesses the DB.
If you use Cytoscape, you can just fetch() the results, e.g. cytoscape({ elements: fetch('http://myserver/get-eles') })

Related

Export neo4j graph for a d3 visualisation

I am currently develloping a webservice to visualize neo4j graph on a html webpage. I use bolt driver to establish the connection with my database using javascript.
However even if I succeed to install "Apoc" plugin to export data to JSON format it's not d3 ready, furthemore I am not able to parse the data to a d3 format...
If anyone has any idea how I could retrieve a "nicer" format. like
[nodes{},
links{}]

Parse .md file with php or javascript

Is there a way to parse an .md file with php or javascript for code snippets.
My scenario is the following:
I have been migrating an old system (php4) to a Laravel Framework(php7) which needed Schema updates. All of this updates I made it manually( I know I could used migrations but the table structure is quite extensive and I want to persevere the old datas in my new system) and I made a history of changes over mysql updates in a Changelog.md.
Now I try to make an automised migration on schema check if matches some negative rules on table columns with a middleware. For example if Table X does not contain columns Y,Z .. than my system is obsoleted and needs an update of schema and I redirect to dedicated Controller.
no I want to read the changelog with changes let it run this mysql updates.
You can do it using http://parsedown.org/
$Parsedown = new Parsedown();
echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello<em>Parsedown</em>!</p>
You can install it for Laravel easily : https://github.com/parsedown/laravel

413 Request Entity Too Large HighCharts

I am having trouble with the exportation of a certain graph. I have made a JSFiddle (http://jsfiddle.net/oy73rgc4/3/) to show with what I am working. This example doesn't contain all the data points with are used, because then my browser (Chrome) crashes. In total i am using about 80K of data points. The HighCharts is displayed like normal and doesn't cause any problems. The problem comes when I want to export the chart!
When I export the chart, doesn't matter if it's PNG/JPG/PDF it always directs to https://export.highcharts.com/ with the message 413 Request Entity Too Large. I have tried some google'ing
offline-export.js
Other people who have experienced this problem had tried to use the JS offline-export. I tried this, but it didn't have any effect.. It just removed the export button in the chart. https://github.com/highcharts/highcharts/issues/4614
Data grouping
Some suggested to others to use HighCharts Data grouping. I checked the API but I find that there is too little explanation about this. I think that I can't implement this from scratch and I am unable to find an example http://api.highcharts.com/highstock/plotOptions.series.dataGrouping
custom exporting server with increased size limit in nginx.conf
I also found that this option could help. I tried to find instructions, but I don't understand how I need to implement this in my web application (Laravel 5.2) http://www.highcharts.com/docs/export-module/setting-up-the-server
Does someone have a new suggestion for me on how I could solve this problem? Or could someone help me out with one of the options which I have suggested?
The exporting server is something that you deploy on your server side (i.e. you have to deploy a server to do exporting for you). However, if you only need to export PNG and SVG, then you can do with client-side only solution as per their docs.
http://www.highcharts.com/docs/export-module/client-side-export
If their server seems to have a limit on how big requests it will serve. Means that you have to deploy your own server and configure it (its has to do with actual http server configuration I think) to accept larger requests. Not much you can do on the client, but to limit the amount of data you display on the chart.
P.S. it always directs you to highcharts export server because export functionality by default users their server.

Query MongoDb with Java and pass it to d3/javascript?

I want to create a chart where I can select a time period and query mongodb accordingly. I want to use Java to query MongoDb. I know how to connect MongoDb and Java but I'm not so clear about linking the java to my webpage(i.e. To pass the data from that java file to my webpage/javascript).
I know Ajax calls can be used to link to servlets, but I'm sort of lost. Please help.
You use the Java MongoDB driver to connect to and query MongoDB from within your Java application. https://docs.mongodb.org/getting-started/java/client/
You would make that data available to the browser (D3/JavaScript) the same way you would make any server-side data available to the browser. You could either add that data to the page as you are rendering the actual webpage, or you could return the data in response to an AJAX request.

How can I access this Flask global from AngularJS?

I am building a internal web app with Flask that connects to various clusters. 95% of the URLs start with /cluster/cluster_name so I use the following code in my blueprints:
cluster = Blueprint('cluster', __name__, url_prefix='/cluster/<cluster_name>')
#cluster.url_defaults
def add_cluster_name(endpoint, values):
values.setdefault('cluster_name', g.cluster_name)
#cluster.url_value_preprocessor
def pull_cluster_name(endpoint, values):
g.cluster_name = values.pop('cluster_name')
Which then allows me to use the following code to create a connection to the cluster before each request:
#app.before_request
def before_request():
if not hasattr(g, 'manager'):
g.manager = ClusterInterface(g.cluster_name)
This works perfectly and allows me to use {{ g.cluster_name }} in jinja2 templates.
The problem is that I am moving to an AngularJS app for the frontend so I won't be using jinja2 templates/render_template() anymore.
So how can I have this global available to AngularJS templates without returning its value from every Flask views?
Thank you.
Your views will now send JSON data instead of rendered HTML templates in order to communicate with Angular. So make this data available in the JSON response.
return jsonify(cluster_name=g.cluster_name)
More likely, you should just send the default and available names when you first start the Angular app, and let it handle the value on it's end.
Sending g.manager is impossible, since it's a Python object with (probably) complex behavior, not something that is JSON serializable.

Categories

Resources