score:2
Accepted answer
I don't think it would be nice to display all the values in smaller svg. You need to take a decision here. I can suggest you two ways:
- You can create scrollable svg and display
- Either don't display x axis values as you are showing on legend.
But if you still want to display you can create a custom logic of yourself like below:
You can use tickValues hook on x axis, and select which values you want to display. In my case i want to show 5 ticks.
g.append("g")
.attr("class", "axis")
.attr("transform", "translate(0," + height + ")")
.transition()
.duration(1000)
.call(d3.axisBottom(x).tickValues(x.domain().filter((d, i) => {
const value = Math.floor(data.length/5)
return i % value === 0;})))
.selectAll("text")
.style("text-anchor", "middle")
.attr("dx", "3em")
.attr("dy", "1em")
.attr("transform", "rotate(30)");
Please find working code at - https://stackblitz.com/edit/angular-yry3au
Source: stackoverflow.com
Related Query
- How can i show the labels on the x axis when there is data overlap in d3js?
- 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?
- dimple.js How can I change the labels of a chart axis without changing the data?
- 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
- How can I display tooltips from multiple maps when mousover on one of the maps in D3js
- How to show the unhighlighted/ not selected data points on scatter plots when using brush/group in dc.js? And is multiple brushes possible in dc.js
- how to improve the drilling performance of d3 sunburst chart when there are too many paths? like dynamically show partial levels?
- How can I customize the label of X axis, that means the label in X axis is different from the data
- How to Show all the child nodes when there are many
- D3 - How can I show/hide a text element when hovering a circle element created from different attributes of the same data entry?
- How to setup D3.js axis labels to show rounded numbers with the $ sign?
- d3.js - How can I set the cursor to hand when mouseover these elements on SVG container?
- How can I get the D3.js axis ticks and positions as an array?
- How to update elements of D3 force layout when the underlying data changes
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- How to show and hides nodes when you move the mouse over a node in D3 Javascript
- How do I hide the text labels in d3 when the nodes are too small?
- How to make the NVD3 discreteBarChart labels on the X axis to adapt to the width or to the number of labels?
- how can i group JSON data into the weeks according to calender?
- How can I add labels inside the points in a scatterplot?
- How to make labels appear only when the chart is zoomed in
- d3.js, how can i create an axis with custom labels and customs ticks?
- How to show the value of each element when hovering
- How can I add axis labels to a sankey diagram in d3?
- D3.js v7 - How to make Y axis labels always show on screen for a scrollable chart
- How can I apply a time scale and show my data in intervals of "n" years?
- How to add svg rectangles as background behind axis tick labels in d3js if ticks are inside chart
- How can I use D3 tree data in the VEGA Api?
- In a d3 scatterplot using data from a csv file, how do i draw lines connecting related points when the mouse is over a point?
- How can I put the Germany map on a svg in HTML? D3js
More Query from same tag
- D3 scatter plot points not displaying correctly
- D3 sorting with an ordinal scale and selecting top 5
- D3 append div with id
- Uncaught TypeError: Cannot read property 'length' of undefined in d3.js
- How can I continuously update the range of the x axis in d3 graph?
- Difference between js syntax
- How do you draw d3-contour multipolygon output to canvas?
- Why is d3 exit() length higher than expected?
- Is it possible to add an svg element to an open layers map with D3?
- c3 chart not displaying changes on axis
- Howto set custom ticks and labels on Y axis in nvd3
- Confused by selection.filter
- Update line chart
- D3 x-Axis not showing correctly
- Plot median,lower quartile in dimplejs horizontal bar char
- Update D3 pie chart with JSON
- Chart-like object (but not a gantt or stacked bar chart) in d3 -- where to start?
- Filter nodes by weight and change attribute
- DC.js stack in line chart not showing
- How to filter objects in GeoJson based on an object?
- d3.js is not able to load my json on chrome but firefox & IE is working fine
- Create a Line graph with Dots and Labels using 2 different data sets
- trouble with D3js world map and svg group element width
- D3 Tree Graph Modified Data Model
- D3v6 zoom causing wrong pointer position
- Dataframe to Json to D3 via Flask
- d3 multiple svg with 1 row of data each
- d3 Trying to select text within a svg text element
- D3 Tooltip on small multiples
- d3.event is null in webpack build