d3.js

Styles in component for D3.js do not show in angular 2

血红的双手。 提交于 2019-12-27 12:20:18
问题 I am using Angular 2 and D3.js. I want to show a red rectangle. It only works if I put styles in the style.css file. Check this plunkr When I put my styles in the component styles: [] , it does not work. Check this plunkr How to let it work when I use the component styles: [] ? Thanks UPDATE: @micronyks provides a solution, but it makes the styles in the component global, basically no difference with writing in style.css file. In this plunkr, it shows style in one component will override

Updating SVG Element Z-Index With D3

*爱你&永不变心* 提交于 2019-12-27 11:04:52
问题 What is an effective way to bring an SVG element to the top of the z-order, using the D3 library? My specific scenario is a pie chart which highlights (by adding a stroke to the path ) when the mouse is over a given piece. The code block for generating my chart is below: svg.selectAll("path") .data(d) .enter().append("path") .attr("d", arc) .attr("class", "arc") .attr("fill", function(d) { return color(d.name); }) .attr("stroke", "#fff") .attr("stroke-width", 0) .on("mouseover", function(d) {

Scaling d3 v4 map to fit SVG (or at all)

假如想象 提交于 2019-12-27 10:39:41
问题 I am trying to make this map of the us scale smaller. Either to my SVG, or even manually. This is my code in its simplest from: function initializeMapDifferent(){ var svg = d3.select("#map").append("svg") .attr("width", 1000) .attr("height", 500); d3.json("https://d3js.org/us-10m.v1.json", function (error, us){ svg.append("g") .attr("class", "states") .selectAll("path") .data(topojson.feature(us, us.objects.states).features) .enter().append("path") .attr("fill", "gray") .attr("d", d3.geoPath(

Prevent dimple from renaming columns on redraw

痞子三分冷 提交于 2019-12-25 18:44:18
问题 I renamed my column names as explained here: dimple.js How can I change the labels of a chart axis without changing the data? The problem is that the column names change back to default on redraw. I redraw on page resize with parameter noDataChange = true as shown in this example: http://dimplejs.org/advanced_examples_viewer.html?id=advanced_responsive_sizing Any ideas on how to prevent reverting column names to default? EDIT: So far I've tried to rename the axes again on each resize, but

Legend not getting appended into div but printing outside the div

情到浓时终转凉″ 提交于 2019-12-25 18:43:06
问题 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>Testing Donut Chart</title> <script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <style type="text/css"> #first { /* width: 500px; height: 300px;*/ height: 50%; width: 50%; border: 3px solid #73AD21; position: absolute; } #chart { position: absolute; height: 100%; width: 100%; }

Running TreeData example D3JS

萝らか妹 提交于 2019-12-25 18:39:51
问题 I am trying to test the example of the DataTree of D3Js and I just copied and pasted the code in: http://bl.ocks.org/d3noob/8329447 . I saved the TreeData.json in my C drive and changed the d3.json("treeData.json", function(error, treeData) to d3.json("C:\treeData.json", function(error, treeData) and I get the error of "Cannot read property '0' of undefined" by looking at the javascript console. But once I hard code the json file into the program it works fine. Can somebody help me with that?

D3: Accessing bound data after using .datum()

半世苍凉 提交于 2019-12-25 18:01:06
问题 I'm having trouble figuring out how to add a title element with bound data after using .datum() When .datum() is called 'd' contains all of the expected properties, but after calling .datum() subsequent attempts to access the properties fails... 'd' contains only the path: var oc = og.selectAll('.oc-circle') .data(function(d) { return [d]; }, get_key); oc.enter() .append('path') .attr({ 'class': 'occ oc-circle' }); oc.exit().remove(); oc .datum(function(d) { console.log(d); // d has all of

Javascript charts as input

ぃ、小莉子 提交于 2019-12-25 17:44:34
问题 I have a requirement as below. I need to input time series data (day data) using a graph. The data is usually like below but the profile can be changed depending upon the situation. Right now the data is being manually entered in textboxes which makes it very difficult. I am wondering whether there are solutions that let user draw on a chart and generate the data in the back. In other words, the user picks certain points and the profile is drawn. 回答1: see following working snippet, click on

Hide all but selected connected nodes in D3 (v4) force graph

∥☆過路亽.° 提交于 2019-12-25 16:59:07
问题 I have created a dynamically built force graph in D3. When I click on one of the links I want to only show that and all the connected links/nodes. This Plunkr is a simplified version of what I have: http://plnkr.co/edit/TiKKmvydqXNipe103juL?p=preview (EDIT: I have updated this and is now a complete solution). As you can see there are 3 separate 'groups' of connected nodes, in my real data set there are several hundred nodes and I want to be able to isolate an individual 'group' and only show

(D3) Data Driven Documents — Transition Repetition

谁都会走 提交于 2019-12-25 16:58:38
问题 I've looked for over 3 hours now trying to find a way to chain transitions indefinitely... My only solution is wrapping the code in a function, then repeatedly calling the function with setInterval or waiting for the transition 'end' event Example one liner: d3.selectAll('circle').data([1,2,3]).enter().append('circle').attr('cy':function(d){return d * 100},'cx':function(){Math.random() * window.innerWidth},'r':'10px') //sets initial locations for circles that are created to match data array