nvd3.js

How to customize color in pie chart of NVD3

馋奶兔 提交于 2019-11-28 05:46:12
I am trying to use NVD3 http://nvd3.org/livecode/#codemirrorNav a pie chart. But i want to change the default color. How do i change the color. i am not able to do it. To use your own colours you will have to override the existing colours, I prefer not to tinker around with the original code. So this is what I did. var myColors = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"]; d3.scale.myColors = function() { return d3.scale.ordinal().range(myColors); }; nv.addGraph(function() { var chart = nv.models.pieChart() .x(function(d) {

NVD3 Scatter Chart Circle Radius

旧时模样 提交于 2019-11-28 01:36:54
问题 I was wondering how I can set minimum and maximum radii of the circles in an NVD3 scatter chart. NVD3 Scatter: http://nvd3.org/ghpages/scatter.html 回答1: Call .sizeRange([minArea, maxArea]) on your chart object. Note that "size" is proportional to area, not radius, so you need to use the square of the maximum/minimum radius (adjusted by pi/2 if you want to be precise). 回答2: As of 1.7.1, call .pointRange([minArea,maxArea]) . 回答3: nv.addGraph(function() { var chart = nv.models.scatterChart()

NVD3 Charts not rendering correctly in hidden tab

馋奶兔 提交于 2019-11-27 23:10:50
问题 I am building a page which contains many charts, which are displayed one at a time depending on which tab you are looking at. The chart in the initially active tab renders correctly. However when I click to another tab, the chart is not rendered properly. Presumably this is because the hidden field does not have dimensions until it is made visible. In fact if I resize the window the chart will correct it's proportions, and render so that it fills the available width. I can fix this problem by

How to add a title for a NVD3.js graph

帅比萌擦擦* 提交于 2019-11-27 22:33:54
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 text over the Chart as like the following image (Which is created in Paint) How can I achieve this? You

How do I display dates on the x-axis for nvd3 / d3.js?

我的未来我决定 提交于 2019-11-27 20:03:40
问题 I'm using nvd3, but I think this is a general d3.js question about time scale and formatting. I've created a simple example that illustrates the problem (see code below): If I omit .tickFormat for the xAxis, it works fine without date formatting. With the example below I get the error: Uncaught TypeError: Object 1326000000000 has no method 'getMonth' nv.addGraph(function() { var chart = nv.models.lineChart(); chart.xAxis .axisLabel('Date') .rotateLabels(-45) .tickFormat(d3.time.format('%b %d'

d3.js & nvd3.js — How to set y-axis range

给你一囗甜甜゛ 提交于 2019-11-27 19:35:06
I'm trying to set the y-axis range of the chart from 1-100. Consulted the API documentation and found a possible solution with axis.tickValues as seen here https://github.com/mbostock/d3/wiki/SVG-Axes#wiki-tickValues However, using the option does not work. Reading further down on the documentation page linked above under axis.tickSize, the following line was spotted The end ticks are determined by the associated scale's domain extent, and are part of the generated path domain rather than a tick line So I take it setting the min and max of the range can't be done through the Axis option. Any

NVD3, Clear svg before loading new chart

半腔热情 提交于 2019-11-27 17:05:01
问题 I have several different NVD3 charts that I call upon in the same svg. I use buttons to call functions, each containing a new chart that uses its own data. Is there a way to clear my single svg without deleting it? I wish to press a button to call my chart, but clear the svg before the new chart is loaded. It's not an issue when using the kind of chart... calling two multibarhorizontal charts, for example, just updates the shapes, which is fine. The problem is loading two different charts,

Understanding nvd3 x-axis date format

我们两清 提交于 2019-11-27 16:17:34
问题 how is the date (x xAxis) formatted as "1025409600000"? I have been studying their documentation but can not figure how this works, it would make my life easier if someone would help me to understand how to change this to a 'normal' date format, like MMDDYYYY This is the chart: http://nvd3.org/ghpages/stackedArea.html Documentation: https://github.com/mbostock/d3/wiki/Time-Formatting Thanks 回答1: I've interpreted your question as how does 1025409600000 get formatted to MMDDYY as that's what's

formatting the date in nvd3.js

余生颓废 提交于 2019-11-27 14:51:54
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? 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 "%m/%d/%Y"(08/06/13) return d3.time.format('%x')(new Date(d)) }); Or you may want to return the date stamp

How to add a click event on nvd3.js graph

前提是你 提交于 2019-11-27 13:34:13
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 ? 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.label }) .y(function(d) { return d.value }) .margin({top: 5, right: 5, bottom: 5, left: 5}) .showValues