score:5
Accepted answer
You can can pass an array of ticks to an axis, and the axis will then plot ticks at the points in an array.
Here is some sample code. An axis is created that runs between 0 and 100. Tick marks are plotted at 0, 50, 60 and 100, in accordance with the 'ticks' array.
svg = d3.select("svg")
var myScale = d3.scale.linear()
.domain([0,100])
.range([0,400]);
var ticks = [0,50,60,100];
var myAxis = d3.svg.axis()
.scale(myScale)
.tickValues(ticks);
svg.append("g")
.attr("class", "axis")
.call(myAxis)
.attr("transform","translate(100,100)");
Here is an interactive example: http://tributary.io/inlet/5207532
Source: stackoverflow.com
Related Query
- How do I specify the number of axis tick marks in d3?
- D3: How to remove tick marks at the top and bottom of Y axis
- How can I keep tick marks from repeating when I have a small number of dates on an nvd3 chart
- How to display the value for the final tick on axis in D3?
- How to make the NVD3 discreteBarChart labels on the X axis to adapt to the width or to the number of labels?
- Limit number of Y axis ticks by keeping a top tick above the bar in d3
- How do i specify the axis range in React-Vis
- How is the number of ticks on an axis defined?
- limit number of tick marks in d3.js x axis with ordinal scale
- Why dont the axis tick marks get removed?
- How can i set the x axis tick interval to be 1 in C3 / d3 js charts?
- How to control the number of tick values in a graph with d3js
- How do I update the tick values on my axis when zooming ?
- How do I get the current number of tick values from a D3 axis?
- How can I get the D3.js axis ticks and positions as an array?
- 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?
- D3 grouped bar chart: How to rotate the text of x axis ticks?
- How do we change the tick values generated by a linear scale in a d3.js line plot?
- how to set the domain and scale on an axis on a nvd3.js multiBarChart
- How do I specify the initial zoom level in D3?
- Tick marks on both sides of axis on d3 scale
- How to flip the Y axis on my D3 graph?
- How to force nvd3 to display the equal number of ticks as that of the values plotted on the graph-nvd3
- How do you change the last tick value in D3.js?
- Count number of tick marks in D3.js
- How to format the Y axis values on Rickshaw Graphs
- How do I generate axis tick for every year in D3?
- c3 graph in a dark background; how to change axis and tick value color
- How to remove the first tick in d3
- Add extra tick of the beginning of a d3 time axis
More Query from same tag
- D3 onClick handler seems to have wrong scope when executed
- Creating a dot density map with D3.js
- Plot data using D3.js and AJAX
- How do I externalise my Data
- Resize points based on zoom
- d3 connect arc and point with a ribbon
- Removing a certain line inside a generated html code using javascript
- D3 Mouseover/Mouseout Conflict
- Manipulate external XML files after they have been loaded
- Bell Curve / Normal Disribution Curve On A NVD3 Discrete Bar Chart
- Y and Height Values for Stacked Bar Chart in D3
- Functions don't recognize variables
- How do I modify ticks and format labels on D3 axes?
- Why do my DOM elements lose their location attributes when I size my SVG based on container size?
- How to let line or path follow the shape when shape are move
- Searching in javascript (D3)
- How to append text to SVG
- d3 - Axis Label Transition
- Appending multiple elements in a single Join
- How to use Map.get() with array of arrays
- Filtering a D3.js map using jquery?
- Filter d3 js objects based on form input
- d3 dateformat parse returns null
- Showing online offline of a device with date and status js jquery d3
- Display months in x-axis nvd3 chart - odoo?
- I'm trying to build D3.js by using CodeMirror editor, but anything I input in there can't be properly visualized by D3.js. What am I missing?
- Building a force-directed concentric circle graph with node ordering from inside out in D3.V4
- Inputing an MPLD3 graph into Wordpress
- d3 Xscale returning nan even on setting scale properly
- D3 bar chart and html data attributes