score:1
d3 axis can be configured using its properties. please have a look on the link so you will get a better idea for implementation
- d3 axis associated with d3.scale
- scale domain values to be visually encoded in pixels by range.
- length of the axis will always with in the range.
to achieve negative values regardless of the domain, make a default negative minimum value in scale domain. by providing this you can have the axis alway starts with the negative value.
var margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 400-margin.left - margin.right,
height = 200-margin.top - margin.bottom;
var y = d3.scale.linear()
.domain([-10, 10])
.range([height, 0]);
var yaxis = d3.svg.axis()
.scale(y)
.orient("left");
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("g")
.attr("class", "y axis")
.call(yaxis)
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispedges;
}
<script src="https://d3js.org/d3.v3.min.js"></script>
Source: stackoverflow.com
Related Query
- Display yaxis on left in d3
- display K and M in Angular nvd3 chart Yaxis
- How do I display dates on the x-axis for nvd3 / d3.js?
- SVG foreignObject contents do not display unless plain text
- Properly display bin width in barChart using dc.js and crossfilter.js
- Display an arrow head in the middle of D3 force layout link
- Display y-axis as percentages?
- Display only whole values along y axis in d3.js when range is 0-1 or 0-2
- Display multiple d3.js charts in a single html page
- Using d3.js, how can I display data faster on my chart?
- D3: Grayscale image display driven by 2D array data
- Display text on rect using D3.js
- How to dynamically display a multiline text in D3.js?
- Make Gist from Github repo for display on bl.ocks.org
- Nvd3: How prevent to display chart between -1 and 1 if have all y values 0?
- How to display the value for the final tick on axis in D3?
- How do I tell D3 to make the dendrogram vertical (top down) instead of left to right?
- Small Box to display where we are hovering in force layout (D3.js)
- D3.js, force-graph, cannot display text/label of nodes
- how to display name of node when mouse over on node in collapsible tree graph
- D3v4 time scale axis error in ticks display
- nvd3.js chart ajax data redraw - missing hovereffect + former yAxis scale
- d3.js geo worldmap - merge russia (shift small part from the left next to america to the right)
- Constrained d3.js Force display
- Display text in D3
- Gauge D3.js display value at the top of the needle
- How to set the domain and scale on an yaxis on a discreteBarChart nvd3.js
- How to use SVG gradients to display varying colors relative to the size of the colored region
- How to force nvd3 to display the equal number of ticks as that of the values plotted on the graph-nvd3
- Stroke left and right side of rect svg
More Query from same tag
- how to start drawing a line with a space between y-axis and it using d3js
- Integrating React with D3
- Create d3 map with geo-albers-usa-territories projection
- d3.js - How can I expand force directed graph horizontally?
- Combining Multiple D3 Charts of Different Types
- Centering svg image used on clustered bar chart
- D3 Horizontal Stacked Bar Chart with Lines
- Keep DOM event handlers when writing an SVG to file
- d3.tsv to load tsv file not working
- Show box on mousehover
- D3 Hierarchical Bar Chart - Change X and Y axis values
- Line Chart path in D3 JS not displaying Properly
- Force.drag().on returns undefined
- Adding a drag icon to Focus+Context via Brushing Chart
- D3 charts interactive repository and learning center
- How can I use column values for SVG colors using JS/D3?
- d3 v4 error this.setAttribute is not a function
- D3.js 'Pie Charts Labels' Overlapping
- D3-cloud with backbone.js
- d3.js build connections by using loop function
- Starting a d3 axis timescale from zero
- Convert SVG co-ordinate to page co-ordinate in D3 js
- d3 y axis label position
- D3 Changing the width attribute of an object depending on it's child
- What is this event handler doing?
- D3 Coordinates of mousedover circle
- d3 data update CSV - can't figure out how to update table cells
- Overlapping category axis label text in c3js charts
- d3 axis not showing tick label if two ticks have the same value
- d3 US state map with markers, zooming transform issues