score:9
For each of your data series that you want disabled, just do:
series.disabled=true
nvd3 does not do everything, but if you are willing to peruse the code it is actually quite flexible. I discovered this by finding this line in the source of several of the chart models:
state.disabled = data.map(function(d) { return !!d.disabled });
score:1
You could start out with a hidden chart and try something like this:
// Array of series you want to hide
var hidden = [0, 2];
// Dispatch click event to each element
var e = document.createEvent('UIEvents');
e.initUIEvent('click', true, true);
d3.select('.nv-legend')
.selectAll('.nv-series')
.filter(function(d, i){return hidden.indexOf(i) !== -1;})
.node()
.dispatchEvent(e);
Once this finishes, unhide your chart and the series will be disabled.
score:14
You can change which streams are enabled/disabled by using the chart.state()
object. For example:
// Assuming your chart is called 'chart'
var state = chart.state();
for(var i=0; i < state.disabled.length; i++) {
state.disabled[i] = ...LOGIC RETURNING TRUE OR FALSE...;
}
chart.dispatch.changeState(state);
chart.update();
score:24
After reading this answer I still had to do some more reading in order for me to understand how to set a stream disabled from my JSON data-stream for the graphs.
The example below is what solved it for me disabled: true
{
key: "something",
disabled: true,
values: [...]
}
Source: stackoverflow.com
Related Query
- How to disable some streams by default in a nvd3 Simple Line Chart?
- How to change the viewfinder (focus chart) of a NVD3 line chart programmatically?
- How to disable C3 chart's select points on line chart
- NVD3 Cumulative Line Chart : How to save Line Chart as image
- NVD3 Cumulative Line Chart : How to set different back ground color for specific X axis
- NVD3 line chart - how can I add on-graph series labels?
- nvd3 - how to disable tooltip in discrete bar chart
- How to expand a data scale on NVD3 line chart
- d3js - How to update an existing svg path in a simple d3 line chart with new data flowing through?
- How to customize color in pie chart of NVD3
- How to disable legend in nvd3 or limit it's size
- MultiBar chart with nvd3 / d3 only shows labels for every other tick on the x-axis. How can I get them all to show up?
- nvd3 line chart with string values on x-axis
- NVD3 - line chart NaN on safari using latest versions
- NVD3 line chart with realtime data
- javascript charting - nvd3 line chart with two Y-axis
- How can I keep tick marks from repeating when I have a small number of dates on an nvd3 chart
- NVD3 Line Chart Uncaught TypeError: Cannot read property 'x' of undefined
- NVD3 line chart with vertical line
- NVD3 Line Chart X Axis Ticks Are Missing
- How to draw logarithmic line charts with nvd3
- how to style style line chart points in c3js
- How to avoid overlapping tooltips of multi-series line chart d3.js
- D3 - adding grid to simple line chart
- Draw D3 Simple Line chart With an Array
- How do I get my area filled beneath my d3 line chart to be a gradient?
- How to display values in Stacked Multi-bar chart - nvd3 Graphs
- How to add a line on x-axis on a horizontal bar chart in d3
- How to plot animated line chart using d3 while the data table is required to be updated every 1 second?
- How do I always keep my d3 line chart rollover text always visible?
More Query from same tag
- D3.js grouped bar chart rendering x axis incorrectly
- Creating a heatmap of two different types for d3
- Dilate SVG element if overlapping another element
- Hide the transformation of the graph in the beginning
- d3 calendar view: how to put all into one svg instead of several svgs
- Drag and linking rectangles, d3+js
- Generate D3 graphics inside Databricks notebook with scala usign RDD data
- When creating an HTML table with D3, use certain data for a row class rather than cell
- How can i set default color on element after mouse out D3
- D3 fill color using custom scale
- Zoomable Sunburst with % Share labeled
- Tensorflow - possibility of implementing custom d3.js plots into TensorBoard
- D3 draggable group with foreignObject HTML Input text caused it to be not edittable
- Javascript Question Mark & Double Pipes
- D3 selection no longer updates after supplying new data
- Does vega only support to create chart, not diagram?
- D3 can not get this.parentNode
- d3 bring elements to front by class from selector
- How to link multiple graph networks in d3js so that an event in one calls the same event in other networks
- d3 sorting of an array of objects
- Zoom softly into the center of a D3 map
- Show only every second grid line
- ReferenceError : barChartHelper is not defined?
- How to stringify circular JSON object and save it to file?
- Insert D3 Graph into a div in CMS
- using flexigrid for touch screens
- D3 - get x position on mouseover
- Is there a trivial way to get non-strict JavaScript codebase to behave in a 'strict' environment?
- d3 - sine wave with circles, the problem is that circles are overlapped in curves
- D3 change SVG dimensions on resize window