Echarts折线图 炫酷实现y轴自定义色阶
2017-11-25 11:14
357 查看
介于上一次本菜鸟的代码过low,现在更新,可能还是low,望见谅
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> html, body { width: 100%; height: 100%; background-color: gray; } #myChart { width: 80%; height: 70%; position: fixed; top: 15%; left: 10%; } </style> <script src="js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script> <script src="echarts3.2.2/echarts.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(function () { var myColor = ['#45fda5', '#3ffd55', '#11da01', '#118b43', '#c3eb18', '#dfde14', '#eac736', '#ed5501', '#9d0700', '#e80c00' ]; var option = { backgroundColor: 'black', grid: { top: 15, left: 15, right: 15, bottom: 15, containLabel: true //轴上的数值 }, xAxis: { type: 'category', splitLine: false, boundaryGap: false, axisLine: { show: false, lineStyle: { color: myColor[0] } }, axisTick: { lineStyle: { color: myColor[0] } }, data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] }, yAxis: { type: 'value', min: 0, splitLine: false, axisLine: { show: false }, axisTick: { show: false }, interval: 10, axisLabel: { formatter: function (value) { return value + " 个 -"; }, textStyle: { color: function (value) { //注意:当值大于999(三位)时,会以“1,0000”形式,所以要做以下处理 value = parseInt(value.replace(/,/g, "")); var idx = parseInt(value / 10); ad2f return myColor[idx > 9 ? 9 : idx]; } } } }, visualMap: { show: false, calculable: true, min: 0, max: 100, inRange: { color: [myColor[0], myColor[1], myColor[2], myColor[3], myColor[4], myColor[5], myColor[6], myColor[7], myColor[8], myColor[9]] } }, tooltip: { trigger: 'axis', axisPointer: { label: { textStyle: { color: "white" } } } }, series: [{ name: '人', type: 'line', symbol: 'none', //这句就是去掉折线上的点的 smooth: true, //这句就是让曲线变平滑的 hoverAnimation: true, lineStyle: { normal: { width: 5 } }, itemStyle: { normal: { opacity: 0 } }, data: [54, 86, 46, 45, 77, 96, 89, 88, 23, 38, 3, 66, 98, 43, 73, 76, 44, 16, 21, 14, 71, 8, 61, 65, 1, 68, 33, 69, 49, 24 ] }] }; var myChart = echarts.init($("#myChart").get(0));//get()方法作用:将jQuery对象转Dom对象 myChart.setOption(option); }); </script> </head> <body> <div id="myChart"></div> </body> </html>
相关文章推荐
- Android 自定义View,实现折线图
- 使用 Kotlin 实现自定义 LayoutManager + ItemTouchHelper 实现炫酷卡片布局
- 实现炫酷的获取本地图片和相机拍照图片-自定义组件
- echarts折线图有两个图例时如何实现分别采用两个不同单位的y轴
- android自定义View,实现折线图(一)
- 自定义Toast实现各种炫酷效果
- Echarts实现折线图随时刻动态加载
- Android自定义View实现支付宝支付成功-极速get花式Path炫酷动画
- 基于SpringMVC框架使用ECharts3.0实现折线图,柱状图,饼状图,的绘制(上篇)
- 实现炫酷的获取本地图片和相机拍照图片-自定义组件
- Echarts3.0+JavaWeb+Mysql实现饼图,折线图,柱状图
- echarts多条折线图和柱状图实现
- 基于SpringMVC框架使用ECharts3.0实现折线图,柱状图,饼状图,的绘制(上篇)
- Android使用自定义View继承SurfaceView实现动态折线图的绘制
- Android自定义PopupWindow实现炫酷的IOS对话框效果
- Android 自定义View,实现折线图
- Android使用自定义View继承SurfaceView实现动态折线图的绘制
- eCharts添加自定义geojson数据实现地图展示
- 自定义View实现炫酷进度条
- eCharts添加自定义geojson数据实现地图展示