Skip to content
Advertisement

Tag: d3.js

Implement JS function with methods in scalajs

I’m trying to create a world map with topojson and d3-geo using scalajs based on the following example: How-to-create-pure-react-SVG-maps-with-topojson-and-d3-geo My biggest issue so far is what I don’t understand how I can implement geoEqualEarth() and geoPath() functions from d3-geo using scala since both of them have a number of methods, for example const projection = geoEqualEarth().scale(160).translate([ 800 / 2, 450

d3 Dendrogram: Replacing root retains old tree

I have a Dendrogram / cluster diagram’s root using d3.hierarchy. I’m trying to update the root with a selected node which should become the new head, with a new tree drawn with that node at the top. This should replace the old tree. The steps are as follows: read in flat data convert to hierarchy using d3.stratify convert this to

D3 Radial Dendrogram only displaying part

I have created the code below based on Mike Bostock’s example in Observable (which I know is not the same as raw d3/ javascript) https://observablehq.com/@d3/radial-dendrogram However, it: only displays if I remove the return svg.attr(“viewBox”, autoBox).node(); at the end of the chart function. I suspect that is causing the issues below is tightly cropped looks like the centre is at

Changing the attribute cx and cy when screen resize in D3.js with React

I have a problem with the dynamic change of cx and cy attributes depending on the size of window.innerHeight/window.innerWidth. I am sending to component window.innerHeight/window.innerWidth as hight/width and it look like this: this is bubble-chart-svg css class: When I add console.log(xScale(4)) in I get information about the new position cx (after resize) but circle element in svg does not change.

Fill D3 arrow with colors

I managed to plot an arrow with D3 that changes direction and size dynamically. Now, I would like to fill the encapsulated area with a color. However, I plot the arrow outline with a succession of lines, so I am not sure how to tell D3 that this area is closed and ready to fill? How shall I adjust my

d3.js Compressing links of a component

I am trying to select a set of nodes in a Force Directed Layout graph in d3, then to compress the component the nodes form. My idea was to make a force simulation, as shown below: Since it relies on distance, I thought finding and selecting the appropriate links in the graph’s data and shrinking it, such as would compress

Animating D3 Arcs, with an Arc for each bound data point

I’d like to be able to animate multiple (based on the data) arc charts from one percent (angle) to another in D3.js and can draw them fine initially. However, after much hunting around, I’m stuck with the animation. Below is the code that does the original drawing and then two options for animation to subsequent values. I’m using groups for

D3 update color based on data

I’m drawing and coloring lines based on data with D3. I now want to update the color of these lines based on different features in the same data set but my color-changing function (colorP2) does not work–I know this color change looks useless, but it will later be triggered by a button. Any ideas? Below is my code. [Update] There

Line chart not displaying from JSON Data

actually I am trying to make a chart line using D3.js. I made x axis and y axis but now the chart line is missing. here is my json data: filterData([ ` { “Sparte”: “Beherbergung”, “Jahr”: 2020, “Monat”: “Januar”, “Beschaeftigte”: “100,3”, “VeraederungenzumVorjahr”: “0,3” }, { “Sparte”: “Beherbergung”, “Jahr”: 2020, “Monat”: “Februar”, “Beschaeftigte”: “99,7”, “VeraederungenzumVorjahr”: “0,2” }, { “Sparte”: “Beherbergung”, “Jahr”:

Advertisement