initial commit
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Highcharts Example</title>
|
||||
|
||||
<style type="text/css">
|
||||
#container {
|
||||
margin: 0 auto;
|
||||
max-width: 400px;
|
||||
min-width: 380px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="../../code/highcharts.js"></script>
|
||||
<script src="../../code/highcharts-more.js"></script>
|
||||
<script src="../../code/modules/solid-gauge.js"></script>
|
||||
|
||||
<div id="container"></div>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
// Uncomment to style it like Apple Watch
|
||||
/*
|
||||
if (!Highcharts.theme) {
|
||||
Highcharts.setOptions({
|
||||
chart: {
|
||||
backgroundColor: 'black'
|
||||
},
|
||||
colors: ['#F62366', '#9DFF02', '#0CCDD6'],
|
||||
title: {
|
||||
style: {
|
||||
color: 'silver'
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
style: {
|
||||
color: 'silver'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// */
|
||||
|
||||
/**
|
||||
* In the chart render event, add icons on top of the circular shapes
|
||||
*/
|
||||
function renderIcons() {
|
||||
|
||||
// Move icon
|
||||
if (!this.series[0].icon) {
|
||||
this.series[0].icon = this.renderer.path(['M', -8, 0, 'L', 8, 0, 'M', 0, -8, 'L', 8, 0, 0, 8])
|
||||
.attr({
|
||||
'stroke': '#303030',
|
||||
'stroke-linecap': 'round',
|
||||
'stroke-linejoin': 'round',
|
||||
'stroke-width': 2,
|
||||
'zIndex': 10
|
||||
})
|
||||
.add(this.series[2].group);
|
||||
}
|
||||
this.series[0].icon.translate(
|
||||
this.chartWidth / 2 - 10,
|
||||
this.plotHeight / 2 - this.series[0].points[0].shapeArgs.innerR -
|
||||
(this.series[0].points[0].shapeArgs.r - this.series[0].points[0].shapeArgs.innerR) / 2
|
||||
);
|
||||
|
||||
// Exercise icon
|
||||
if (!this.series[1].icon) {
|
||||
this.series[1].icon = this.renderer.path(
|
||||
['M', -8, 0, 'L', 8, 0, 'M', 0, -8, 'L', 8, 0, 0, 8,
|
||||
'M', 8, -8, 'L', 16, 0, 8, 8]
|
||||
)
|
||||
.attr({
|
||||
'stroke': '#ffffff',
|
||||
'stroke-linecap': 'round',
|
||||
'stroke-linejoin': 'round',
|
||||
'stroke-width': 2,
|
||||
'zIndex': 10
|
||||
})
|
||||
.add(this.series[2].group);
|
||||
}
|
||||
this.series[1].icon.translate(
|
||||
this.chartWidth / 2 - 10,
|
||||
this.plotHeight / 2 - this.series[1].points[0].shapeArgs.innerR -
|
||||
(this.series[1].points[0].shapeArgs.r - this.series[1].points[0].shapeArgs.innerR) / 2
|
||||
);
|
||||
|
||||
// Stand icon
|
||||
if (!this.series[2].icon) {
|
||||
this.series[2].icon = this.renderer.path(['M', 0, 8, 'L', 0, -8, 'M', -8, 0, 'L', 0, -8, 8, 0])
|
||||
.attr({
|
||||
'stroke': '#303030',
|
||||
'stroke-linecap': 'round',
|
||||
'stroke-linejoin': 'round',
|
||||
'stroke-width': 2,
|
||||
'zIndex': 10
|
||||
})
|
||||
.add(this.series[2].group);
|
||||
}
|
||||
|
||||
this.series[2].icon.translate(
|
||||
this.chartWidth / 2 - 10,
|
||||
this.plotHeight / 2 - this.series[2].points[0].shapeArgs.innerR -
|
||||
(this.series[2].points[0].shapeArgs.r - this.series[2].points[0].shapeArgs.innerR) / 2
|
||||
);
|
||||
}
|
||||
|
||||
Highcharts.chart('container', {
|
||||
|
||||
chart: {
|
||||
type: 'solidgauge',
|
||||
height: '110%',
|
||||
events: {
|
||||
render: renderIcons
|
||||
}
|
||||
},
|
||||
|
||||
title: {
|
||||
text: 'Activity',
|
||||
style: {
|
||||
fontSize: '24px'
|
||||
}
|
||||
},
|
||||
|
||||
tooltip: {
|
||||
borderWidth: 0,
|
||||
backgroundColor: 'none',
|
||||
shadow: false,
|
||||
style: {
|
||||
fontSize: '16px'
|
||||
},
|
||||
pointFormat: '{series.name}<br><span style="font-size:2em; color: {point.color}; font-weight: bold">{point.y}%</span>',
|
||||
positioner: function (labelWidth) {
|
||||
return {
|
||||
x: (this.chart.chartWidth - labelWidth) / 2,
|
||||
y: (this.chart.plotHeight / 2) + 15
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
pane: {
|
||||
startAngle: 0,
|
||||
endAngle: 360,
|
||||
background: [{ // Track for Move
|
||||
outerRadius: '112%',
|
||||
innerRadius: '88%',
|
||||
backgroundColor: Highcharts.Color(Highcharts.getOptions().colors[0])
|
||||
.setOpacity(0.3)
|
||||
.get(),
|
||||
borderWidth: 0
|
||||
}, { // Track for Exercise
|
||||
outerRadius: '87%',
|
||||
innerRadius: '63%',
|
||||
backgroundColor: Highcharts.Color(Highcharts.getOptions().colors[1])
|
||||
.setOpacity(0.3)
|
||||
.get(),
|
||||
borderWidth: 0
|
||||
}, { // Track for Stand
|
||||
outerRadius: '62%',
|
||||
innerRadius: '38%',
|
||||
backgroundColor: Highcharts.Color(Highcharts.getOptions().colors[2])
|
||||
.setOpacity(0.3)
|
||||
.get(),
|
||||
borderWidth: 0
|
||||
}]
|
||||
},
|
||||
|
||||
yAxis: {
|
||||
min: 0,
|
||||
max: 100,
|
||||
lineWidth: 0,
|
||||
tickPositions: []
|
||||
},
|
||||
|
||||
plotOptions: {
|
||||
solidgauge: {
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
linecap: 'round',
|
||||
stickyTracking: false,
|
||||
rounded: true
|
||||
}
|
||||
},
|
||||
|
||||
series: [{
|
||||
name: 'Move',
|
||||
data: [{
|
||||
color: Highcharts.getOptions().colors[0],
|
||||
radius: '112%',
|
||||
innerRadius: '88%',
|
||||
y: 80
|
||||
}]
|
||||
}, {
|
||||
name: 'Exercise',
|
||||
data: [{
|
||||
color: Highcharts.getOptions().colors[1],
|
||||
radius: '87%',
|
||||
innerRadius: '63%',
|
||||
y: 65
|
||||
}]
|
||||
}, {
|
||||
name: 'Stand',
|
||||
data: [{
|
||||
color: Highcharts.getOptions().colors[2],
|
||||
radius: '62%',
|
||||
innerRadius: '38%',
|
||||
y: 50
|
||||
}]
|
||||
}]
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user