score:4
Accepted answer
You can use .tickFormat()
to suppress the labels for those particular values. As the thing you want to check isn't part of the data that's available to the scale, you'll need to find it in your entire data:
yAxis.tickFormat(function(d) {
var val = 0;
dataSet.forEach(function(item) {
if(item.Date == d) val = item.total;
});
return val == 0 ? "" : d;
});
This will suppress the label (return "") if the total is 0 or the value can't be found in the data set. Complete demo here.
Source: stackoverflow.com
Related Query
- d3 show labels only for ticks with data in a bar chart
- 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?
- C3js - combination chart with data labels only for line
- Only show first 25 data items in bar chart with d3.js
- Specifying Ticks on D3 Bar chart with Time Series data and scaleBand
- d3 bar chart labels not getting updated on updating the chart with the new data
- Updating d3 bar chart labels with new data of variable length
- Data model for creating a radial bar chart with d3js
- How to draw a Bar Chart with time on xAxis and one or more numeric data for yAxis in d3js?
- How to update d3.js bar chart with new data
- how to create labels for data in donut chart using d3.js
- How to show c3.js No data but with legend for empty column?
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- d3.js bar chart sorting: can't figure out how to sort x-axis labels along with bars
- Need help lining up x axis ticks with bars in D3.js bar chart
- How to modify axis labels in d3 for a stacked bar chart when the axis labels are mapped as part of the scale's domain
- x axis labels overlapping for grouped category bar chart in d3
- D3 - How to loop through an object with keys for a bar chart
- Grouped bar chart with zoom and updateable data error
- hack for d3 pie chart with 'zero' data
- D3 Grouped Bar Chart with JSON nested data
- Dimple.js - Add data labels to each bar of the bar chart
- d3.js bar chart with pos & neg bars (win/loss) for each record
- D3.js v7 - How to make Y axis labels always show on screen for a scrollable chart
- Show yearly X labels for June instead of January on d3.js chart
- Transitioning a bar chart with negative values for the width
- Stacked Bar Chart with Time Series Data
- Create a bar chart with local storage data (drawing the bars doesn't work)
- Multiline chart x-axis ticks not aligned with data points
- rendering issue in d3 radial bar chart with labels
More Query from same tag
- Draw a d3 trend line with different color and width for different segments
- Angularjs testing D3 directive compile bug
- Type errors for d3js in Angular ( Latest )
- How to Set Initial State of Gear Example without Using User Input Forms
- add fixed parameter to await callback
- How do I use angularjs directives in generated d3 html?
- Marker end position not working correctly d3js
- Not sure how to interpret D3 API
- D3.js: Why the bar chart turns around if I add this two statements
- Cannot set d3 axis to only integers
- d3.select is not working with special Characters
- Adding a drag icon to Focus+Context via Brushing Chart
- Drawing multiple bars per date
- How to omit a column from stack?
- How does "text-align: justify" works?
- vuejs + d3: select returns element, but attr() returns null
- Float text to the right of D3.Js Graph
- Can't add labels to d3js force layout network visualization
- Add link between the rectangles in d3 v4
- d3 clip-path not working for filled line graph
- How to position the legend to the right of the donut chart
- How to turn dataset into multiple different color lines in D3.JS
- NVD3.js Get Data Point's Screen Position Within SVG Chart
- D3: Data join for population pyramid
- Text not rendered in d3 visualization
- D3.js stick parent object in middle of the svg
- What is the best way to set nvd3 x domain range for dynamically changing time?
- Binding dc.js to Google Maps with crossfilter
- Different behaviour when using drag with array of numbers and array of objects
- unable to retrieve mutated data from getter