score:1
Accepted answer
You could set all the text in the axis to a particular class and then hide the ticks based on the number for example.
//Create the xAxis and assign x-axisticks class to the tick text
var xAxis = svg.append("g")
.style("font-size", textSetter())
.attr("class", "xAxis", "axis")
.attr("transform", "translate(" + 0 + "," + heightTwo + ")")
.call(d3.axisBottom(xScale)
.selectAll('text')
.attr('class', 'x-axisticks');
//remove the ticks which based on the multiples
var xticks = d3.selectAll('.x-axisticks');
xticks.attr('class', function (d, i) {
i = i + 1;
if (i % 5 !== 0) d3.select(this).remove();
});
Hope this helps. A more specific use-case answer would probably require some more code to be posted from your end so that I can tailor an answer, but this should work.
Source: stackoverflow.com
Related Query
- D3JS: unable to set only 5 ticks in x Axis
- Display only values from the data set into X axis ticks
- d3js time axis ticks duration set dynamically
- Ticks only at the start and end of an axis
- How to set fixed no. of ticks on axis in d3.js?
- d3js axis dates start and end value only
- d3js set tickValues for time scale axis
- Cannot set d3 axis to only integers
- How to add svg rectangles as background behind axis tick labels in d3js if ticks are inside chart
- Resize projection in d3JS in only one axis with a geojson map
- D3js Changing ticks on Zoomable Time axis
- d3 changing x Axis Time ticks only full years and full months
- Howto set custom ticks and labels on Y axis in nvd3
- set yAxis ticks D3js
- d3js - Stacked Bar Chart in Horizontal Axis - How do I set x so the bars are seperated?
- D3js Ordinal Axis does not show all the ticks
- D3js change ticks x and y axis
- d3js set X axis tick position
- How to place a date in a tooltip when only part of axis ticks with dates are shown? Using D3.js
- d3.js: Align text labels between ticks on the axis
- How can I get the D3.js axis ticks and positions as an array?
- D3: Is it possible to zoom+pan one axis and only pan the other?
- D3 - using strings for axis ticks
- Display only whole values along y axis in d3.js when range is 0-1 or 0-2
- how to set the domain and scale on an axis on a nvd3.js multiBarChart
- d3 ticks only shows Sundays:
- Format Y axis values, original figures in millions, only want to show first three digits
- Multiline svg text axis ticks in d3
- d3js - how to set albers projection properly?
- How to change line color in d3js according to axis value?
More Query from same tag
- obtaining data values on two different places within a webpage
- Creating a categorical line chart in D3.js (V4)
- Merge objects that share a common key or value
- D3js undefined variable creating fill color
- Custom Y axis label and tick in d3
- D3.js network graph using force-directed layout and rectangles for nodes
- How to access JSON data with D3.js?
- How to place node title to the left or right of the node in d3 Sankey graph?
- nvd3 positive and negative value for same timestamp
- How to add jitter to a d3 plot?
- Can I use drag.container in d3.js to restrict the dragging area?
- Unable to plot chart with new data format
- D3.js: Wrong position of horizontal and vertical focus lines (crosshairs) in line chart
- Add correct value after nesting with d3
- leaflet.js: too slow with custom svg markers (and a lot of points)
- Leaflet Choropleth Map and D3 Line Graph Interference
- Using Custom Scale function for ReCharts or d3-scale
- d3 charts sankey json error
- How to change Y-Axis dc.js
- Zoom touch on mobile with d3
- Draw USA map region wise using D3 and angular 6
- Moving fixed nodes in d3 force layout
- d3.js vertical line on a time axis
- Angular 6 compile template runtime
- D3 Tree ON event issue using MOUSEOVER
- How do I use/retrieve the C3 scale function post generate?
- Highlight data label onmouseover for c3js chart
- How to add tick marks to color legend in d3.js
- can not plot lines in d3, parsing error
- D3 Brush Extent Inverted