Responsive chart with width and height to 100%
See original GitHub issueHello
I am trying to implement a responsive pie chart with width and height to 100%.
The html code:
<google-chart id="chart" [data]="pieChartData"></google-chart>
The relevant scss code:
#chart {
position: absolute;
top: 0;
left: 50%;
-webkit-transform: translate(-50%, 0);
transform: translate(-50%, 0);
width:100%;
height:100%;
@include rem(max-width, 350px); // just calculates the rem
@include rem(max-height, 350px); // just calculates the rem
}
and the chartData object:
{
chartType: "PieChart",
dataTable: dataTable,
options: {
legend:"none",
height: "100%",
width: "100%",
chartArea: {
height: "94%",
width: "94%"
}
}
}
For some reason setting “100%” in width and height does not work, hard coding those to e.g 350 will not make it responsive. Although the #chart in my browser ends up to 350 x 350 the enclosed div defaults to 350 x 200 I have tried using “100%” in plain javascript/css/html and it works. Any idea how to implement a responsive chart or what am am I doing wrong?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:8
Top Results From Across the Web
Responsive Charts - Chart.js
When it comes to changing the chart size based on the window size, a major limitation is that the canvas render size (...
Read more >Set height and width for responsive chart using recharts ...
The height / width will be 100% of the parent container in this case. Share.
Read more >Using Responsive Features – amCharts 4 Documentation
amCharts 4 has a powerful responsive capabilities built into its core. ... E.g. for a chart that is 80px wide, both width <=...
Read more >Chart Container - Concepts - Handbook - Apache ECharts
Listen to the Container Size to Change the Chart Size For instance, the container has a height of 400px and a width of...
Read more >Chart not following "Responsive Design" 100% Height
Chart not following "Responsive Design" 100% Height ... 100%; display: inline-block; zoom: 1; width: 99%; height: 34.65px; background-color: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

any updates? a version that uses angular flex is nice too
This - https://codepen.io/flopreynat/pen/BfLkA works for me!