-
-
Save sirensoft/7eff8ebe17b0ecb4d1fe to your computer and use it in GitHub Desktop.
chart_meter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gaugeOptions = { | |
chart: { | |
type: 'solidgauge' | |
}, | |
title: null, | |
pane: { | |
center: ['50%', '85%'], | |
size: '140%', | |
startAngle: -90, | |
endAngle: 90, | |
background: { | |
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE', | |
innerRadius: '60%', | |
outerRadius: '100%', | |
shape: 'arc' | |
} | |
}, | |
tooltip: { | |
enabled: false | |
}, | |
// the value axis | |
yAxis: { | |
stops: [ | |
[0.6, 'red'], | |
[0.8, 'yellow'], | |
[0.9, 'green'], | |
], | |
lineWidth: 0, | |
minorTickInterval: null, | |
tickPixelInterval: 400, | |
tickWidth: 0, | |
//startOnTick:true, | |
title: { | |
y: -70 | |
}, | |
labels: { | |
y: 16 | |
} | |
}, | |
plotOptions: { | |
solidgauge: { | |
dataLabels: { | |
y: 5, | |
borderWidth: 0, | |
useHTML: true | |
} | |
} | |
} | |
}; | |
// The speed gauge | |
function gen_donut(obj, title_text, value) { | |
obj.highcharts(Highcharts.merge(gaugeOptions, { | |
yAxis: { | |
min: 0, | |
max: 100, | |
title: { | |
text: '<b>' + title_text + '</b>' | |
} | |
}, | |
credits: { | |
enabled: false | |
}, | |
series: [{ | |
// name: 'Speed', | |
data: [value], | |
dataLabels: { | |
format: '<div style="text-align:center"><span style="font-size:25px;color:' + | |
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>' + | |
'<span style="font-size:12px;color:silver">คุณภาพ ( % )</span></div>' | |
}, | |
tooltip: { | |
valueSuffix: ' ร้อยละ' | |
} | |
}] | |
})); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->registerJsFile( 'webpath/js/chart-donut.js', ['depends' => [\yii\web\JqueryAsset::className()]]); | |
$this->registerJs(" | |
var obj_div=$('#div'); | |
gen_donut(obj_div,'title',$value); | |
"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment