nvd3.js

Is an NVD3 Line Plot with Markers Possible?

馋奶兔 提交于 2019-11-27 12:19:06
问题 I'm making an NVD3 line plot that will have significantly improved clarity if I can get markers to show for each data point instead of just the line itself. Unfortunately, I haven't been able to find an easy way to do this with NVD3 yet. I also considered using a scatter plot, but I couldn't figure out how to show connecting lines between the points. A third option I considered was to overlay a line and scatter plot, but this would show each series twice in the legend and may cause other

d3.js nvd3 date on x axis: only some dates are show

佐手、 提交于 2019-11-27 11:49:27
问题 I have a strange issue with showing dates on a xAxis. I am generating data like this: for (i=0;i<12;i++){ date=new Date(2013,i,1); ideas.values[i] = {"y" : Math.round(2*i*getRandom(1,2)), "x": date}; } In my lineChart I want to create the x-axis like this: chart.xAxis.tickSize(12) .tickFormat(function(d) { var date = new Date(d); testarr.push(date); return d3.time.format('%b %y')(date); }); Now if I look at the chart, there are only a few Dates visible. This is why I created the array

NVD3 Line Chart X Axis Ticks Are Missing

拜拜、爱过 提交于 2019-11-27 03:38:17
问题 I am using NVD3 to display line chart here: http://jsbin.com/xodaxafiti/2/edit?js,output But it seems like NVD3 auto-hide some tickLabels on XAxis, but only those ticks near the edge, i.e. 2-3Oct and 27-28Oct (except the first and last tick). I know that this is an auto-reduce because when I increase the width of chart, the ticks start to show up. However I find that this reducing behaviour weird, and the lineChart does not have reduceXTicks option like multiBarChart. I want to be able to

how to set height and width of nvd3 chart

做~自己de王妃 提交于 2019-11-27 03:06:39
问题 I'm trying to set the width and height of a nvd3 multi bar chart programmatically using chart.width(600); chart.height(400); See the example here: http://jsfiddle.net/hPgyq/20/ As you can see this really messes up the chart. I know I can do this is CSS with: #chart svg { width: 600px; height: 400px; } but I thought this was also possible using the width() and height() functions on the chart. Am I doing something wrong here or am I mis-using the two functions? 回答1: Yes it is possible, like you

How to add a title for a NVD3.js graph

谁都会走 提交于 2019-11-26 21:08:56
问题 I want to add a title text over the graph in NVD3.js. I tried the following, nv.addGraph(function() { var chart = nv.models.linePlusBarWithFocusChart() .margin({top: 30, right: 60, bottom: 50, left: 70}) .x(function(d,i) { return i }) .color(d3.scale.category10().range()); chart.append("text") .attr("x", 200) .attr("y", 100) .attr("text-anchor", "middle") .text("Sample Charts"); } Its (Highlighted) working for D3.js but not working for NVD3.js. I'm getting a Blank page.. I want to place the

nvd3 piechart.js - How to edit the tooltip?

强颜欢笑 提交于 2019-11-26 18:54:36
I'm using nvd3's piechart.js component to generate a piechart on my site. The provided .js file includes several var's, as follows: var margin = {top: 30, right: 20, bottom: 20, left: 20} , width = null , height = null , showLegend = true , color = nv.utils.defaultColor() , tooltips = true , tooltip = function(key, y, e, graph) { return '<h3>' + key + '</h3>' + '<p>' + y + '</p>' } , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') ; In my in-line js, I've been able to override some of those variables, like this (overriding showLegend and margin): var chart

How to add a click event on nvd3.js graph

ぐ巨炮叔叔 提交于 2019-11-26 18:18:08
问题 I am using nvd3.js and trying to add a click event d3.selectAll(".nv-bar").on('click', function () {console.log("test");}); JSFiddle How can I do that ? 回答1: I was running into the same issue and was about to dump NVD3 all together because of the lack of documentation... What you need to do is add a callback function to addGraph(). Also note the d3.selectAll() instead of d3.select(). Good Luck. nv.addGraph(function() { var chart = nv.models.multiBarHorizontalChart() .x(function(d) { return d

formatting the date in nvd3.js

匆匆过客 提交于 2019-11-26 16:56:10
问题 How can I make the date format in nvd3.js. For example: data1 = [{ "values": [{ "x": 1374561814000, "y": 2 }], "key": "x-axis" }] 1374561814000 what does it mean, how its converted from a date? 回答1: The date 1374561814000 is currently Unix Time Stamp. You can define how you want the date to be displayed in your when passed into your chart. Have a read on the d3 guide to Time formatting it will give you a better understanding. chart.xAxis.tickFormat(function(d) { // Will Return the date, as "

NVD3 - How to refresh the data function to product new data on click

 ̄綄美尐妖づ 提交于 2019-11-26 09:59:27
问题 I have a line chart and every time the page refresh it changes the data, which is great but I need to to refresh by a user click. This is because there will eventually be other input fields on the page and refreshing the page would destroy their current session. jsfiddle - http://jsfiddle.net/darcyvoutt/dXtv2/ Here is the code setup to create the line: function economyData() { // Rounds var numRounds = 10; // Stability of economy var stable = 0.2; var unstable = 0.6; var stability = unstable;

nvd3 piechart.js - How to edit the tooltip?

陌路散爱 提交于 2019-11-26 06:40:34
问题 I\'m using nvd3\'s piechart.js component to generate a piechart on my site. The provided .js file includes several var\'s, as follows: var margin = {top: 30, right: 20, bottom: 20, left: 20} , width = null , height = null , showLegend = true , color = nv.utils.defaultColor() , tooltips = true , tooltip = function(key, y, e, graph) { return \'<h3>\' + key + \'</h3>\' + \'<p>\' + y + \'</p>\' } , noData = \"No Data Available.\" , dispatch = d3.dispatch(\'tooltipShow\', \'tooltipHide\') ; In my