d3.js

how to roll up dc stacked-bar example into single bar?

寵の児 提交于 2020-02-25 07:14:18
问题 "http://dc-js.github.io/dc.js/examples/stacked-bar.html" I want to roll this kind of dataset into a single bar stacked-bar chart. I changed the speedSumGroup = runDimension.group().reduce(function(p, v) { p[v.Expt] = (p[v.Expt] || 0) + v.Speed; return p; }, function(p, v) { p[v.Expt] = (p[v.Expt] || 0) - v.Speed; return p; }, function() { return {}; }); to speedSumGroup2 = runDimension.groupAll().reduce(function(p, v) { and inspecting the group shows the data rolled up to the single expected.

D3 drag event behaviour: DragEvent.x and DragEvent.y values source

你。 提交于 2020-02-24 12:01:35
问题 I don't understand the behaviour of the D3 DragEvent object in Mike Bostock’s examples for D3. Those are the two examples I don't understand: Circle Dragging I Drag + Zoom This is the code that I don't understand: function dragged(d) { d3.select(this).attr("cx", d.x = d3.event.x).attr("cy", d.y = d3.event.y); } In this example, d.x and d.y are part of a data object that contains the last centre of the circle. What I expect to happen with this code, is that the attributes cx and cy of the

NVD3.js multichart with fixed x- and y-axis

一世执手 提交于 2020-02-24 09:07:33
问题 I´m using a NVD3.js multichart to display various data. Is it possible set a fixed range for the x- and y-axis. I´ve made a Plunker example: http://plnkr.co/edit/OLN87eIE21tImHktYIH6?p=preview var chart = nv.models.multiChart() .margin({top: 30, right: 60, bottom: 50, left: 70}) .color(d3.scale.category10().range()); chart.xAxis.tickFormat(function(d) { return d3.time.format('%H:%m')(new Date(d)); }); chart.yAxis1.tickFormat(d3.format(',.1f')); chart.yAxis2.tickFormat(d3.format(',.1f')); d3

NVD3.js multichart with fixed x- and y-axis

痴心易碎 提交于 2020-02-24 09:04:02
问题 I´m using a NVD3.js multichart to display various data. Is it possible set a fixed range for the x- and y-axis. I´ve made a Plunker example: http://plnkr.co/edit/OLN87eIE21tImHktYIH6?p=preview var chart = nv.models.multiChart() .margin({top: 30, right: 60, bottom: 50, left: 70}) .color(d3.scale.category10().range()); chart.xAxis.tickFormat(function(d) { return d3.time.format('%H:%m')(new Date(d)); }); chart.yAxis1.tickFormat(d3.format(',.1f')); chart.yAxis2.tickFormat(d3.format(',.1f')); d3

D3JS: appending simple nested HTML in a single command

梦想的初衷 提交于 2020-02-24 06:36:53
问题 Consider this simple block of HTML: <div id="somediv"> <btn id="somebutton">Abc</btn> <div class="nested"> <span id="span1">Blah blah blah</span> <span id="span2">Bleh bleh bleh</span> </div> </div> I'd like to recreate it, dynamically, using D3JS. This works fine for this purpose: (function() { var somediv = d3.select( 'body' ).append( 'div' ).attr( 'id', 'somediv' ); somediv.append( 'btn' ) .attr( 'id', 'somebutton' ) .html( 'Abc' ); var nested = somediv.append( 'div' ) .attr( 'class',

Logarithmic scale returns NaN

穿精又带淫゛_ 提交于 2020-02-23 09:09:09
问题 I have issues creating a logarithmic scale in d3. The scale works fine if it is set to linear. This works: var myLinScale = d3.scale.linear() .domain([0, 100]) .range([50, 1150]); console.log(myLinScale(71)); //output = 831 However, this doesn't work: var myLogScale = d3.scale.log() .domain([0, 100]) .range([50, 1150]); console.log(myLogScale(71)); //output = NaN What is wrong with the logarithmic scale? 回答1: New solution (using D3 v5.8) After more than 2 years this question finally has a D3

d3js - error in rendering a legend key - duplicated render?

人盡茶涼 提交于 2020-02-23 06:48:29
问题 I am trying to complete a timeline application - - but I am getting a malfunction with the region key area latest fiddle https://jsfiddle.net/fqn4vb90/2/ when this gets rendered -- they all seem to be duplicates of the first array element? So in this example -- first element is JA, the second should be AS, and the third should be E let listRegions = [{ "label" : "A", "value" : "SIEA" },{ "label" : "E", "value" : "SIEE" },{ "label" : "JA", "value" : "SIEJA-JAPAN" },{ "label" : "AS", "value" :

How to create bar chart with path property in d3js?

巧了我就是萌 提交于 2020-02-23 04:28:07
问题 Below is how I creat a bar chart using rect s in D3. However, how would I modify that to get the bar chart with path property in d3js? I have a json file which has the data to be read and am trying to create a bar chart with paths rather than rectangles in d3js. Json : [ { "name": "sam", "age": 24 }, { "name": "baby", "age": 23 }, { "name": "adu", "age": 21 }, { "name": "ja", "age": 23 }, { "name": "mack", "age": 34 } ] Code: <script> d3.json("mydata.json", function (data) { var canvas = d3

Size of rectangle in d3js based on sum of values but not count of items

拥有回忆 提交于 2020-02-22 05:29:28
问题 I am working on a d3js visualization where I want to show groups and subgroups based on size.I have most of it working except for the size of the rectangles. If you see on load viz all four box size are of same size because all of them have same no. of grant programs. I want to change the size of these rectangles based on grant_award. Here is the code I have published at : https://gist.github.com/senthilthyagarajan/bfa1b611c0e91b1a304c0b8f32555daf Thank you 回答1: UPDATED:index.js .value() to

How to plot a directed Graph in R with networkD3?

点点圈 提交于 2020-02-21 05:14:09
问题 when I am ploting a directed graph with NetworkD3 , The edges are not directed , how can I fix it ? an Example : library(networkD3) data(MisLinks) data(MisNodes) forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8) I want the result to be directed This is the definetion of directed Graph: "A directed graph is graph, i.e., a set of objects (called vertices or nodes) that are connected together,