score:0
Accepted answer
i solved this whit following approach, it's controlled by shouldlogscale
var:
nv.addgraph(() => {
this.chart = nv.models.multibarchart()
...
.y(d => {
const y = parsefloat(d.y);
return this.shouldlogscale ? math.log10(y <= 0 ? 1 : y) : y;
});
if(this.shouldlogscale) {
this.logscale();
} else {
this.chart.yaxis.tickformat(d3.format(`,.${this.precision}f`));
}
...
});
when initialising the chart: i modify y
values, force y
(chart.forcey
) start and end values (map them to their log10 range), analogically i set chart.yaxis.tickvalues
. lastly i map ticks (chart.yaxis.tickvalues
) to their original values. just make sure to comply domain of the log function.
logscale
method:
private logscale() {
this.chart.forcey([1, 180]
.map(v => math.log10(v)));
this.chart.yaxis.tickvalues([1, 3, 5, 10, 20, 50, 100, 180]
.map(v => math.log10(v)));
this.chart.yaxis.tickformat(d => math.pow(10, d).tofixed(this.precision));
}
maybe i could use a map of y domain and range values to avoid using log and pow functions in logscale
method.
Source: stackoverflow.com
Related Query
- nvd3 - multiBarChart: how to log scale y axis
- how to set the domain and scale on an axis on a nvd3.js multiBarChart
- How to make Nvd3 use log scale on y-axis
- How to set a nvd3 axis to use strings instead of numerical values ?
- How to make the NVD3 discreteBarChart labels on the X axis to adapt to the width or to the number of labels?
- NVD3 (D3 JS) how to remove y2 axis
- how to draw nvd3 simple barchart with x and y axis in angularjs
- nvd3 Bubble chart with log scale
- NVD3 how set y scale correctly?
- d3.js how to place custom labels on horizontal log scaled axis
- NVD3 x axis time scale misaligned
- Axis with log scale, how to include tick for 0?
- nvD3 - multiBarChart - How to start from 0 and how to change the shape of controls
- nvd3 - How to redraw axis on windows resize
- How to spcify ticks on x axis for time scale in d3js?
- How to use log scale to show proper stacked bar chart using d3 JS?
- How to scale year interval in D3 axis without changing columns
- nvd3 - how to set y axis to default values
- NVD3 Cumulative Line Chart : How to set different back ground color for specific X axis
- how to remove gridlines for subticks for log scale
- Log axis scale not formatting data
- How to hide first Y Axis line on an nvd3 chart?
- Trying to understand how log scale in d3.js works
- How to remove unwanted lines in Axis scale of a graph when using D3.js?
- How can I fix my chart so that the scale of the x axis is defined by a group of labels?
- How to expand a data scale on NVD3 line chart
- How do I prevent graph elements from reaching the axis of my graph in D3 and scale properly?
- How to give a better Y axis label / scale in d3 chart?
- How to update the axis scale on change events in cubism/d3
- nvd3 multiBarChart with line along x axis
More Query from same tag
- D3.js node color based on type
- How to override inherited svg style
- D3 Alternate Calendar - Coloring by Bin
- How to load data from an internal JSON array rather than from an external resource / file for a collapsible tree in d3.js?
- D3.js Can not add background image to rectangle
- Understanding why three nested functions are used in .attrTween
- Sum by category in Piechart (Dc.js & Crossfilter)
- How do I structure data in php to get the correct json result?
- c3js json timeseries issue
- Reactsj and d3v4 integration -- Table and Pie chart application with jest testing
- Selecting inner tspan on SVG
- how can i prevent d3.behavior.zoom().on("zoom", redraw) from being used when i mousedrag on my nodes?
- reading d3 data in from a file rather than hard coding it into a programme
- D3 - passing JSON data through AJAX call
- .style of child nodes in d3js
- Ignore duplicate date values
- How to redraw chart : d3.js chaining function and crossfilter filtering
- Draw a path out gradually from the middle
- D3 Bar shows data only for first date
- Is there a trivial way to get non-strict JavaScript codebase to behave in a 'strict' environment?
- Using d3.js + SoundCloud API - Need to show track titles
- Right to Left Icicle Tree
- Creating Tool Tips Correctly Based on Individual Sums
- D3.js Tree - Check and set fill circle node white if no children?
- Angular nvd3 multibarchart stacked not showing properly
- doubts regarding an "official" example of D3 pack layout
- data visualization with d3.js in javascript
- How do you change the last tick value in D3.js?
- Change scale default in cubism.js
- d3js not having the same behaviour within and outside a function