unable to resize chat after update dom with chartjs 2.7
See original GitHub issueIt works on chartjs 2.6 but DOSE NOT on 2.7.
Could you fix this?
Here is my js code.
class DataSet extends React.Component {
...
const data = {
labels = ["aaa", "bbb", "ccc"];
datasets = [
{ label: "xxxx", backgroundColor: "xxx", data: [...], ... },
{ label: "yyyy", backgroundColor: "yyy", data: [...], ... },
{ label: "xxxx", backgroundColor: "xxx", data: [...], ... },
]
}
const options = {
responsive: true,
...
}
render() {
return(<PowerMonitorGraph data={data} options={options} />)
}
}
class PowerMonitorGraph extends React.Component {
constructor(props) {
super(props);
this.state = {
data: this.props.data,
options: this.props.options
}
}
componentWillReceiveProps(props) {
if (props.data !== this.state.data) {
this.setState({data: props.data});
}
if (props.options !== this.state.options) {
this.setState({options: props.options});
}
}
render() {
return (
<Line data={this.props.data} options={this.props.options} redraw={true}/>
)
}
}
And then here is debug.
After first rending,it works fine.
<div class="chartjs-size-monitor" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: hidden; pointer-events: none; visibility: hidden; z-index: -1;">
<div class="chartjs-size-monitor-expand" style="position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;pointer-events:none;visibility:hidden;z-index:-1;">
<div style="position:absolute;width:1000000px;height:1000000px;left:0;top:0"></div>
</div>
<div class="chartjs-size-monitor-shrink" style="position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;pointer-events:none;visibility:hidden;z-index:-1;">
<div style="position:absolute;width:200%;height:200%;left:0; top:0"></div>
</div>
</div>
<canvas height="422" width="844" class="chartjs-render-monitor" style="display: block; width: 844px; height: 422px;"></canvas>
After update dom, resize does’t work.
<canvas height="422" width="844" class="chartjs-render-monitor" style="display: block; width: 844px; height: 422px;"></canvas>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:6
Top Results From Across the Web
unable to resize chat after update dom with chartjs 2.7 #203
I have a similar problem, chart will resize it's width, but the height will never change. Is there ANY example showing how to...
Read more >Developers - unable to resize chat after update dom with chartjs 2.7 -
Coming soon: A brand new website interface for an even better experience!
Read more >Chart.js Disappear on Window Resize - Stack Overflow
I had a problem, on resizing the window, the graph disappears. I solved the problem by creating the graph just once with the...
Read more >Chart.js
js-based, charting libraries that render as SVG. Canvas rendering makes Chart.js very performant, especially for large datasets and complex ...
Read more >Responsive Charts - Chart.js
js is unable to properly resize for the print layout. To work around this, you can pass an explicit size to .resize() then...
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 FreeTop 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
Top GitHub Comments
I have a similar problem, chart will resize it’s width, but the height will never change. Is there ANY example showing how to make a chart resize properly when it’s parent resizes?
I do not care about this anymore. so, I close this.