关于插件echarts

图片描述

这个是鼠标移进去的效果,但是我想进入页面的时候就有这个默认效果怎么弄,大神们!

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- 引入 echarts.js -->
<script src="echarts.js"></script>
</head>

<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 335px;height:325px;"></div>
<script type="text/javascript">

// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));

// 指定图表的配置项和数据

option = {
  tooltip: {
    trigger: 'item'
  },
  series: [{
      name: '学校录取信息',
      type: 'pie',
      radius: ['45%', '70%'],
      avoidLabelOverlap: false,
      label: {
        normal: {
          show: false,
          position: 'center'
        },
        emphasis: {
          show: true,
          textStyle: {
            fontSize: '14',
            fontWeight: 'bold'
          }
        }
      },
      labelLine: {
        normal: {
          show: false
        }
      },
      data: [{
          value: 335,
          name: '直接访问'
        },
        {
          value: 310,
          name: '邮件营销'
        },
        {
          value: 234,
          name: '联盟广告'
        },
        {
          value: 135,
          name: '视频广告'
        },
        {
          value: 1548,
          name: '搜索引擎'
        }
      ]
    },
    {
      name: 'radial gradient',
      type: 'pie',
      radius: '70%',
      avoidLabelOverlap: false,
      itemStyle: {
        normal: {
          color: {
            type: 'radial',
            x: 0.5,
            y: 0.5,
            r: 0.5,
            colorStops: [{
              offset: 0,
              color: 'rgba(255,255,255,0)'
            }, {
              offset: 0.55,
              color: 'rgba(255,255,255,0.5)'
            }, {
              offset: 0.65,
              color: 'rgba(255,255,255,0.5)'
            }, {
              offset: 0.95,
              color: 'rgba(255,255,255,0)'
            }],
            globalCoord: false
          }
        }
      },
      silent: true,
      z: 999,
    }
  ]
};


// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);

</script>
</body>

</html>

阅读 1.9k
1 个回答
var index = 0;//数据的第几个显示
//高亮图形
myChart.dispatchAction({
  type: 'highlight',
  seriesIndex: 0,
  dataIndex: index 
});
// 显示 tooltip
myChart.dispatchAction({
  type: 'showTip',
  seriesIndex: 0,
  dataIndex: index 
});        
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题