小程序Echarts设置像素比后tooltips不显示

设置完像素比就不正常,不设置像素比就正常,可以使用tooltips!!设置完像素比就不正常,不设置像素比就正常,可以使用tooltips!!设置完像素比就不正常,不设置像素比就正常,可以使用tooltips!!设置完像素比就不正常,不设置像素比就正常,可以使用tooltips!!

img

你试试这个能用不

import * as echarts from '../ec-canvas/echarts';
const app = getApp();
let chart;

function initChart(canvas, width, height, dpr) {
  chart = echarts.init(canvas, null, {
    width: width,
    height: height,
    devicePixelRatio: dpr // new
  });
  canvas.setChart(chart);

  chart.setOption(option);
  return chart;
}
var option = {
  title: {
    text: '智酷君 echarts 切换效果测试',
    left: 'center'
  },
  tooltip: {
      trigger: 'item',
      formatter: '{a} <br/>{b}: {c} ({d}%)'
  },
  legend: {
      orient: 'vertical',
      left: 10,
      data: ['AAA', 'BBB', 'CCC', 'DDD', 'EEE']
  },
  series: [
      {
          name: '访问来源',
          type: 'pie',
          radius: ['50%', '70%'],
          avoidLabelOverlap: false,
          label: {
              show: false,
              position: 'center'
          },
          emphasis: {
              label: {
                  show: true,
                  fontSize: '30',
                  fontWeight: 'bold'
              }
          },
          labelLine: {
              show: false
          },
          data: [
              {value: 335, name: 'AAA'},
              {value: 310, name: 'BBB'},
              {value: 234, name: 'CCC'},
              {value: 135, name: 'DDD'},
              {value: 1548, name: 'EEE'}
          ]
      }
  ]
};

Page({
  data: {
    ec: {
      onInit: initChart
    }
  },
  onLoad: function () {},
  //单曲线
  line() {
    let option2 = {
      title: {
        text: '同一canvas更新成折线图',
        left: 'center'
      },
      xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
      },
      yAxis: {
        type: 'value'
      },
      series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line'
      }]
    };
    chart.setOption(option2)
  },
  //切换柱状图
  bar(){
    let option3 = {
      title: {
        text: '直接更新数据,减少性能消耗',
        left: 'center'
      },
      xAxis: {
          type: 'category',
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
      },
      yAxis: {
          type: 'value'
      },
      series: [{
          data: [120, 200, 150, 80, 70, 110, 130],
          type: 'bar',
          showBackground: true,
          backgroundStyle: {
              color: 'rgba(220, 220, 220, 0.8)'
          }
      }]
    };
    chart.setOption(option3)
  }
})