桑吉图

作者: 小北呀_ | 来源:发表于2019-11-26 10:14 被阅读0次

如图:


image.png
鼠标悬浮
1.echarts 下载
npm install echarts --save
2.main.js引入 echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
3.页面代码:
<template>
  <div>
     <div style="width: 300px;height: 300px;" id="chart"></div>
  </div>
</template>
<script>
    export default {
        name: '',
        data() {
            return {
            }
        },
        created() {
            this.$nextTick(() => {
                let sangjiOption = {
                    label:{
                        color: '#fff',
                    },
                    //悬浮显示
                    tooltip: {
                        trigger: 'item',
                        triggerOn: 'mousemove'
                    },
                    series: {
                        type: 'sankey',
                        left:10,
                        right:20,
                        bottom:0,
                     //   控制页面显示/隐藏 A1
                     /*   label:{
                            show:false
                        },*/
                        layout:'none',
                        focusNodeAdjacency: 'allEdges',
                        data: [],
                        links: [],
                        itemStyle: {
                            normal: {
                                //渠道没有数据时候0,线条样式
                                borderWidth: 1,
                                borderColor: '#aaa'
                            }
                        },
                        lineStyle: {
                            normal: {
                                color: 'source',
                                curveness: 0.5
                            }
                        }
                    }
                }
                let color_list = [
                    {
                        name: 'A1', itemStyle: {color: 'pink'},
                    },
                    {
                        name: 'A2',itemStyle: {color: 'pink'},
                    },
                    {
                        name: 'A3',itemStyle: {color: 'pink'},
                    },
                    {
                        name: 'B1',itemStyle: {color: 'red'},
                    },
                    {
                        name: 'B2',itemStyle: {color: 'red'},
                    },
                    {
                        name: 'B3',itemStyle: {color: 'red'},
                    },
                ]
                let data_list = [
                    {
                        source: 'A1',
                        target: 'A2',
                        value: 1
                    },
                    {
                        source: 'B1',
                        target: 'B2',
                        value: 2
                    },
                    {
                        source: 'A2',
                        target: 'A3',
                        value:2
                    },
                    {
                        source: 'B2',
                        target: 'B3',
                        value: 1
                    },
                ]
                sangjiOption.series.data = color_list
                sangjiOption.series.links = data_list
                let myChart = this.$echarts.init(document.getElementById('chart'));
                myChart.setOption(sangjiOption)
            })
        },
        methods: {

        }
    }
</script>

越简单的例子越能看清本质。复制代码可自行修改。
举例:A2的高度其实是相邻value的值相加,自动算出来的。

相关文章

  • 桑吉图

    如图: 1.echarts 下载 2.main.js引入 echarts 3.页面代码: 越简单的例子越能看清本...

  • 冲积图和桑吉图的比较

    图1是冲积图,图2室桑吉图。 冲积图(Alluvial plot):(左右没有先后顺序,不存在箭头表示先后,左右的...

  • sankey绘制方法(待更新图)

    基于excel Power BI工具制作Saneky(桑吉图)的教程 2019-11-1 基础条件:自用电脑,需要...

  • 相见-桑吉平措

    相见-桑吉平措,感恩有机会与大家遇见中国梵呗音乐第一人桑吉平措,我们值得学习的典范。 桑吉平措, 原名王秋翔,汉族...

  • 相片

    桑吉平措影集

  • 第五章 战术制定

    桑吉带着竹书天来到他的住处,一个类似于地堡的地方。 他没有看到桑吉的母亲,其实刚才所有人都问桑吉讨债就可以知道...

  • 桑吉沉没

    最不愿见到的一幕还是出现了,巴拿马籍油船“桑吉”轮(SANCHI)燃烧了八天后沉没东海。 央视消息,1月14日12...

  • 归来仍是少年

    认识桑吉是偶然在路途上。 他一个人,我也一个人。 桑吉很黑、我笑他是不是常年爱吃黑豆。 桑吉总是笑着他的白牙、没有...

  • 181222图桑.图桑

    快晚上了,到达目的地图桑。 很喜欢教堂的建筑,所以每到一个地方,都要去看看当地的教堂。教堂的建筑很有意思,如果你走...

  • 桑基图怎么看怎么画(附R代码)

    什么是桑基图 桑基图(Sankey diagram),即桑基能量分流图,也叫桑基能量平衡图。它是一种特定类型的流程...

网友评论

      本文标题:桑吉图

      本文链接:https://www.haomeiwen.com/subject/tvqewctx.html