Flutter 图表之使用echart

261 阅读1分钟

使用插件:flutter_echarts

如果要使用echart里的词云功能(wordcloud),需要下载wordcloud的插件:github.com/ecomfe/echa…

把这里的js代码复制备用。

const wordCloudScript = r'''
///这里把 echarts-wordcloud.min.js 里的代码复制过来
''';

然后就可以使用了。

Echarts(
  extensions: const [wordCloudScript],
  option: 
'''
{
    series: [{
        type: 'wordCloud',
        shape: 'circle',
        left: 'center',
        top: 'center',
        width: '90%',
        height: '90%',
        sizeRange: [12, 60],
        rotationRange: [-90,0, 90],
        rotationStep: 90,
        gridSize: 8,
        drawOutOfBound: false,
        textStyle: {
            normal: {
                fontFamily: 'sans-serif',
                fontWeight: 'bold',
                color: function () {
                    return 'rgb(' + [
                        Math.round(Math.random() * 160),
                        Math.round(Math.random() * 160),
                        Math.round(Math.random() * 160)
                    ].join(',') + ')';
                }
            },
            emphasis: {
                shadowBlur: 10,
                shadowColor: '#333'
            }
        },
        data: $data
    }]
}
''';
),
///data是以键值对的形式,作为demo可以直接从echart里复制点数据用。