highcharts 饼图_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > highcharts 饼图

highcharts 饼图

 2015/1/6 18:50:51  半城煙沙  程序员俱乐部  我要评论(0)
  • 摘要:js部分varTypeoptions={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}条'}
  • 标签:
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");

}
  • highcharts.rar (51.8 KB)
  • 下载次数: 0
  • 相关文章
发表评论
用户名: 匿名