score:1
I feel it's a good practice to append the <g>
for the axes first and then once the domains are set, you call them. Relevant changes made:
Re-ordered:
this.drawAxis(); this.createStack(this.data);
Calling axes once the domains are set:
this.y0.domain([0, +d3.max(this.stackedSeries, function (d: any) { return d3.max(d, (d: any) => { return d[1] }) })]); this.chart.select('g.y0-axis').call(d3.axisLeft(this.y0));
Removing "four" from the keys as it doesn't exist in the data:
.keys(['one', 'two', 'three'])
Included the
stroke-dasharray
transition to the line from your previous postvar totalLength = thisLine.node().getTotalLength(); thisLine.attr("stroke-dasharray", totalLength + " " + totalLength) .attr("stroke-dashoffset", totalLength); thisLine.transition() .duration(1000) .attr("stroke-dashoffset", 0);
Here's a fork of your code with the above changes: https://stackblitz.com/edit/d3-stacked-trend-bar-positioned-months-vtb2zr?file=src/app/bar-chart.ts
Source: stackoverflow.com
Related Query
- D3 - axis only show values from 0-1
- Display only values from the data set into X axis ticks
- Display only whole values along y axis in d3.js when range is 0-1 or 0-2
- Format Y axis values, original figures in millions, only want to show first three digits
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- D3.js - show tick values on the Y axis
- D3 - Show only middle and last tick marks on axis
- setting up d3 axis with KiB, MiB, GiB units from values in bytes
- d3 - Show only values using d3.nest()
- Maintain highest and lowest values only in Y axis of d3.js Bar graph
- d3js: How to select only x number of values from data
- Best way to show Y axis values in Millions of £
- Show only max values in d3 bar chart
- D3 show values as label on right axis
- Displaying values from JSON along an axis
- D3 tooltip show values from nested dataset
- Show values on Y Axis as it is with Higher and lower limits NVD3 Line Chart
- Why do the y axis values shift up from real point in line chart?
- Angular + D3 - Get scope values to show in template from click event
- Want to show unique values only using d3.js not working
- D3 brushes: accessing absolute values from axis
- Values from file don't expand as x axis in D3.js using x.domain?
- dc.js graph won't show line and y axis values
- d3 axis is not showing any values if there is only 1 value in the domain
- Remove end-ticks from D3.js axis
- D3.js: Using images (with filenames specified in data) as tick values on axis
- D3: Is it possible to zoom+pan one axis and only pan the other?
- 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?
- Show d3 node text only on hover
- How to select unique values in d3.js from data
More Query from same tag
- How can I connect two parent node into one child node and how to make a tooltip for each node in the tree pragmatically? in D3 js (SVG)
- How to give same classes
- What does fusion chart buy you that D3 doesn't?
- Shading polygons with d3
- D3 v4: charting tool: How to send horizontal gridlines behind columns
- Updating WebView on Android 5
- I am not able to run the D3 code on my local computer
- Center a element on the svg
- update d3 pack layout from multiple json files
- d3js with node, how do I add a lines to pie chart?
- How do I auto generate domain & range? Anyone know why my data is not showing up?
- How to animate range input element properly?
- D3.geo.bounds does not return bounding box?
- Why does my array need parsing, when they look the same in the console?
- How is it possible to sort a D3 generated HTML table with no "transition()" call?
- Setting labels on axis ticks in D3 V5
- Which workflow to get polygons from a geographic area and a raster file?
- combining Aframe and d3.js: embed issue with different library source
- D3, Typescript - Argument of type 'this' is not assignable to parameter of type 'BaseType'
- Create svg element from string
- D3 (v3.4) edge bundle chart and update button to load a new dataset
- How do I place a D3 tooltip inside a div?
- Flatten nested array created with d3.nest() to create stacked bar
- Create a line passing through some points with d3.js
- D3.js - generating a drag event in Jasmine programmatically
- Create an interactive chart (zoom/pan) with lines using D3
- How can D3 select multiple shapes with shared attributes from a group?
- D3 change Dataset csv
- loop over js array in d3 callback tree
- Style the previous links to a child on hover in D3