Javascript Highchart在初始加载时未显示正确的大小,仅在react js中调整窗口大小时调整大小
目前我正在我的React中开发图表。我用的是海图。我的问题是,当我第一次加载图表时,大小与容器大小不符,当我调整窗口大小时,只有图表显示正确的大小 建议使用许多解决方案Javascript Highchart在初始加载时未显示正确的大小,仅在react js中调整窗口大小时调整大小,javascript,reactjs,highcharts,window-resize,react-highcharts,Javascript,Reactjs,Highcharts,Window Resize,React Highcharts,目前我正在我的React中开发图表。我用的是海图。我的问题是,当我第一次加载图表时,大小与容器大小不符,当我调整窗口大小时,只有图表显示正确的大小 建议使用许多解决方案 chart.reflow(); 但是如何在react代码中使用它呢 我试过了 .highcharts-container, .highcharts-container svg { width: 100% !important; } 不起作用 图表始终显示初始值如下所示 我需要把图表完全画在黄线上 我的图表代码 thi
chart.reflow();
但是如何在react代码中使用它呢
我试过了
.highcharts-container, .highcharts-container svg {
width: 100% !important;
}
不起作用
图表始终显示初始值如下所示
我需要把图表完全画在黄线上
我的图表代码
this.setState({
chartDrawSector: {
chart: {
type: 'column',
height: '600',
events: {
load: function(event) {
event.target.reflow();// i tried this not working also..
}
}
},
title: {
text: 'Sector All'
},
// subtitle: {
// text: 'Source: WorldClimate.com'
// },
xAxis: {
categories: sectorName[0],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: displayMode == 'f' ? 'Figures' : 'Percentage %'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} </b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Ultimate Negative',
data: n30Data[0],
color: 'rgb(100, 30, 22 )'
},
{
name: 'Ultimate Positive',
data: gt30Data[0],
color: 'rgb(27, 79, 114)'
},
]
}
})
this.setState({
图表部门:{
图表:{
键入:“列”,
高度:'600',
活动:{
加载:函数(事件){
event.target.reflow();//我尝试了这个方法,但也不起作用。。
}
}
},
标题:{
文本:“全部扇区”
},
//副标题:{
//文本:'来源:WorldClimate.com'
// },
xAxis:{
类别:扇区名称[0],
十字准星:对
},
亚克斯:{
分:0,,
标题:{
text:displayMode=='f'?'Figures':'Percentage%'
}
},
工具提示:{
headerFormat:“{point.key}”,
pointFormat:“{series.name}:”+
“{point.y:.1f}”,
页脚格式:“”,
分享:是的,
useHTML:true
},
打印选项:{
专栏:{
点填充:0.2,
边框宽度:0
}
},
系列:[{
名称:'最终负数',
数据:n30Data[0],
颜色:'rgb(100,30,22)'
},
{
名称:'最终正',
数据:gt30Data[0],
颜色:'rgb(27,79,114)'
},
]
}
})
您已将图表高度指定为600。尝试从图表配置中删除它。嗨,我尝试了。。但是图表变得越来越小。你能用样本数据在一些在线编辑器上重现你的案例吗?您可以从此模板开始: