【发布时间】:2020-02-28 06:07:51
【问题描述】:
我正在尝试将饼图集成到我的网页中。它工作正常,但顶部和底部有额外的空间。我不知道那些空格。
如上图所述,顶部和底部有很多我不想要的空白。我在高图中有任何选项可以删除这些空间吗?或者我们可以使用 css 或其他任何东西吗?
下面是我正在处理的示例代码。
Highcharts.chart('jobs', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie',
showLegend: false
},
title: {
text: 'Parramatta'
},
subtitle: {
text: 'Total: 12',
},
tooltip: {
pointFormat: '{series.name} ({point.y}): <b>{point.percentage:.1f}%</b>'
},
exporting: {
enabled: false,
},
plotOptions: {
pie: {
allowPointSelect: false,
cursor: 'pointer',
dataLabels: {
enabled: true,
x: 0, y: 0,
format: '<b>{point.name} ({point.y}):</b><br />{point.percentage:.1f}%'
},
showInLegend: true,
cursor: 'pointer',
point: {
events: {
click: function() {
}
}
}
}
},
credits: {
enabled: false
},
series: [{
name: 'Jobs',
colorByPoint: true,
data: [
{
name: 'No AFSS',
y: 4,
color: '#9933ff',
},
{
name: 'Valid AFSS',
y: 4,
color: '#00b04f',
},
{
name: 'Expired AFSS',
y: 4,
color: '#ff0000',
}
]
}]
});
<link href="http://materialwrap-html.authenticgoods.co/assets/css/theme-a.css" rel="stylesheet"/>
<link href="http://materialwrap-html.authenticgoods.co/assets/css/app.bundle.css" rel="stylesheet"/>
<link href="http://materialwrap-html.authenticgoods.co/assets/css/vendor.bundle.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="row">
<div class="col-md-3 col-sm-4 col-xs-4">
<div class="panel panel-default">
<div class="panel-body">
<div id="jobs"></div>
</div>
</div>
</div>
</div>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
【问题讨论】:
-
你能创建一个能产生问题的工作 sn-p
-
将以下代码添加到您的选项 json 数组图例中:{ margin: 5, padding: 0 },
-
你能在我可以处理的在线编辑器上复制你的案例吗?
标签: jquery css charts highcharts pie-chart