highcharts 饼图

js 部分

var Typeoptions = {
chart: {
renderTo: 'materialTypeCount',//指向的div的id属性
plotBackgroundColor: null,
plotBorderWidth: null,
type: 'pie',
plotShadow: false
},
title: {
text: ''
},
exporting: { enabled:false },
credits: {
enabled: false
},
tooltip: {
pointFormat: '{point.y} 条'
},
plotOptions: {
pie: {
size:320,
allowPointSelect: false,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
format: '<b>{point.name}</b>: {point.y} 条'
},
point : {
events : {
// 控制图标的图例legend不允许切换
legendItemClick : function(event)
{
return false; // return true 则表示允许切换
}
}
},
showInLegend: true
}
},
legend: {
enabled:true,
borderWidth: 1,
floating:false ,
useHTML:true
}
};

var brandPrices;
var erencePrices;
var periodicalPrices;
function getType() {
var series = {};
chart = new Highcharts.Chart(Typeoptions);
chart.addSeries(series);
chart.showLoading('数据正在加载中...');
$.ajax({
type : "POST",
url : WEB_URL + '/getmaterialType',
data : {},
complete : function(response) {
var data = response.responseText;
if (false){
data = eval("(" + data + ")");
}
var result = data;
result = eval("(" + result + ")");
var tresults = result.results;
if(tresults[0] != null){
brandPrices=tresults[0].brandPrices;
erencePrices=tresults[0].erencePrices;
periodicalPrices=tresults[0].periodicalPrices;
series = {
type: 'pie',
data: [
['Safari', brandPrices],
['Opera', erencePrices],
['Firefox', periodicalPrices]
]
};
}
chart = new Highcharts.Chart(Typeoptions);
chart.addSeries(series);
}
});
}


java 代码部分
@RequestMapping(value = "/getmaterialType")
@ResponseBody
public Object getmaterialType(){
Map<String, String> params = new HashMap<String, String>();
MaterialCount type = indexService.getmaterialType(params);
List<MaterialCount> newType = new ArrayList<MaterialCount>();
if(type != null){
MaterialCount m1 = new MaterialCount();
m1.setBrandPrices(type.getBrandPrices());
m1.setPeriodicalPrices(type.getPeriodicalPrices());
m1.setErencePrices(type.getErencePrices());
newType.add(m1);
}
return new Result(200, null, newType, "success");

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值