GithubHelp home page GithubHelp logo

echarts's People

Contributors

kelichao avatar

Watchers

 avatar  avatar

echarts's Issues

标准版饼图配置方式

default

var a = [{name:"地方政府债",value:40},{name:"商业银行债",value:2},{name:"国债", value:60}]
var b = ["地方政府债", "商业银行债", "国债"]


option = {

	chart: {
		// 类型饼图
	    type: "pie"
	},
	// 鼠标上移的tip提示框
	tooltip: {
	    trigger: "item",
	    // 设置提示框的文案格式
	    formatter: "{b} : {c} 个({d}%)",
           // 调整tip框的位置,防止空间不够一直在抖动
           // 而且参数可以传数组当对象
            position: function([x, y]) {
                    return [x-200,y]; 
            },
	},
	// 小标签位置
	legend: {
	 	// 小标签排列方向 水平:'horizontal'  垂直:'vertical'
	    orient: "vertical",
	    // 坐标
	    x: "20",
	    y: "center",
	    data: b
	},
	series: [{
	    name: "访问来源",
	    type: "pie",
	    // 大小扇形
	    //roseType:"radius",
	    // 最小角度
	    minAngle: 20,
	    data: a,
	    // 直径与容器短边的比值
	    radius: "85%",
	    // 圆心对于容器的相对位置
	    center: ["50%", "55%"],
	    itemStyle: {
	    	// 一般情况下饼图上显示的文案
	        normal: {
	            label: {
	                position: "inner",
	                show: !0,
	                formatter: function(total) {
	                    return (total.percent - 0).toFixed(0) + "%"
	                },
	                textStyle: {
	                    color: "#ffffff"
	                }
	            },
	            labelLine: {
	                show: !1
	            }
	        },
	        // 鼠标上浮时候饼图上显示的文案
	        emphasis: {
	            label: {
	                show: !0,
	                formatter: function(total) {
	                    return (total.percent - 0).toFixed(0) + "%"
	                }
	            }
	        }
	    }
	}]
};

// 初始化图表插件,传入一个载体dom元素
var myChart = echarts.init(document.getElementById("cont")) ;
// 传入设置好的参数
myChart.setOption(option, true);

标准版的echarts使用方式

echarts2最简单配置

image

<div id="cont" class="cont" style="width:700px;height:400px"></div> 
<script type="text/javascript" src="./echarts-all.js"></script>
<script type="text/javascript">
	option = {
		// 颜色列表,注意,这里如果线条比较多,则会重复
		color:["#6ca5ed","#ff7f50"],
		// 标题
	    title : {
	        text: '未来一周气温变化',
	        // 小标题
	        subtext: '纯属虚构'
	    },
	    // 鼠标悬浮标签 根据纵坐标是:axis,根据坐标点是:item
	    tooltip : {
	        trigger: 'axis'
	    },
	    // 标签类目
	    legend: {
	        data:['最高气温','最低气温']
	    },
	    // 表格在容器内部的内边距,效果类似padding
	    grid: {
	    	x: 50,
	        x2: 50            
	    },
	    // 工具栏这个一般不需要
	    toolbox: {
	    	// 隐藏
	        show : false,
	        feature : {
	            mark : {show: true},
	            dataView : {show: true, readOnly: false},
	            magicType : {show: true, type: ['line', 'bar']},
	            restore : {show: true},
	            saveAsImage : {show: true}
	        }
	    },
	    // 是否拖拽重计算,这个也比较多余
	    calculable : false,
	    // x轴配置
	    xAxis : [
	        {
	            type : 'category',
	            boundaryGap : false,
	            data : ['周一','周二','周三','周四','周五','周六','周日']
	        }
	    ],
	    // y轴配置
	    yAxis : [
	        {
	            type : 'value',
	            axisLabel : {
	                formatter: '{value} °C'
	            }
	        }
	    ],
	    // 主数据
	    series : [
	        {
	            name:'最高气温',
	            // 图画类型
	            type:'line',
	            data:[11, 11, 15, 13, 12, 13, 10],
	            // 标注点
	            markPoint : {
	                data : [
	                    {type : 'max', name: '最大值'},
	                    {type : 'min', name: '最小值'}
	                ]
	            },
	            // 标注线
	            markLine : {
	                data : [
	                    {type : 'average', name: '平均值'}
	                ]
	            }
	        },
	        // 多条线分割
	        {
	            name:'最低气温',
	            type:'line',
	            data:[1, -2, 2, 5, 3, 2, 0],
	            markPoint : {
	                data : [
	                    {name : '周最低', value : -2, xAxis: 1, yAxis: -1.5}
	                ]
	            },
	            markLine : {
	                data : [
	                    {type : 'average', name : '平均值'}
	                ]
	            }
	        }
	    ]
	};

	// 初始化图表插件,传入一个载体dom元素
	var myChart = echarts.init(document.getElementById("cont")) ;
	// 传入设置好的参数
	myChart.setOption(option, true);
</script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.