@Kener-林峰 你好,想跟你请教个问题:请问如何在echarts中添加水印
在画布上画一个"开源中国",并将此画布盖在 echarts 之上,算不算水印?
<meta charset="utf-8"> <header> <style> #watermark{ position:absolute; left:0px; top:0px; } </style> </header> <body> <div id="main" style="height:400px"></div> <canvas id="watermark" width="400" height="400"></canvas> <script src="http://echarts.baidu.com/build/dist/echarts.js"></script> <script type="text/javascript"> require.config({ paths: {echarts: 'http://echarts.baidu.com/build/dist'} }); require([ 'echarts', 'echarts/chart/bar' ], function (ec) { var myChart = ec.init(document.getElementById('main')); var option = { tooltip: { show: true }, xAxis : [ { type : 'category', data : ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"] } ], yAxis : [ { type : 'value' } ], series : [ { "name":"销量", "type":"bar", itemStyle: { normal: { color: function(params) { var colorList=['#000000','#FF0000','#00FF00','#0000FF', '#FFFF00','#00FFFF','#FF00FF','#C0C0C0', '#808080','#800000','#808000','#008000', '#800080','#008080','#000080'], col = []; for (var i =0; i<option.series[0].data.length;i++) col[i] = parseInt(option.series[0].data[i]/10); return colorList[col[params.dataIndex]]; } }, }, "data":[5, 25, 38, 32, 12, 22] } ], }; myChart.setOption(option); } ); g=document.getElementById("watermark").getContext('2d'); g.fillStyle='lightgrey'; g.font="60px ARIAL BOLD"; s = ["开","源","中","国"]; for (var i=0; i<s.length;i++) g.fillText(s[i],100 + i*50,100 + i*50); </script> </body>
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
在画布上画一个"开源中国",并将此画布盖在 echarts 之上,算不算水印?