score:2
here's how to achieve this, for anyone curious. this results in conditional scaling of axes when the largest current bar is too small (or large) to be valuable.
var currentmax = 0,
ratio,
chartmax = groupdata.top(1)[0].value; // initialize with largest value
row
.on('postredraw', function(chart){
currentmax = groupdata.top(1)[0].value; // after redraw, capture largest val
ratio = currentmax/chartmax;
if(ratio < .1 || ratio > 1){ // check if bars are too small or too large
row.elasticx(true);
chartmax = currentmax; // always be sure to reset the chartmax
dc.redrawall();
} else {
row.elasticx(false);
chartmax = currentmax;
}
});
Source: stackoverflow.com
Related Query
- DC.js - trigger elastic resize when criteria are met
- Resize svg when window is resized in d3.js
- How to avoid the overlapping of text elements on the TreeMap when child elements are opened in D3.js?
- How to trigger click of both elements, when clicking overlapping area
- d3js: zooming when there are two y axes
- How do I hide the text labels in d3 when the nodes are too small?
- Making a grouped bar chart when my groups are varied sizes?
- d3.js - stacked graphs that are both zoomed in and out/scrolled when using scrollwheel/drag on either graph
- Plotly.js in relative barmode labels are overlapped when both bars have value 0
- 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 event listeners cannot access "this" when ES6 arrow functions are used
- How to make grid lines when axes are aligned at the middle?
- Dynamically resize a div when it is used as a node in a d3 force-directed graph
- what is the point of calling selectAll when there are no existing nodes yet on D3.js
- Iterate over geojson in D3.js and return values when condition is met
- How to let line or path follow the shape when shape are move
- With NVD3.js (nv.models.lineWithFocusChart), how do you set specific ticks on X-axis, when x values are dates?
- Zero tick vertically centered on axis when all values are 0
- How to change table cell color based on numeric value from .csv report AND when tables are dynamically created?
- Why are my donut charts positioned outside the container when other chart types are correctly positioned?
- D3 behave weird when I do a drag act which also trigger unexpected zoom function
- How can I use a keyboard listener to trigger a tooltip when called?
- Are D3 value keys matched in the same way that default index numbers are when using enter()?
- Some bars are black when trying to use individual colors
- d3 v4: How to make a path being curved when only start and end point are known?
- How to load data to D3 chart from JSON when there are only tuples
- Drawing a line using d3 is not visible when all data items are the same
- Why labels on chart are not shown when drawn after axes
- D3.js node links overflowing into sibling nodes when new nodes are being added
- Resize my d3 chart so that it is 100% when the page loads and when you resize the window
More Query from same tag
- Accessing Lines Chord Diagram D3
- Retrieve stroke-width attribute of d3 axis path
- How to use D3 to append several html line of codes
- Creating a continuous data set from irregular, dated rows
- d3 timeline make axis fragmented (color-code) based on time offset
- One canvas, two sets of data
- d3.scaleLog ticks with base 2
- When adding d3.behavior.zoom, the .on("zoom", zoom), zoom undefined
- Axes Labels missing upon conversion from v3 to v4
- D3.js: How can I put an image on the background of a circle with the remaining parts trimmed and make it resize along with the circle onclick?
- D3 force layout graph causes slowness in firefox browser
- Get list of axis ticks with final formatting applied
- Canvas convert SVG to PNG doesn't get the full size
- D3.JS Click Event problem, using a svg map
- Change a pivot point of the nested svg using d3.js
- json file not loading frim Visual Studio 2013
- D3 v3 Force Layout - gracefully add/remove nodes without refresh
- d3 Bar chart with a tool tip is not working
- D3 DataMaps: OnClick Events on Bubbles Passing in Attributes of Bubble
- Why am I getting an array of NANs when trying to plot a map with D3.js?
- D3 pan/zoom behaviors don't work on mobile Safari
- Adding and Removing Nodes in D3js Force Graph
- d3 animation wordCloud flyin
- d3 updated json loads but doesn't access new data
- Get all paths in JSON object
- Plotting two datasets
- How to use series.stack = false in dimple.js to suppress aggregation; different symbols for each series
- D3.js v5 - Creating a relative, zoomable timeline-like axis on a linear scale
- D3 + VueJs + Typescript | How to import D3.js Library?
- Uncaught TypeError: d3plus.Pie is not a constructor