index.html 5.42 KB
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>无标题</title>
</head>
<body ng-controller="MyController">
    <div xn-charts style="height:400px" chart-config="chartConfig"></div>
    <div xn-charts style="height:400px" chart-config="chartConfig"></div>
</body>
<script type="text/javascript" src="../spm_modules/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="../spm_modules/xn-angular/1.0.0/angular.js"></script>
<script type="text/javascript" src="../vendor/echarts-all.js"></script>
<script type="text/javascript" src="../directive/charts.js"></script>
<script type="text/javascript">
	angular.module("myApp", ["xn.charts"])
	.controller("MyController", ["$scope", function($scope) {
//        var dataStyle = {
//            normal: {
//                color: function(params) {
//                    // build a color map as your need.
//                    var colorList = [
//                        '#FF0000','#46A3FF','#00DB00'
//                    ];
//
//                    if(params.series.data[params.dataIndex]<=3)
//                        return colorList[2];
//                    if(params.series.data[params.dataIndex]>3 && params.series.data[params.dataIndex]<=5)
//                        return colorList[1];
//                    if(params.series.data[params.dataIndex]>5)
//                        return colorList[0];
//                },
//                label : {
//                    show: true,
//                    position: 'inside',
//                    formatter: '{c}天'
//                }
//            }
//        };
//
//        $scope.chartConfig = {
//            title : {
//                text: '所有任务处理时效'
//            },
//            tooltip : {
//                show:false
//            },
//            legend: {
//                data:[]
//            },
//            grid: {
//                borderColor: 'rgba(0,0,0,0)'
//
//            },
//            toolbox: {
//                show : false
//            },
//            aaxis: {
//                axisLine : {
//                    show: false
//                }
//            },
//            xAxis : [
//                {
//                    show:false,
//                    type : 'value'
//                }
//            ],
//            yAxis : [
//                {
//                    type : 'category',
//                    splitLine: {show: false},
//                    axisTick : {show: false},
//                    axisLine: {
//                        show: false
//                    }
//                }
//            ],
//            series : [
//                {
//                    name:'2011年',
//                    itemStyle : dataStyle,
//                    type:'bar'
//                }
//            ]
//        };

        $scope.chartConfig =  {
            title : {
                text: '漏斗图',
                subtext: '纯属虚构'
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c}%"
            },
            toolbox: {
                show : false
            },
            legend: {
                data : ['展现','点击','访问','咨询','订单']
            },
            calculable : false,
            series : [
                {
                    name:'漏斗图',
                    type:'funnel',
                    x: '10%',
                    y: 60,
                    y2: 60,
                    width: '80%',
                    min: 0,
                    max: 100,
                    minSize: '0%',
                    maxSize: '100%',
                    sort : 'descending',
                    gap : 10,
                    itemStyle: {
                        normal: {
                            borderColor: '#fff',
                            borderWidth: 1,
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            labelLine: {
                                show: false,
                                length: 10,
                                lineStyle: {
                                    width: 1,
                                    type: 'solid'
                                }
                            }
                        },
                        emphasis: {
                            borderColor: 'red',
                            borderWidth: 5,
                            label: {
                                show: true,
                                formatter: '{b}:{c}%',
                                textStyle:{
                                    fontSize:20
                                }
                            },
                            labelLine: {
                                show: true
                            }
                        }
                    }
                }
            ]
        };

//        $scope.chartConfig.yAxis[0].data = ['巴西','印尼','美国','印度','中国','世界人口(万)'];
//        $scope.chartConfig.series[0].data = [3, 5, 6, 4, 8, 10];
        $scope.chartConfig.series[0].data = [
            {value:60, name:'访问'},
            {value:40, name:'咨询'},
            {value:20, name:'订单'},
            {value:80, name:'点击'},
            {value:100, name:'展现'}
        ];
	}]);
</script>
</html>