d3.js

Can we add images in json data file and call it on page using D3.js

我怕爱的太早我们不能终老 提交于 2020-01-15 19:12:56
问题 Below is my code for displaying a world map on page. I'm trying to find the way to store image in json data file - and calling it in tooltip function for each country. The tooltip function is currently mapped to the json file and displaying the data I've entered. Thanks <!DOCTYPE html> <meta charset="utf-8"> <style> .country:hover { stroke: #B3B5B3; stroke-width: 3px; } span1 { font-size:18px; font-family:Arial, Helvetica, sans-serif; } span2 { font-size: 14px; font-family:Arial, Helvetica,

Can we add images in json data file and call it on page using D3.js

时光毁灭记忆、已成空白 提交于 2020-01-15 19:12:34
问题 Below is my code for displaying a world map on page. I'm trying to find the way to store image in json data file - and calling it in tooltip function for each country. The tooltip function is currently mapped to the json file and displaying the data I've entered. Thanks <!DOCTYPE html> <meta charset="utf-8"> <style> .country:hover { stroke: #B3B5B3; stroke-width: 3px; } span1 { font-size:18px; font-family:Arial, Helvetica, sans-serif; } span2 { font-size: 14px; font-family:Arial, Helvetica,

Formula to calculate the control point from three known points on a D3 “basis” curve

醉酒当歌 提交于 2020-01-15 12:30:24
问题 I have a curve generated by a D3.js line generating function with interpolate set as "basis". The problem is that the line generated only touches the first and last point given into the line generating function and does not pass through the ones in between. I am aware that these are treated as control points to generate the b-spline curve, but what I am looking for is a way to "project"/calculate the control points so that the curve does go through every point in my path array. These in

consolidate successive translations in D3

和自甴很熟 提交于 2020-01-15 12:26:14
问题 The following toy code (jsfiddle here) write to the console log translate(20,0) translate(20,0) translate(20,0) translate(20,0) translate(20,0) . Is it possible to get translate(100,0) as a "consolidated" translation? var svg = d3.select('svg'); var rec=svg.append("rect") .attr("width",20) .attr("height", 20) .attr("x", 0) .attr("y", 20) .attr("fill","#00ffff") .attr("transform","") ; for (var i=0;i<10;i++) { rec .attr("transform",rec.attr("transform")+" translate(20,0)") ; } console.log(rec

consolidate successive translations in D3

丶灬走出姿态 提交于 2020-01-15 12:26:07
问题 The following toy code (jsfiddle here) write to the console log translate(20,0) translate(20,0) translate(20,0) translate(20,0) translate(20,0) . Is it possible to get translate(100,0) as a "consolidated" translation? var svg = d3.select('svg'); var rec=svg.append("rect") .attr("width",20) .attr("height", 20) .attr("x", 0) .attr("y", 20) .attr("fill","#00ffff") .attr("transform","") ; for (var i=0;i<10;i++) { rec .attr("transform",rec.attr("transform")+" translate(20,0)") ; } console.log(rec

Accessing touch properties on Windows Chrome #74

戏子无情 提交于 2020-01-15 11:45:06
问题 I was experiencing the issue raised here and here. My d3 app works perfectly on Chrome via a touch display on Mac, but d3.drag failed when I switched to the Windows production machine running Chrome v.74. I applied the solution .touchable(navigator.maxTouchPoints) , as suggested by the linked pages above. This allowed me to drag the element in Windows Chrome v.74 using the touch screen, but am now getting: UncaughtTypeError: Failed to execute 'elementFromPoint' on 'Document': The provided

How to create a bar chart in D3?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-15 11:16:47
问题 I need help creating a bar chart, just a normal bar chart. I have 5 objects, each with their own 10 fields. I want to create a side-by-side bar layout where the x axis labels are the 10 fields. Above the ith field should be a rectangle for each 5 object with each height corresponding to that objects data for that field. Each object has its own distinctive color. I've spend 4+ hours and I've got nothing. Google reveals nothing that helps. Note: the rectangles of the bar chart should be

How to create a bar chart in D3?

坚强是说给别人听的谎言 提交于 2020-01-15 11:15:33
问题 I need help creating a bar chart, just a normal bar chart. I have 5 objects, each with their own 10 fields. I want to create a side-by-side bar layout where the x axis labels are the 10 fields. Above the ith field should be a rectangle for each 5 object with each height corresponding to that objects data for that field. Each object has its own distinctive color. I've spend 4+ hours and I've got nothing. Google reveals nothing that helps. Note: the rectangles of the bar chart should be

giving axis ticks more space in nvd3

 ̄綄美尐妖づ 提交于 2020-01-15 10:45:27
问题 I am constructing a horizontal bar plot in nvd3 with domain names as x-labels. The domain names, while not too long, are longer than the amount of space given to them. How do I increase the amount of space given to an axis in nvd3 ? jsfiddle example here. 回答1: Apparently, you can specify your own margins. For example: var chart = nv.models.multiBarHorizontalChart() .margin({top: 30, right: 10, bottom: 30, left: 90}) // increase the left margin .x(function(d) { return d[0]; }) .y(function(d) {

giving axis ticks more space in nvd3

半腔热情 提交于 2020-01-15 10:45:08
问题 I am constructing a horizontal bar plot in nvd3 with domain names as x-labels. The domain names, while not too long, are longer than the amount of space given to them. How do I increase the amount of space given to an axis in nvd3 ? jsfiddle example here. 回答1: Apparently, you can specify your own margins. For example: var chart = nv.models.multiBarHorizontalChart() .margin({top: 30, right: 10, bottom: 30, left: 90}) // increase the left margin .x(function(d) { return d[0]; }) .y(function(d) {