d3.js

Updating D3 force layouts - adding and removing nodes corrupt the page

主宰稳场 提交于 2020-01-16 11:56:29
问题 First of all apologies to all for effectively opening a duplicate question to my last one (D3: problems with node = vis.selectAll(".node")) but initially I thought I could do this would jsfiddle, however it never really worked. The two problems are the same, so it might be worth reading the other one before this one. The issue I have is in updating the force layout with new nodes. In reality, I have an ajax call every few seconds to get updated data and I have reams of code to parse it and

Map elements in dataset to div id

[亡魂溺海] 提交于 2020-01-16 09:19:56
问题 I would like to make a webpage that looks something like the following: More specifically, I would like my webpage to be generated based on a dataset that has four columns, titled as follows: Manuals (there are four unique elements in this category, and they determine the colour of the dots) Name (this category determines the words that appear on mouseover) CategoryLevel1 (this category positions together rows that have the same CategoryLevel1) CategoryLevel2 (this positions together

d3.parseDate Error cannot read property 'forEach' of undefined

依然范特西╮ 提交于 2020-01-16 05:35:32
问题 I hope y'all can help me. I am stuck trying to make a bar chart with a time series using D3 and a JSON file. My JSON file is structured like so: { "ProjectCode": "PRJ2.1", "numberOfSchools": 1188, "newSchools": 0, "date": 2011-12 }, The y axis is supposed to show the numberOfSchools whilst the x axis is supposed to show the years passed. I used a combination of a time scale and ordinal scale for the x axis and parsed the date as so: data.forEach(function(d) { d.date = parseDate(d.date

d3 make Y axis position fixed even the scroller x

心已入冬 提交于 2020-01-16 05:25:52
问题 I have a chart with alot of data that means I have a scroller over the x axis. when I scroll over the X axis Y axis disappear. can i set to Y axis position fixed. ( always see this Y axis)? https://jsfiddle.net/ou28se1z/1/ I tried to add .attr("position", "fixed") but it doesnt work //Add Y axis svg.append("g") .attr("class", "axis") .attr("transform", "translate(" + padding + ",0)") .attr("position", "fixed") .call(yAxis); I also tried to do .style("position", "fixed") svg.append("g") .attr(

TypeError: this.setAttribute is not a function

。_饼干妹妹 提交于 2020-01-16 04:16:39
问题 I'm new to d3 and reactjs. I was trying to make a bar chart with following Rect.js componenet I've tried to debug right before // enter-update but with no avail. import React, { Component } from 'react' import * as d3 from 'd3'; const dataset = [14, 68, 24500, 430, 19, 1000, 5555]; const width = 600; const height = 400; export default class Rect extends Component { constructor(props) { super(props); } componentWillMount() { } componentDidMount() { this.renderRect(); } componentDidUpdate() {

Bullet chart ticks & labels in D3.js

社会主义新天地 提交于 2020-01-16 01:01:19
问题 I'm trying to blend the following two "official" D3 bullet chart examples into one: http://bl.ocks.org/mbostock/4061961 http://boothead.github.io/d3/ex/bullet.html I get the former to work locally, and I did manage to "plug" the JS code of the latter in by replacing "d3.chart.bullet" with "d3.bullet" (and re-referencing the DOM objects and "randomize" event listeners). However, compatibility with the local, label-type ".ticks" call is broken that way. In an ideal world I'd like to have the

How to change color of donut chart created using d3.js?

旧城冷巷雨未停 提交于 2020-01-16 00:55:20
问题 I am very new to d3 charts. I have this code that creates donut charts. However, unable to change colors. could some one help ? <body> <div id="chart"></div> <script src="d3.v3.min.js"></script> <script> (function(d3) { 'use strict'; var dataset = [ { label: 'Abulia', count: 10 }, { label: 'Betelgeuse', count: 20 }, { label: 'Cantaloupe', count: 30 }, { label: 'Dijkstra', count: 40 } ]; var width = 360; var height = 360; var radius = Math.min(width, height) / 3.5; var donutWidth = 50; // NEW

d3 chord diagram that produces parallel ribbons

点点圈 提交于 2020-01-15 22:13:10
问题 I currently am working with a chord layout, I would like to have my chords parallel though (illustrated with red overlays). How do I accomplish this? I tried the different sorting options and none seem to yield the desired results. code: var width = 1000; var height = 600; var svg = d3.select("#chart") .append("svg") .attr("width", width) .attr("height", height) .append("g") .attr("transform", "translate(" + width/2 + "," + height/2 + ")"); var matrix5x5 = [ [0, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0

NVD3 chart partly missing grid lines

旧城冷巷雨未停 提交于 2020-01-15 19:18:50
问题 In my chart here, if you can notice, it is missing grid lines for the first 4 and last 4 dates. I tried doing: .ticks(data[0].length) but it didnt help. What am I missing? jsFiddle 回答1: Adding .showMaxMin(false) fixes the problem. chart.xAxis .showMaxMin(false) .axisLabel("My X-Axis") .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) }); Working example is here 来源: https://stackoverflow.com/questions/24523744/nvd3-chart-partly-missing-grid-lines

NVD3 chart partly missing grid lines

≯℡__Kan透↙ 提交于 2020-01-15 19:18:43
问题 In my chart here, if you can notice, it is missing grid lines for the first 4 and last 4 dates. I tried doing: .ticks(data[0].length) but it didnt help. What am I missing? jsFiddle 回答1: Adding .showMaxMin(false) fixes the problem. chart.xAxis .showMaxMin(false) .axisLabel("My X-Axis") .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) }); Working example is here 来源: https://stackoverflow.com/questions/24523744/nvd3-chart-partly-missing-grid-lines