gpt4 book ai didi

javascript - 无法在 Gauge Highchart 中设置目瞪口呆

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

我已经尝试并走到了这一步,但仍然无法按照要求实现。

var chart = new Highcharts.chart('container', {

chart:{
type:'gauge',
backgroundColor:'#000',
},
title: {
text: null,
},
tooltip: {
enabled: false
},

pane: {
center: ['50%', '55%'],
size: '250',
startAngle: -135,
endAngle: 135,
background: {
backgroundColor:'rgba(255, 255, 255, 0)',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc',
borderWidth: 1,
},
},
plotOptions: {
gauge: {
dial: {
radius: '92%',
backgroundColor: '#fff',
borderColor: '#fff',
borderWidth: 0,
baseWidth: 4,
topWidth: 1,
baseLength: '80%', // of radius
rearLength: '-67%'
},
pivot: {
radius: '0%',
borderWidth: 0,
borderColor: null,
backgroundColor: 'rgba(255, 255, 255, 0)',
}
}
},
yAxis: [{

min: 0,
max: 250,
minPadding:5,
minorTickInterval: 3,
minorTickLength: 38,
minorTickWidth: 2,
offset:-10,
minorTickPosition: 'inside',
minorTickColor: 'rgba(255, 255, 255, 0.3)',

tickPixelInterval:100,
tickWidth: 2,
tickPosition: 'inside',
tickLength:-10,
tickColor: '#fff',
lineWidth :1,

labels: {
step: 1,
distance: 16,
rotation: 'auto',
style:{'color':'#fff','font-weight':'bold', 'font-size': '10px'}
},

plotBands: [{
from: 0,
to: 40,
color: '#31B710' // green
}, {
from: 40,
to: 125,
color: '#12B3D9' // blue
}, {
from: 125,
to: 175,
color: '#DD3308' // red
}],

plotOptions: {
solidgauge: {
dataLabels: {
y: 5,
borderWidth: 0,
useHTML: true,
enabled:false,
}
}
},

}],
credits: {
enabled: false
},
series: [{
name: 'Speed',
data: [175],
dataLabels: {
align: "center",
borderWidth:0,
borderColor: "rgba(255, 255, 255, 0)",
className:"gauge-center-text",
style:{
'color': '#fff',
'fill': '#fff',
'font-weight': 'normal',
'font-family': 'gargi',
},
useHTML:true,
verticalAlign:'middle',
x:0,
y:0,
format: '<div style="text-align:center; color:#fff; font-family: gargi; font-weight: normal; line-height: 33px;"><span style="text-align: center;font-size:38px; font-family: gargi; font-weight: normal; display:block;">{y}</span><span style="text-align: center;font-size:14px; font-family: gargi; font-weight: normal;" >Social Good</span></div>',
},

}]
});

请引用 fiddle 来完成我的开发。 fiddle并通过图像检查所需的仪表图表。 enter image description here

请问有人已经完成了这一步,请帮忙

最佳答案

您需要两个 y 轴,因为您需要两组刻度 - 一组带有延伸到整个圆弧的标签,另一组延伸到表盘。

第二个 y 轴应链接到第一个,您需要使用 axis.tickPositioner 手动设置刻度。 .

 {
linkedTo: 0,
offset: -15,
lineWidth: 0,
labels: {enabled: false},
minorTickInterval: null,
tickWidth: 1,
tickLength: 35,
tickColor: 'rgba(255, 255, 255, 0.3)',
tickPositioner: function () {
//generate ticks from 0 to 175
var interval = 3;
return Array.apply(null, Array(Math.round(175 / interval))).map((v, i) => i * interval);
}
}

可以使用svg演示属性设置虚线stroke-dasharray应用于 .highcharts-pane 类。

.highcharts-pane {
stroke-dasharray: 1, 3
}

示例:http://jsfiddle.net/yuvdddL1/

关于javascript - 无法在 Gauge Highchart 中设置目瞪口呆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41739954/

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