score:8
You can "hack" this by having an empty array that contains an empty array:
data2 = [
{
"key" : "A key" ,
"values" : [[]]
}
];
score:5
The answer provided by Lars works well when you do not want to show the noData
message on a chart when its empty.
Recently I had charts with content being loaded dynamically. I found a similar question to this Updating with no data does not clear old data from the chart.
If a chart is populated with data and then update is called after the data has been emptied, the noData text will overlay the existing data.
Consider if the current data should be cleared from the chart as it can be confusing to see both at the same time.
I was not able to find a clean solution to that, So here's what I did to overcome it :
Used Lars answer to empty the chart :
data2 = [{
"key" : "A key",
"values" : [[]]
}];
And then added the code below.
d3.select('#chart svg').append("text")
.attr("x", "235")
.attr("y", "35")
.attr("dy", "-.7em")
.attr("class", "nvd3 nv-noData")
.style("text-anchor", "middle")
.text("My Custom No Data Message");
Even I am after a proper solution for it, to show the noData text without it overlaying the existing data. But for now this works perfectly.
Hope it helps some one, trying to achieve the same thing.
score:5
you can call noData
and pass a string during the chart creation:
(coffeescript)
self.chart = nv.models.lineChart()
.margin left: 100, right: 100
.useInteractiveGuideline true
.transitionDuration 150
.showLegend true
.showYAxis true
.showXAxis true
.noData 'no data, there is'
Source: stackoverflow.com
Related Query
- NVD3 - Showing empty chart instead of noData message
- NVD3 example chart not showing
- angularjs nvd3 multibar chart xAxis tick not showing
- d3 chart is showing some decimal value in the X axis tick, instead of showing the date and time
- nvd3 tooltip is showing index instead of label
- nvd3 chart showing grayscale
- NVD3 chart fails to calculate legend text length in Chrome, since Window.getComputedStyle does not return font-size correctly
- How to customize color in pie chart of NVD3
- 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
- custom no data label in nvd3 scatter chart
- d3 show number instead of percentages on pie chart
- D3 Sankey chart using circle node instead of rectangle node
- 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
- NVD3 force specific width of bar in bar chart
- How to display values in Stacked Multi-bar chart - nvd3 Graphs
- Same color is showing in different arc of d3 pie chart
- nvd3 chart starts out squished in browser
- add y axis label to NVD3 Multi-Bar Chart
- dc-js line chart showing extra filled line at average change
- Responsive pie chart using NVD3
- NVD3 Scatter Chart Circle Radius
- How to add space between bars in a grouped bar chart in a nvd3 grouped multibar chart?
- How to set a nvd3 axis to use strings instead of numerical values ?
More Query from same tag
- Drawing a line connecting data points
- Parallel coordinates multidimensional data not visualised in D3
- d3js, detect click above chart
- d3 synchronizing 2 separate zoom behaviors
- How to prevent ticks from getting too close together for responsive d3 chart
- D3.js read csv file with special characters, é à ü è
- d3.nest().key().map().each is not a function
- My cities are being plotted with the wrong projection (quite small and to the left). Using d3.geo.albersUSA()
- Show first value in year axis, regardless of what month graph starts on
- Convert d3 map to high resolution image
- column graph with datetime xaxis in d3.js
- Key function in data binding: objects vs strings
- Drawing a line with two different colors using D3
- add legend to dc.js scatterplot
- How can I wrap text on the each arc in D3.js?
- How to add tool-tip in d3 group chart using csv file
- D3 - Remove padding to have graph fill the page
- d3 tooltip/popup for multiple data series?
- Show all data for a variable in box next to d3 chart on mouseover
- d3 stock value line graph: can't draw the line
- plot these points xy in c3.js
- Creating a bar chart based on number or rows over 100k using javascript with d3?
- D3.js: Exteding the y-axis without making any changes to the existing chart
- How to highlight the button when it is pressed
- Update existing nodes in a d3 Force Layout
- Padding out a Timeline so all data will be displayed? (custom extent function?)
- Targeting pseudo elements with d3 - is it possible?
- How to create a real-time plot with mpld3
- Examples showing animated transitions between linear and log scales in D3JS?
- d3.js build connections by using loop function