gpt4 book ai didi

javascript - 使用 highcharts 调整饼图高度时出错

转载 作者:行者123 更新时间:2023-12-03 05:10:46 25 4
gpt4 key购买 nike

我希望我的图表与其他 div 和主 div 内联,但我无法修复饼图 div 的高度,我希望删除额外的填充。我该如何实现这一目标?

图表.html

<html>
<head>

<script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>

<script type="text/javascript" src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script type="text/javascript" src="chart1.js"></script>
</head>
<body>



<div style="width:175px; height :200px">


<div >
<table style="width:100%;border:1px solid green">
<tr>
<td>Execution %</td>
<td style="text-align:right">70</td>
</tr>
<tr>
<td>Pass %</td>
<td style="text-align:right">90</td>
</tr>

</table>
</div>

<div id="chartdiv" style="min-width: 100px; max-width:100%;max-hright:100%;border:3px solid black ">

</div>

</div>

用于渲染此图表的 js 文件是:-

$(function() {           
var chart = new Highcharts.Chart('chartdiv',{
chart: {

margin: [0, 0, 0, 0],
spacingTop: 0,
spacingBottom: 0,
spacingLeft: 0,
spacingRight: 0
},
credits: {
enabled: false
},
title: {
text: null
},
plotOptions: {
pie: {
size:'100%',
slicedOffset: 0,
dataLabels: {
enabled: false
}
}
},
series: [{
type: 'pie',
name: 'Months',
data: [
['Jan', 45.0],
['Feb', 26.8],
['Mar', 8.5],
['June', 6.2],
['July', 21.0]
]}]
});
});

最佳答案

为图表 div 添加样式 - “chartdiv”

width:100% !important;
height:100% !important;

关于javascript - 使用 highcharts 调整饼图高度时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41829013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com