推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
Afishtail

小程序使用 ECharts 画图表怎么动态的修改数据呀

  •  
  •   Afishtail · Jul 14, 2018 · 10732 views
    This topic created in 2885 days ago, the information mentioned may be changed or developed.

    后面会用到雷达图,如何下载了 echarts 组件后发现不会动态修改。。 之前做小程序一直是写 page 里的内容,引入这个组件真的有点懵。。复制下 js 代码。。求大神指点下 下面就是组件源码了,网上也有其他相关的,但是比较杂,代码格式也不太一样,echarts 这么写肯定有他道理。 import * as echarts from '../../ec-canvas/echarts';

    const app = getApp();

    function initChart(canvas, width, height) { const chart = echarts.init(canvas, null, { width: width, height: height }); canvas.setChart(chart);

    var option = { backgroundColor: "#ffffff", color: ["#37A2DA", "#FF9F7F"], tooltip: {}, xAxis: { show: false }, yAxis: {
    show: false }, radar: { // shape: 'circle', indicator: [{ name: '食品', max:500 }, { name: '玩具', max: 500 }, { name: '服饰', max: 500 }, { name: '绘本', max: 500 }, { name: '医疗', max: 500 }, { name: '门票', max: 500 } ] }, series: [{ name: '预算 vs 开销', type: 'radar', data: [{ value: [430, 340, 500, 300, 490, 400], name: '预算' }, { value: [300, 430, 150, 300, 420, 250], name: '开销' } ] }] };

    chart.setOption(option); return chart; }

    Page({ onShareAppMessage: function (res) { return { title: 'ECharts 可以在微信小程序中使用啦!', path: '/pages/index/index', success: function () { }, fail: function () { } } }, data: { ec: { onInit: initChart } },

    onReady() {

    } });

    4 replies    2018-07-14 21:20:59 +08:00
    rateltalk
        1
    rateltalk  
       Jul 14, 2018 via iPhone
    你去他的代码库看看案例,多看几遍
    momo1999
        2
    momo1999  
       Jul 14, 2018
    你找官方示例会动态改变的就行了
    des
        3
    des  
       Jul 14, 2018 via Android
    chart.setOption(option) 就完了,他会自动合并
    alvin666
        4
    alvin666  
       Jul 14, 2018 via Android
    二楼三楼正解,我就是改的官方 demo,自动合并数据
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2881 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 15:02 · PVG 23:02 · LAX 08:02 · JFK 11:02
    ♥ Do have faith in what you're doing.