gochart/template_pie_html.go

80 lines
2.8 KiB
Go
Raw Permalink Normal View History

2014-12-26 17:37:11 +08:00
package main
// see the resource of : http://www.freecdn.cn/libs/highcharts/
2014-12-26 17:42:51 +08:00
var TemplatePieHtml = `{{define "T"}}
2014-12-26 17:37:11 +08:00
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Gochart - {{.ChartType}} | CodeG.cn</title>
2014-12-26 17:37:11 +08:00
<script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
//type: 'pie',
type: '{{.ChartType}}',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
// text: 'Browser market shares at a specific website, 2014'
text: '{{.Title}}',
},
subtitle: {
// text: 'Source: somewebsite.com',
text: '{{.SubTitle}}',
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
// name: 'Browser share',
name : '{{.SeriesName}}',
2014-12-26 17:37:11 +08:00
data:
{{.DataArray}}
/*
data:
[
['Firefox', 45.0],
['IE', 26.8],
['Chrome', 12.8],
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
*/
}]
});
});
</script>
</head>
<body>
2017-03-12 10:31:56 +08:00
By <a id="copyright" class="anchor" href="http://blog.codeg.cn/2014/12/13/Hello-CodeG/" >zieckey@gmail.com</a>
2014-12-26 17:37:11 +08:00
<script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/4.0.1/highcharts.js"></script>
<script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/4.0.1/modules/exporting.js"></script>
2017-03-12 21:51:02 +08:00
<div id="container" style="min-width: 310px; height: {{.Height}}px; max-width: 600px; margin: 0 auto"></div>
2014-12-26 17:37:11 +08:00
</body>
</html>
{{end}}
`