d3.js

How to set all descendant nodes and links to same colour as level 2 ancestor?

孤人 提交于 2021-02-10 05:39:13
问题 I have a d3.js tree with descendant nodes receiving their level 2 ancestor's node colour. This is working from level 2 to level 3, but stops working at level 4 and on. Relevant code: var colourScale = d3.scale.ordinal() .domain(["MD","Professional", "Leader", "Advocate", "Clinician", "Educator", "Scholar"]) .range(["#6695c8", "#cd3838","#d48440", "#a8ba5f", "#63b7c0", "#c97eb2", "#ccc136"]); and nodeUpdate.select("circle") .attr("r", 10) .attr("fill-opacity","0.7") .attr("stroke-opacity","1")

How to set all descendant nodes and links to same colour as level 2 ancestor?

蹲街弑〆低调 提交于 2021-02-10 05:39:12
问题 I have a d3.js tree with descendant nodes receiving their level 2 ancestor's node colour. This is working from level 2 to level 3, but stops working at level 4 and on. Relevant code: var colourScale = d3.scale.ordinal() .domain(["MD","Professional", "Leader", "Advocate", "Clinician", "Educator", "Scholar"]) .range(["#6695c8", "#cd3838","#d48440", "#a8ba5f", "#63b7c0", "#c97eb2", "#ccc136"]); and nodeUpdate.select("circle") .attr("r", 10) .attr("fill-opacity","0.7") .attr("stroke-opacity","1")

d3.mouse is not a function

你。 提交于 2021-02-09 09:20:02
问题 Upgraded d3 library and now getting an error for executing the following code console.log(`\n${JSON.stringify(d3.mouse)}\n`); const mouse = d3.mouse(this); Getting undefined d3.mouse is not a function And it is not defined anywhere. I went trough d3 exports and this function is not really exported from anywhere. 回答1: d3.mouse was removed in d3v6, you should use d3.pointer(event) 来源: https://stackoverflow.com/questions/65134858/d3-mouse-is-not-a-function

d3.mouse is not a function

我怕爱的太早我们不能终老 提交于 2021-02-09 09:18:40
问题 Upgraded d3 library and now getting an error for executing the following code console.log(`\n${JSON.stringify(d3.mouse)}\n`); const mouse = d3.mouse(this); Getting undefined d3.mouse is not a function And it is not defined anywhere. I went trough d3 exports and this function is not really exported from anywhere. 回答1: d3.mouse was removed in d3v6, you should use d3.pointer(event) 来源: https://stackoverflow.com/questions/65134858/d3-mouse-is-not-a-function

D3 How to place image next to horizontal line text

可紊 提交于 2021-02-08 15:05:51
问题 I've created this D3 chart which displays the results sentiment value. However what I'm struggling to do is place an image next to the horizontal text. Using the JSFiddle as an example, lets say 'Result 2' is under 20%. There would be a sad face displayed to the right of the 'Result 2' text. Then if the value was higher than 20%... a happy face would be displayed instead. Is it possible to do this? JSFiddle: https://jsfiddle.net/sopjzwst/3/ I've created the 2 different faces below the chart

D3 How to place image next to horizontal line text

99封情书 提交于 2021-02-08 15:03:14
问题 I've created this D3 chart which displays the results sentiment value. However what I'm struggling to do is place an image next to the horizontal text. Using the JSFiddle as an example, lets say 'Result 2' is under 20%. There would be a sad face displayed to the right of the 'Result 2' text. Then if the value was higher than 20%... a happy face would be displayed instead. Is it possible to do this? JSFiddle: https://jsfiddle.net/sopjzwst/3/ I've created the 2 different faces below the chart

D3: ordinal scale not working with array of objects

人走茶凉 提交于 2021-02-08 11:42:25
问题 still struggeling with d3. I tried build an ordinal scale where the domain is an array of objects. Somehow rangeBands is not working with this type of array. It works with a string or number array. Can anybody explain why? var number_data = [1,2,3,4,5]; var string_data = ["1","2","3","4","5"] var object_data = [{"test":"1" },{"test":"2"},{"test":"3"},{"test":"4"},{"test":"5"}] console.log("+++ Array of Numbers +++") var scale= d3.scale.ordinal() .domain(number_data) .rangeBands([0,100]);

Changing slider color

限于喜欢 提交于 2021-02-08 10:30:05
问题 I want to be able to create multiple sliders of different colors. One of the suggestions I found online was to create multiple classes in my CSS file for each color and to call on the needed class when defining the slider. It is not clear how to override CSS in Javascript and how to change my html file accordingly. Please find code attached below: <body> <div id="testslider"></div> <script> var slider = d3.slider().min(0).max(1).value(1).ticks(1).showRange(true); d3.select('#testslider').call

How to make d3 gauge chart responsive?

独自空忆成欢 提交于 2021-02-08 10:19:28
问题 Can anyone help me to resize the d3 gauge chart? Here is the Stackblitz code. I've tried, .attr("preserveAspectRatio", "xMinYMin meet") and window.addEventListener("resize", this.draw); 回答1: Please modify your render() and add svg = d3.select(container) .append('svg') .attr('class', 'gauge') .attr('width', '100%') .attr('height', '100%') .attr('viewBox', '0' + ' ' + '0'+ ' ' + config.clipWidth + ' ' + config.clipHeight) .attr('preserveAspectRatio', 'xMinYMin') 来源: https://stackoverflow.com

D3 word cloud layout circle and rectangular

穿精又带淫゛_ 提交于 2021-02-08 09:01:51
问题 I'm a D3 newbie and trying to build word cloud page using JasonDavies d3-cloud. But sometimes all words are showing in circle layout, but sometimes in rectangular. How can I make them always locate in circle layout? 回答1: d3-cloud 's layout algorithm places words within an ellipse starting from the center of the rectangle you've provided ( d3.layout.cloud().size([width, height]) ). If you have a container ( size([width, height]) ) big enough compared to your number of words and the size you've