How can I create a bar graph dynamically using data in JS - javascript

Can someone please suggest how I can create a bar graph, dynamically in Javascript. Below is the design that I am trying to achieve. I did come across Google Charts, but couldn't figure out ways to acheive the below deisgn style.

D3.js is a long-standing and very popular solution for all kinds of dynamic charts and graphs.
Check out the gallery and search for the word bar to find examples that might fit your use case.
You might also just google "d3js" and words relevant to your problem. In your case, this is really a type of "gauge", and when I search "d3js" and "gauge", a few examples come up that may be closer to your data type, though maybe not exactly in that style.
D3.js is very configurable though. If you don't find something out-of-the-box, you should have the tools to make it work.

Related

Is it possible to create d3 nodes with multiple edge ports?

I'd like to achieve something similar to this diagram using d3:
https://gojs.net/latest/samples/records.html
I was trying to look it up on the web but I hardly found any resources to get started with.
I'm quite new to d3 so I don't know how to approach this task, any help or guidance would be appreciated!
This is another one of those questions where people need to implement a sophisticated diagram visualization and they think just because D3 is a lot about visualization, it will be a good fit.
IMHO it is not.
D3 could be a part of the solution, but it certainly cannot be the solution alone: It's almost like asking whether JavaScript can be used to create this kind of diagram. Of course it can! D3 is just a very thin (but very useful) layer on top of the DOM+JavaScript, that can help you with crunching numbers, work with colors, coordinate systems, create DOM elements, and simplifies working with the DOM. Think of it as jquery for DOM and data plus a lot of very nice demos. But the value very often is in the demos, rather than in D3 itself: You need to implement a lot of things to get from a simple mapping from data to dom elements to a sophisticated diagram visualization like the one you are referring to.
If you don't want to implement and maintain most of the low-level diagram logic yourself, you should rather be looking at a diagramming solution, rather than a tool that will help you create SVG elements elegantly with less code.
Look at this question to see a list of graph and diagram visualization software. Agreed, D3 is also on this list (for the same reason you are asking this question), but there are also far more capable tools on that list that you should be looking at, my recommendation being either the one that you've found already or preferrably this one if your requirements are more sophisticated.

Pareto Chart/Graph using Javascript/Html/JSON

Im trying to find any plugins, examples or related resources on how to built a Pareto Chart for an html page. I'd like to be able to built it out of html, style it w/ CSS and populate data via json. Im willing to build it out of scratch by using a combination of a line graph and bar graph, however want to be sure there isnt anything already out there for this.
Here is an example of the output i hope to produce
Based on my searches i can only seem to find How-To's, Examples, etc on how to build one in Excel, however nothing for the web.
Any ideas or suggestions are greatly appreciated.
Pareto charts come standard in quite a few JS charting libraries. Here's a demo of one in ZingChart.
You can view the docs for creating pareto charts here. I'm part of the ZingChart team, and you're welcome to reach out to us if you have any questions at support#zingchart.com.
I am not sure from your description whether you would like to build from scratch or if you want to use a charts package. Normally, I would avoid re-inventing the wheel, but I sometimes do a challenge to learn. Below are a few links to pre-made packages of javascript charts that can do pareto, found with a google search (javascript pareto chart -excel -matlab).
http://cyberpython.github.io/AwesomeChartJS/ is apache 2.0
one of the better paid-for versions is http://www.dundas.com/ but there are others.
Sorry that this is a list of links. I would like to be able to rattle off the method from my memory, but I do not do HTML charts as much as I would like to.
It seems some of the options aren't free and/or open source :(
For building from scratch, or at least basing on common libraries, d3 might be a good choice. I ran into a similar issue looking to generate histograms with a cumulative frequency line included in the chart, and to build my own based on some examples. I then investigated further for options for pareto charts and sorted histograms.
If you want to try it with d3, here's some examples to start from (they're not as pretty rendered like the other answers, but a charting/UI web developer can prettify it I'm sure):
a basic d3 pareto chart based off Excel example
a histogram-based pareto chart in d3 - at the time of this post, this d3 sample is incomplete

Javascript Library to dynamically create graphs?

Here is my requirement:
I need to create a visualization of links between different representations of a person. The image below I think indicates that fairly clearly.
Additionally, those rectangles would also contain some data about that representation of a person (such as demographics and the place). I also need to be able to handle events when clicking on the boxes or the links between them, as a sort of management tool (so, for example, double clicking a link to delete it, or something along those lines). Just as importantly, since the number of people and links will varies, I need it to be displayed by spacing out the people in a roughly equidistant fashion like the image shows.
What would be a javascript library that could accomplish this? I have done some research and have yet not found something that can cleanly do this but I'm hardly an expert in those libraries.
Here are the ones I've looked at:
Arbor js: Can dynamically create the spacing and links of the graph but I'm responsible for rendering all the visuals and there's really no hooks for things like clicking the links.
jsPlumb: Easily create connections between elements and draws them nicely enough but doesn't seem to address any layout issues. Since I don't know how many people will be on the screen, I have to be able to space them out equidistant and that doesn't seem to be a concern of jsPlumb.
D3.js: This creates a good visualization with the spacing I need but I don't see how I can show the data inside each node or do things like like mouse events on the links or box.
I'm feeling a bit lost so I'm hoping someone could point me to something that could help me or maybe point me to an example from one of these libraries that shows me that what I want is possible.
I ended up using Arbor with Raphael as my rendering library and it's worked out very well.
Take a look at Dracula Graph Library. It's a simple library that seems to do both layout as well as rendering graphs (using Raphael under the hood). It's a bit underdeveloped however.

gRaphael Js: where can I find tutorials to produce data charts (pie, bar, etc)

Where can I find tutorials to produce data representations on the web with gRaphael? There seem to be no documentation on line.
Many Thanks
I really would recommend against graphael just from personal experience. I looked at it and got stuck several times during my implementation (ex, simple things like axis labels require hacks like setting text at specific spots), and the physical x-axis scaling/ticks that is visible (at least for bar charts that I've tried) don't seem related to the data, as if there is some internal axis that you can't see. I could not find a single graph example that actually had even the minimum # of components a professional graph has (labels, legends, etc), so for me it's just a prettier 'sparklines'. All in all, a lot more trouble than it's worth, plus any documentation you find will be minimal at best.
I would look into jquery options (great documentation and easy browser support for js)
highcharts is #1 if it's for personal
use, very beautiful, interactive,
and easy to use
flot, nice looking though not as
interactive or as many options
jqplot, inspired by flot. this is my
current choice. there's a huge
amount of stuff you can do with
this. interactive and professional
looking, looks like a good sub for highcharts if the licensing fee is too much.
Flash charts (beautiful but flash is a no-no these days):
Open flash charts - It's not too bad
to implement and I used it before I
decided to switch to jqplot. Very
nice looking charts, but my graphs
needed to grab data from the server
more dynamically, and I decided js
was a better option to do it.
Amcharts - easily make good looking
graphs via XML data.
There doesn't seem to be that many beginner tutorials, but here's a couple of reasonably introductory text with examples:
http://www.treutech.com/42/visualizing-data-jqplot-graphael,
http://articles.sitepoint.com/article/graphael-javascript-graphs,
http://blog.jeremi.info/entry/creating-a-chart-with-raphael-js-from-a-google-spreadsheet

Good Ajax Chart/Graphic Library

I know there has been several discussions on JavaScript chart/graphics libraries, and there is many out there. What I need is one that can:
Zooming and panning
Data point manipulation (like when click on a data point, highlight other data points within the data series with the same certain parameter of the clicked one)
Dynamically change data point values (e.g.: dragging a data point dynamically updating the line shape)
Error bar support, horizontally and vertically
Select data points on the chart
Seems like Flot may have most of the features, if not all(not sure about 3, and 4), but would like to see if I don't miss out on there nice libraries.
Check out the awesome Visualization API on Google's AJAX APIs Playground
Take a look at http://raphaeljs.com/ library.
It has a plugin called gRaphaƫl which is charting plugin.
Look good but personally didn't use it.
Good luck and share you expirience if you try it.
The Dojo Charting Engine has a pretty astonishing featureset. Sadly dojo seems to suffer from a general lack of evangelism.
I dont know if there are good introductory tuts, maybe the best way is to learn from examples.

Categories