score:0
Accepted answer
If anyone stumbles on this question in the future: I decided to place my title below the chart and managed to solve it by slightly cheating.
I used the following CSS:
.svg-container {
height:100%;
width:100%;
min-height: 100%;
position:relative;
}
.svg-content-responsive {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height:100%;
width: 100%;
position: relative;
padding-bottom: 50px;
}
.svg-gauge-title-container {
width: 100%;
height: 50px;
position:relative;
margin-top:-50px;
}
.svg-gauge-title {
position: relative;
width: 100%;
}
i.e. I added 50px of padding-bottom to the chart, and also added a title container with 50px of margin above. Might not be the cleanest way, but it works.
score:1
Is there something wrong with adding something like this:
var title = svg.append("text")
.text('This is the title')
.attr("text-anchor", "middle")
.style("font-size", '12px')
.attr("dy", 10)
.attr("dx", width / 2);
exactly like the text
?
PS: adding your approaches that failed would help people answer the question
Source: stackoverflow.com
Related Query
- d3.js title above responsive chart with fixed aspect ratio
- How to center title over SVG chart with d3.js?
- d3 bar chart with fixed bar width and fixed spacing to align in center axis line
- Keeping aspect ratio of D3 circle pack - responsive design
- Responsive line chart with transitions using d3
- Is there a way to keep aspect ratio fixed for text but not other svg elements?
- D3 donut chart based on seasons with fixed labels
- D3 v4 - make a horizontal bar chart with fixed width
- D3 - Create a chart with 3 fixed y-axis ticks
- d3 Responsive grouped bar chart with tooltip using json file
- height should be of fixed size in responsive chart
- how to add title to d3js bubble chart with force layout
- responsive D3 chart
- D3: How to refresh a chart with new data?
- Bar chart with negative values
- D3 force directed graph with drag and drop support to make selected node position fixed when dropped
- 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?
- nvd3 line chart with string values on x-axis
- how do you set a fixed link distance with d3 v4
- D3.JS time-series line chart with real-time data, panning and zooming
- Multiseries line chart with mouseover tooltip
- Format a number with SI Prefix, with fixed number of decimals
- d3.js chart area filling with different colors
- How to update d3.js bar chart with new data
- D3: gauge chart with growing arc
- d3.js pie chart with angled/horizontal labels
- NVD3 line chart with realtime data
- javascript charting - nvd3 line chart with two Y-axis
- Make simple bar chart using C3 with separate columns on the x axis
- d3 Line Chart with enter-update-exit logic
More Query from same tag
- How to use colors in RGB as the input domain in a d3.js linear (or different) scale? Or how to code an algorithm that achieves the same?
- D3 v6: How to zoom stacked bar by selected segment to stretch only selected segment and shrink rest segments (and keep initial chart width)?
- D3 Tree update color of nodes dynamically
- D3 draw children paths under parents
- how to remove zero if hours less then 10 from d3.time.format("%I %p")
- Precalculate and set initial positions of nodes in D3.js
- D3.js - exit() section does not remove all data
- Is there an issue with putting all of my code in the argument for d3.csv()?
- d3.js onclick and touch works erratically on topojson map
- Uncaught TypeError: d3.pack(...).sort is not a function
- Simple Pan and Zoom in d3 v7
- javascript: array of objects within an array of objects
- display rectangles based on values
- How to distinguish "0" values from filtered out values in a dc.js geoChoroplethChart?
- Attempting to apply d3.js transition to line length, not weight
- d3 lines between dots not working
- d3 v4 and angular v4 histogram syntax
- Displaying a graph
- D3.js Enter/update/exit not adding elements as expected
- Lasso select on amchart maps
- Alternative for JSON_ENCODE to be called in d3js graph
- Focus+context based zoom for multiple graphs in the same page
- embedding json in sankey d3 javascript file
- "TypeError: d is undefined" when transitioning on a bar chart with a mouseover event
- Delay animated arcs with .attrTween method
- How to make axis ticks disappear in c3js?
- How can I efficiently move from a Pandas dataframe to JSON
- D3 Pie chart arc partitions
- d3-v6-tip: d3.event is not defined
- D3: How to implement horizontally responsive SVG elements?