score:4
Accepted answer
I haven't used rickshaw, but looking at this example on the homepage page:
var y_axis = new Rickshaw.Graph.Axis.Y( {
graph: graph,
orientation: 'left',
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
element: document.getElementById('y_axis'),
} );
It looks like you can pass a function to tickFormat. In this case formatKMBT is passed, and it looks like this:
Rickshaw.Fixtures.Number.formatKMBT = function(y) {
var abs_y = Math.abs(y);
if (abs_y >= 1000000000000) { return y / 1000000000000 + "T" }
else if (abs_y >= 1000000000) { return y / 1000000000 + "B" }
else if (abs_y >= 1000000) { return y / 1000000 + "M" }
else if (abs_y >= 1000) { return y / 1000 + "K" }
...ect
From here, you can use d3 built in number formatters or roll your own. For example:
function yAxisFormat(d){ return d.toFixed(8); }
score:4
Here's an example:
var yAxis = new Rickshaw.Graph.Axis.Y( {
graph: graph,
tickFormat: function(y){return y.toPrecision(3)}
} );
You can put whatever function you want there.
Source: stackoverflow.com
Related Query
- How to format the Y axis values on Rickshaw Graphs
- How can I convert the unix date values along the axis of a d3.js graph to format dd-mm-yy?
- How do I update the tick values on my axis when zooming ?
- How can I get the D3.js axis ticks and positions as an array?
- 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 can I get numeric values instead of Logarthmic values in D3 axis scale?
- How to display the value for the final tick on axis in D3?
- How to flip the Y axis on my D3 graph?
- How can I set min/max of the x-axis in Rickshaw / D3?
- How to graph dates on X axis in Rickshaw
- how do i format the value shown in a d3 graph
- How to force nvd3 to display the equal number of ticks as that of the values plotted on the graph-nvd3
- How to display values in Stacked Multi-bar chart - nvd3 Graphs
- D3.js- How to format tick values as quarters instead of months
- Display only values from the data set into X axis ticks
- How to set a nvd3 axis to use strings instead of numerical values ?
- How do I specify the number of axis tick marks in d3?
- How to make the NVD3 discreteBarChart labels on the X axis to adapt to the width or to the number of labels?
- D3: How to remove tick marks at the top and bottom of Y axis
- dimple.js How can I change the labels of a chart axis without changing the data?
- How do you retrieve the key values of a nested data set in D3
- 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
- D3.js - show tick values on the Y axis
- How to update the fill and sorting the values of lollipop chart?
- How to format brushed time axis (with context-dependent values)
- How to set the label for each vertical axis in a parallel coordinates visualization?
- NVD3.js line graphs fail to scale y axis to max and min values
- How do i specify the axis range in React-Vis
More Query from same tag
- Show values on top of line graph
- C3.js chart title overlapped if I change the size of title
- D3 arcTween - Updating transitions for multiple pie charts
- Transition a chart dependent on another chart
- How to create a conditional ease?
- D3 example not working
- D3.js adding/removing data pie chart slices
- Selectively removing node labels in D3 force directed diagram
- Error on horizontal Bar chart using d3.js
- Chart to display data over a long time frame
- D3 Geojson map won't display
- How to pass a number from app.js to index.html? I can pass a static text, but need to pass a calculated number or number from an array
- Undesired shimmering effect using D3 to create adjacent rectangles
- Shapefile to TopoJSON conversion problems
- d3js text not showing on node graph
- d3.js in drupal 7
- How to remove an attribute in D3.js?
- How do I stop event propagation in d3 using TypeScript?
- Margin calculation with D3 JavaScript
- How is it possible to sort a D3 generated HTML table with no "transition()" call?
- How Can I highlight the parents names and the connection lines when I hover on their child in family tree
- d3 heatmap using nested json data: how to create grids
- d3.js Sankey using named nodes
- D3.js Draw vertical line after every 2 bar and draw x-axis label on the top of bar chart
- enclosing the nodes of a d3 force directed graph in a circle or a polygon or a cloud
- TypeError: d3.layout.cloud is not a function
- Native d3.js methods to save / store / write data to a database?
- How to make Nvd3 use log scale on y-axis
- second transition won't work
- In D3 Bubble Layout, Is there a way to listen to the name of a bubble and add interaction via jQuery?