echarts几种图表应用

柱形图

const xData: ["收录信息1", 收录信息2", "收录信息3", "收录信息4"],
const  legendData: [
      {
        name: "未读",
        num: 25,
        rate: "25%"
      },
      {
        name: "已读",
        num: 75,
        rate: "75%"
      }
    ]
const option = {
      tooltip: {
        trigger: "axis",
        axisPointer: {
          // 坐标轴指示器,坐标轴触发有效
          type: "shadow" // 默认为直线,可选为:'line' | 'shadow'
        }
      },
      legend: {
        orient: "vertical",
        top: "3%",
        right: "0%",
        itemWidth: 12,
        itemHeight: 12,
        textStyle: {
          color: "rgba(0,0,0,.85)",
          fontSize: 14
        },
        // data: legendData,
        formatter: function(name) {
          let num = 0;
          legendData.map((i) => {
            if (name == i.name) {
              num = i.num;
            }
          });
          // console.log(name)
          return "{a|" + name + "}" + " " + "{b|" + num + "条" + "}" + " " + "{b|" + num + "%" + "}";
        },
        textStyle: {
          color: "#000",
          fontSize: 14,
          lineHeight: 18,
          rich: {
            a: {
              fontSize: 14,
              // fontWeight: 400,
              color: "#000",
              lineHeight: 14
            },
            b: {
              fontSize: 14,
              // fontWeight: "bold",
              color: "#737373",
              lineHeight: 14
            }
          }
        }
      },
      grid: {
        //图表的位置
        top: "25%",
        left: "8%",
        right: "15%",
        bottom: "11%"
      },
      yAxis: [
        {
          name: "总数(条)",
          nameTextStyle: {
            color: "rgba(0,0,0,0.65)"
          },
          type: "value",
          axisLabel: {
            show: true,
            color: "rgba(0,0,0,.45)",
            interval: "auto",
            formatter: "{value} "
          },
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          },
          splitLine: {
            lineStyle: {
              color: "#e7eaf0",
              type: "dashed"
            }
          },
          show: true
        }
      ],
      xAxis: [
        {
          name: "公告类型",
          nameTextStyle: {
            color: "rgba(0,0,0,0.65)"
          },
          type: "category",
          axisTick: {
            show: false
          },
          axisLine: {
            lineStyle: {
              color: "#e7eaf0"
            }
          },
          axisLabel: {
            interval: 0,
            show: true,
            textStyle: {
              fontSize: 12,
              color: "#000"
            }
          },
          data: xData
        }
      ],
      series: [
        {
          name: "已读",
          type: "bar",
          stack: "sum",
          barWidth: "20px",
          data: hasRead,
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 1,
                  color: "#3295FF"
                },
                {
                  offset: 0,
                  color: "#81BEFF"
                }
              ])
            }
          }
        },
        {
          name: "未读",
          type: "bar",
          barWidth: "20px",
          stack: "sum",
          itemStyle: {
            normal: {
              barBorderRadius: [2, 2, 0, 0],
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 1,
                  color: "#FFC53E"
                },
                {
                  offset: 0,
                  color: "#FFF88F"
                }
              ])
            }
          },
          data: noRead
        }
      ]
    };

在这里插入图片描述

饼状图

var data = [
{
        name: '2018级',
        value: 255,
        itemStyle: {
          normal: { //颜色渐变
            color: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [{
                offset: 0,
                color: '#81BEFF',
              },
              {
                offset: 1,
                color: '#3295FF',
              }
              ]
            )
          }
        }
      },
      {
        name: '2019级',
        value: 103,
        itemStyle: {
          normal: { //颜色渐变
            color: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [{
                offset: 0,
                color: '#FECC84',
              },
              {
                offset: 1,
                color: '#FF983E',
              }
              ]
            )
          }
        }
      },
      {
        name: '2020级',
        value: 80,
        itemStyle: {
          normal: { //颜色渐变
            color: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [{
                offset: 0,
                color: '#70F3C2',
              },
              {
                offset: 1,
                color: '#48D69E',
              }
              ]
            )
          }
        }
      },
      {
        name: '2021级',
        value: 33,
        itemStyle: {
          normal: { //颜色渐变
            color: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [{
                offset: 0,
                color: '#9F9BFF',
              },
              {
                offset: 1,
                color: '#826CFF',
              }
              ]
            )
          }
        }
      }
];

const option = {
      tooltip: {
        trigger: 'item',
        formatter: '{b} : {c} ({d}%)'
      },
      legend: {
        orient: "vertical",
        // right: "10%",
        left: "60%",
        top: "25%",
        itemWidth: 12,
        itemHeight: 12,
        textStyle: {
          fontSize: 14,
          lineHeight: 18,
        }
      },
      series: [
        {
          type: 'pie',
          data: data,
          label: {
            show: false
          },
          radius: ["0%", "60%"],
          center: ['30%', '50%'],
          itemStyle: {
            borderWidth: 2,
            borderColor: "#fff"
          },
        }
      ]
    };

在这里插入图片描述

进度条圆环

var value = {"name":"在用课程数","rat": 45,"num":5326};
option = {
    backgroundColor: '#fff', //背景颜色
    title: [  //标题显示
        {
            text: value["rat"] + '%',
            subtext: value["name"],
            left: "center",
            top: "43%",
            textStyle: {
              fontSize: 50,
              color: '#397EF0',
            },
            subtextStyle: {
              fontSize: 30,
              color: '#000',
            }
          }
    ],
    legend:{
        orient: 'vertical',
        right: 200,
        top: 500,
        formatter: function (v) {
            // console.log(v)
            return  v +' '+ value["rat"]+'%';
        },
    },
    polar: {  //圆环显示
        radius: ['40%', '35%'],
        center: ['50%', '50%'],
    },
    angleAxis: {
        max: 100,
        // clockwise: false, //刻度增长是否按顺时针
        axisLine: {
            show: false,
        },
        axisTick: {
            show: false,
        },
        axisLabel: {
            show: false,
        },
        splitLine: {
            show: false,
        },
    },
    radiusAxis: {  //极坐标系的径向轴
        type: 'category',
        // show: true,
        // axisLabel: {
        //     show: false,
        // },
        axisLine: {
            show: false,
        },
        // axisTick: {
        //     show: false,
        // },
    },
    series: [
        {
            type: 'pie',
            radius: [0, '30%'],
            animation : false,
            itemStyle: {
                normal: {
                    color: '#EAF1FD',
                    
                }
            },
            silent: true, //图形是否不响应和触发鼠标事件
            label: {
                show: false
            },
            data: [100]
        },
        
        {
            name: value["name"],
            type: 'bar',
            roundCap: true,
            //  animation : false,
            z: 2,
            showBackground: true,
            backgroundStyle: {
                color: '#EAF1FD',
            },
            data: [value["rat"]],
            coordinateSystem: 'polar',
            itemStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, .5, 1, [
                        {
                            offset: 0,
                            color: '#3295FF',
                        },
                        {
                            offset: 1,
                            color: '#81BEFF',
                        },
                    ]),
                },
            },
        },
    ],
};

在这里插入图片描述

进度条

···
option = {
grid: {
left: ‘5%’,
right: ‘5%’,
bottom: ‘5%’,
top: ‘10%’,
containLabel: true,
},
// backgroundColor: ‘#101129’,
xAxis: {
show: false,
type: ‘value’,
max: 1520,
},
yAxis: [
{
type: ‘category’,
inverse: true,
axisLabel: {
show: true,
textStyle: {
fontSize: ‘12’,
color: ‘#03fcfe’,
},
},
splitLine: {
show: false,
},
axisTick: {
show: false,
},
axisLine: {
show: false,
},
},
{
type: ‘category’,
inverse: true,
axisTick: ‘none’,
axisLine: ‘none’,
show: true,
data: [1520],
},
],
series: [
{
type: ‘bar’,
showBackground: true,
backgroundStyle: {
color: ‘rgba(231,234,240,0.45)’,
borderRadius:10
},
label:{
show:true,
position:‘right’,
padding: [3,0,0,-35],
formatter:’{@score}’,
textStyle: {
color: ‘#fff’,
fontSize: ‘12’,
},
verticalAlign: “middle”
},
itemStyle: {
normal: {
barBorderRadius: 10,
color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{
offset: 0,
color: ‘#4EE7F9’,
},
{
offset: 1,
color: ‘#3295FF’,
},
]),
},
},
barWidth: 20,
data: [500],
},
],
};
···
在这里插入图片描述

地图

const option = {
            tooltip: {
                trigger: 'item'
            },
            visualMap: {
                min: 0,
                max: 2500,
                left: 'left',
                top: 'bottom',
                text: ['高', '低'],           // 文本,默认为数值文本
                calculable: false,
                left: 10,
                itemWidth: 8,
                itemHeight: 60,
                color: ['#7babfb', '#e1eeff']
            },
            series: [
                {
                    name: '各省**分布',
                    type: 'map',
                    mapType: 'china',
                    roam: false,
                    emphasis: {
                        label: {
                            show: true,
                            color:"#fff",
                        },
                        itemStyle:{
                          areaColor:"#315b9b"  
                        }
                    },
                    itemStyle: {
                        borderColor: "#fff"
                    },
                    data: [
                        { name: '北京', value: Math.round(Math.random() * 1000) },
                        { name: '天津', value: Math.round(Math.random() * 1000) },
                        { name: '上海', value: Math.round(Math.random() * 1000) },
                        { name: '重庆', value: Math.round(Math.random() * 1000) },
                        { name: '河北', value: Math.round(Math.random() * 1000) },
                        { name: '河南', value: Math.round(Math.random() * 1000) },
                        { name: '云南', value: Math.round(Math.random() * 1000) },
                        { name: '辽宁', value: Math.round(Math.random() * 1000) },
                        { name: '黑龙江', value: Math.round(Math.random() * 1000) },
                        { name: '湖南', value: Math.round(Math.random() * 1000) },
                        { name: '安徽', value: Math.round(Math.random() * 1000) },
                        { name: '山东', value: Math.round(Math.random() * 1000) },
                        { name: '新疆', value: Math.round(Math.random() * 1000) },
                        { name: '江苏', value: Math.round(Math.random() * 1000) },
                        { name: '浙江', value: Math.round(Math.random() * 1000) },
                        { name: '江西', value: Math.round(Math.random() * 1000) },
                        { name: '湖北', value: Math.round(Math.random() * 1000) },
                        { name: '广西', value: Math.round(Math.random() * 1000) },
                        { name: '甘肃', value: Math.round(Math.random() * 1000) },
                        { name: '山西', value: Math.round(Math.random() * 1000) },
                        { name: '内蒙古', value: Math.round(Math.random() * 1000) },
                        { name: '陕西', value: Math.round(Math.random() * 1000) },
                        { name: '吉林', value: Math.round(Math.random() * 1000) },
                        { name: '福建', value: Math.round(Math.random() * 1000) },
                        { name: '贵州', value: Math.round(Math.random() * 1000) },
                        { name: '广东', value: Math.round(Math.random() * 1000) },
                        { name: '青海', value: Math.round(Math.random() * 1000) },
                        { name: '西藏', value: Math.round(Math.random() * 1000) },
                        { name: '四川', value: Math.round(Math.random() * 1000) },
                        { name: '宁夏', value: Math.round(Math.random() * 1000) },
                        { name: '海南', value: Math.round(Math.random() * 1000) },
                        { name: '台湾', value: Math.round(Math.random() * 1000) },
                        { name: '香港', value: Math.round(Math.random() * 1000) },
                        { name: '澳门', value: Math.round(Math.random() * 1000) }
                    ]
                },

            ]
        };

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: ASP.NET是一个基于Web的应用程序开发平台,支持多种编程语言和开发工具。随着Web应用程序的发展,数据可视化变得越来越重要,ECharts是一个非常流行的数据可视化库。 使用ECharts绘制图表需要几个步骤。首先,在ASP.NET项目中添加ECharts库,并在需要绘制图表的页面中引入相关的JavaScript文件和CSS。 然后,我们需要编写JavaScript代码来配置图表。这包括定义图表的类型、数据来源、样式和其他样式选项。可以在ECharts官网上找到各种类型的图表示例和文档,作为参考和指导。 最后,将图表渲染到HTML页面中。可以使用ECharts提供的API来将图表插入到指定的HTML元素中。 除了基本的图表绘制功能,ECharts还提供了一些高级的特性,如数据驱动的图形变化、交互式数据探索、闪烁式动画效果等。这些特性可以进一步增强数据可视化的效果,为用户提供更好的数据分析和理解能力。 在ASP.NET应用程序中使用ECharts绘制图表可以使数据更好地呈现出来,为用户提供更好的数据可视化效果。这对于数据分析、报表和决策支持等方面都非常有帮助。 ### 回答2: ASP.NET是一个强大的Web应用程序框架,可以让开发者使用各种技术(如HTML、CSS、JavaScript等)来构建高效的Web应用程序。而ECharts则是一款极其强大的JavaScript图表库,可以在Web应用程序中呈现各种类型的图表,如折线图、柱状图、饼图、雷达图等等。 在ASP.NET中使用ECharts绘制图表非常简单,只需要引入ECharts的JavaScript文件,并编写一些JavaScript代码即可实现想要的图表效果。ASP.NET中的ECharts使用采用前端渲染的方式,将图表的数据和样式信息通过JSON格式传递给浏览器,由浏览器进行渲染,从而实现对数据的可视化。开发者可以通过ECharts提供的丰富的API来自定义图表样式,如更改颜色、字体、标签等。 在ASP.NET中使用ECharts的主要优点是能够快速实现数据可视化,使得开发者可以更直观地了解数据的特点,从而更快速地做出决策。同时,ECharts还支持对移动设备的适配,可以在不同设备上实现合适的图表展示效果。 总之,ASP.NET结合ECharts可以让开发者更便捷地实现数据可视化,展示出更直观的数据结果,帮助用户更好地了解和处理数据。 ### 回答3: asp.net echarts是一种非常强大的数据可视化组件,可以在asp.net网页中轻松地绘制各种图表,包括折线图、柱状图、饼状图、散点图等。由于asp.net echarts使用简单方便,所以很受开发者的喜爱。 想要在asp.net网页中使用echarts绘制图表,需要先准备好echarts库和所需的数据。可以通过引入echarts.js文件和样式表,然后在网页中设置一个容器,用于显示echarts图表。接下来,可以通过JavaScript或jQuery编写代码,在容器中绘制不同类型的图表,并对其进行样式和交互的设置。 使用asp.net echarts绘制图表时,需要注意一些细节问题。例如在加载echarts库时需要注意版本兼容性,需要对数据进行合理的处理和格式化,还需要设置一些参数和方法,以达到更好的可视化效果。 总之,使用asp.net echarts可以快速轻松地实现数据可视化的需求,使数据更加直观、易于理解,有助于提高网页的用户体验,也有助于更好地展示数据分析的结果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值