(function () { 'use strict'; angular.module('core.service') .factory("Chart", Chart); function Chart(Utils) { return { circular: circular, histogram:histogram, pie:pie, lineChart:lineChart, lineChartDy:lineChartDy }; /** * 动态折线图 * @param title * @param legend * @param xAxis * @param yAxis * @param series * @param show * @param grid * @returns {{title: *, tooltip: {trigger: string}, legend: *, toolbox: {show: *, feature: {mark: {show: boolean}, dataView: {show: boolean, readOnly: boolean}, magicType: {show: boolean, type: string[]}, restore: {show: boolean}, saveAsImage: {show: boolean}}}, grid: *, calculable: boolean, xAxis: *, yAxis: *, series: *}} */ function lineChartDy(title,legend,xAxis,yAxis,series,show,grid,tooltip){ return { title: title, tooltip: tooltip, legend: legend, toolbox: { show: show, feature: { mark: {show: true}, dataView: {show: true, readOnly: false}, magicType: {show: true, type: ['line', 'bar']}, restore: {show: true}, saveAsImage: {show: true} } }, grid:grid, calculable: true, xAxis: xAxis, yAxis: yAxis, series: series }; } /** * 折线图 * @param title 图表题目 * @param legend 图例显示 * @param xAxis 横向显示 * @param yAxis 纵向显示 * @param series 数据 */ function lineChart(title,legend,xAxis,yAxis,series,show,grid){ return { title: title, tooltip: { trigger: 'axis' }, legend: legend, toolbox: { show: show, feature: { mark: {show: true}, dataView: {show: true, readOnly: false}, magicType: {show: true, type: ['line', 'bar']}, restore: {show: true}, saveAsImage: {show: true} } }, grid:grid, calculable: true, xAxis: xAxis, yAxis: yAxis, series: series }; } //和弦图 function circular(title,legend,series) { return { title : title, animationDurationUpdate: 1500, animationEasingUpdate: 'quinticInOut', //tooltip : { // trigger: 'item', // formatter: function (params) { // if (params.indicator2) { // is edge // return params.indicator + ' ' + params.name + ' ' + params.indicator2; // } else { // is node // return params.name; // } // } //}, tooltip : { trigger: 'item', backgroundColor: 'rgba(255,255,255,0.85)', extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);', borderColor:'#FFF', borderRadius: 0, textStyle:{ color:'#666666', extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);' }, formatter: function (params) { if (!Utils.isBlank(params.data.source)) { return params.data.source + params.data.name + params.data.target; } return params.data.ip; } }, legend: legend, series : series }; } //柱状图 function histogram(title,legend,xAxis,yAxis,series) { return { title: title, tooltip: { trigger: 'axis' }, legend: legend, toolbox: { show: true, feature: { mark: {show: true}, dataView: {show: true, readOnly: false}, magicType: {show: true, type: ['line', 'bar']}, restore: {show: true}, saveAsImage: {show: true} } }, calculable: true, xAxis:xAxis, yAxis: yAxis, series: series }; } //饼图 function pie(title, legend, color,series) { return { title : title, tooltip : { trigger: 'item', formatter: "{a}
{b} : {c} ({d}%)" }, legend: legend, color: color, //grid:grid, series :series }; } } })();