d3.js

Compilation errors when drawing a piechart using d3.js and TypeScript

非 Y 不嫁゛ 提交于 2020-04-08 09:50:09
问题 I am attempting to draw a pie chart using the d3.js library and TypeScript. I have the following code: "use strict"; module Chart { export class chart { private chart: d3.Selection<string>; private width: number; private height: number; private radius: number; private donutWidth: number; private dataset: { label: string, count: number }[]; private color: d3.scale.Ordinal<string, string>; constructor(container: any) { this.width = 360; this.height = 360; this.radius = Math.min(this.width, this

d3.select(“#element”) not working when code above the html element

喜欢而已 提交于 2020-04-05 07:52:10
问题 This works: <div id="chart"></div> <script>var svg = d3.select("#chart").append("svg:svg");</script> This doesn't: <script>var svg = d3.select("#chart").append("svg:svg");</script> <div id="chart"></div> I tried wrapping the code in a jquery document.ready(), grabbing the element with jquery, and passing it into d3.select, but that didn't work either. Edit Once I got the jquery document.ready() syntax right, it worked. Any way I can include the javascript at the top of the page and still

Add a Legend to D3 Force Directed Graph

六月ゝ 毕业季﹏ 提交于 2020-03-26 08:37:49
问题 So I am trying to create a legend in the bottom right corner of my D3. I have written all of the code for the legend but it comes up as just a black screen with the force-directed graph not showing up as well. Any advice would help. Legend Code: var color = d3.scale.ordinal() .domain(["<400", "400-549", "550-699", "700-849", "850-999", "1000-1149", "1150-1299", "1300-1449", ">1450"]) .range(["#1a9850", "#66bd63", "#a6d96a","#d9ef8b","#ffffbf","#fee08b","#fdae61","#f46d43","#d73027"]); var

Stop loading default css after ajax call

喜欢而已 提交于 2020-03-25 22:02:22
问题 I am new with ajax call, currently i am developing a custom style for my dashboard using a hosted web. so im just applying custom style ontop of it . i tried applying custom style on background, after ajax is loaded. it still working. once i applied it on my table td, it will revert back . f.afterDraw = function () { const evt = d3.selectAll("#" + arcapi.chartId() + " span.crosstab-expand") const chChange = d3.selectAll("#" + arcapi.chartId() + " td.viz-td-header").append('div').attr('class',

Stop loading default css after ajax call

做~自己de王妃 提交于 2020-03-25 22:01:50
问题 I am new with ajax call, currently i am developing a custom style for my dashboard using a hosted web. so im just applying custom style ontop of it . i tried applying custom style on background, after ajax is loaded. it still working. once i applied it on my table td, it will revert back . f.afterDraw = function () { const evt = d3.selectAll("#" + arcapi.chartId() + " span.crosstab-expand") const chChange = d3.selectAll("#" + arcapi.chartId() + " td.viz-td-header").append('div').attr('class',

Stop loading default css after ajax call

折月煮酒 提交于 2020-03-25 22:01:41
问题 I am new with ajax call, currently i am developing a custom style for my dashboard using a hosted web. so im just applying custom style ontop of it . i tried applying custom style on background, after ajax is loaded. it still working. once i applied it on my table td, it will revert back . f.afterDraw = function () { const evt = d3.selectAll("#" + arcapi.chartId() + " span.crosstab-expand") const chChange = d3.selectAll("#" + arcapi.chartId() + " td.viz-td-header").append('div').attr('class',

How can I draw an autoscaling D3.js graph that plots a mathematical function?

安稳与你 提交于 2020-03-24 08:35:12
问题 I have a working jsfiddle that I made using JSXGraph, a graphing toolkit for mathematical functions. I'd like to port it to D3.js for personal edification, but I'm having a hard time getting started. The jsfiddle graphs the value of -ke(-x/T) + k , where x is an independent variable and the values of k and t come from sliders. board.create('functiongraph', [ // y = -k * e(-x/t) + k function(x) { return -k.Value()*Math.exp(-x/t.Value()) + k.Value(); }, 0 ] ); The three things I'm most stumped

d3 Bar Chart append text to bar

家住魔仙堡 提交于 2020-03-23 07:35:27
问题 I've followed the tutorial to make a bar chart from Scott Murray from alignedleft. I'm having problem with my dataset and adding the dataset to a bar as text. The image below: 1 bar chart: from the tutorial , 2nd bar chart: how I want to display the text. Here's my code so far: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Tutorial d3 bar chart!</title> <script type="text/javascript" src="d3/d3.v3.js"></script> </head> <body> <script type="text/javascript"> //Width and

D3 mousewheel zoom direction

最后都变了- 提交于 2020-03-21 07:04:30
问题 I'm trying to create some custom zoom functionality in d3.js. Currently the zoom is triggered on a single click and zooms in to focus only on the area that was clicked on. Currently my code has a function zoom(d) that does exactly what it needs to. There is also a var zoomTransition which resides inside zoom() and is responsible for much of the functionality. I'm unfortunately unable to share much of my code. The zoom needs to also occur on a mouse scroll. The difficulty I'm having is that

programmatically trigger click event in svg rect element

非 Y 不嫁゛ 提交于 2020-03-17 16:52:20
问题 How to programmatically trigger click event in svg rectangle element element? like :$("#targetElm").triger("click"); <svg version="1.1" class="highcharts-root" style="font-family:MontserratRegular;font-size:12px;" xmlns="http://www.w3.org/2000/svg" width="441" height="319.5" viewBox="0 0 441 319.5"> <desc>Created with Highcharts 6.0.1</desc> <defs> <clipPath id="highcharts-74tub7h-41"> <rect x="0" y="0" width="255" height="275" fill="none"></rect></clipPath></defs> <rect fill="none" class=