d3 js – loading json without a http get

Simply replace d3.json call with json = JSON.parse( myjson ); IE: var myjson = ‘{“name”: “flare”,”children”: [{“name”: “analytics”,”children”: [{“name”: “cluster”,”children”: [{“name”: “MergeEdge”, “size”: 10 }]}]}]}’; // d3.json(“/path/flare.json”, function(json) { #delete this line json = JSON.parse( myjson ); //add this line //rendering logic here //} #delete this line UPDATE 09/2013 Original code has changed. So varname … Read more

How do I include newlines in labels in D3 charts?

I ended up using the following code to break each x-axis label across lines: var insertLinebreaks = function (d) { var el = d3.select(this); var words = d.split(‘ ‘); el.text(”); for (var i = 0; i < words.length; i++) { var tspan = el.append(‘tspan’).text(words[i]); if (i > 0) tspan.attr(‘x’, 0).attr(‘dy’, ’15’); } }; svg.selectAll(‘g.x.axis g … Read more

How to invoke “click” event programmatically in d3?

not sure why, but there appears to be a discrepancy with the way jQuery and d3 handle events that causes a jQuery induced click event $(“#some-d3-element”).click() to not dispatch to the d3 element. a workaround: jQuery.fn.d3Click = function () { this.each(function (i, e) { var evt = new MouseEvent(“click”); e.dispatchEvent(evt); }); }; and then call … Read more

producing a “live” graph with D3

This tutorial can help you a lot to create a real time line graph: http://bost.ocks.org/mike/path/ I would like to add a few more comments: Asynchronous data When you do a real time graph, you often get the data asynchroneously, thus you cannot know the exact time between each “point”. For the line, you are lucky … Read more

How can I bring a circle to the front with d3?

TL;DR With latest versions of D3, you can use selection.raise() as explained by tmpearce in its answer. Please scroll down and upvote! Original answer You will have to change the order of object and make the circle you mouseover being the last element added. As you can see here: https://gist.github.com/3922684 and as suggested by nautat, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)