首页 > 其他分享 >柱状图(5)

柱状图(5)

时间:2024-02-08 13:33:05浏览次数:33  
标签:polar return -- 柱状图 2000 1500 data

案例1

<!--
	此示例下载自 https://echarts.apache.org/examples/zh/editor.html?c=bar-polar-real-estate
-->
<!DOCTYPE html>
<html lang="en" style="height: 100%">
<head>
  <meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
  <div id="container" style="width: 500px;height: 500px"></div>

  
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.4.3/files/dist/echarts.min.js"></script>
  <!-- Uncomment this line if you want to dataTool extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.4.3/files/dist/extension/dataTool.min.js"></script>
  -->
  <!-- Uncomment this line if you want to use gl extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts-gl/2/files/dist/echarts-gl.min.js"></script>
  -->
  <!-- Uncomment this line if you want to echarts-stat extension
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts-stat/latest/files/dist/ecStat.min.js"></script>
  -->
  <!-- Uncomment this line if you want to use map
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/4.9.0/files/map/js/china.js"></script>
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/4.9.0/files/map/js/world.js"></script>
  -->
  <!-- Uncomment these two lines if you want to use bmap extension
  <script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=YOUR_API_KEY"></script>
  <script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.4.3/files/dist/extension/bmap.min.js"></script>
  -->

  <script type="text/javascript">
    var dom = document.getElementById('container');
    var myChart = echarts.init(dom, null, {
      renderer: 'canvas',
      useDirtyRect: false
    });
    var app = {};
    
    var option;

    const data = [
  [5000, 10000, 6785.71],
  [4000, 10000, 6825],
  [3000, 6500, 4463.33],
  [2500, 5600, 3793.83],
  [2000, 4000, 3060],
  [2000, 4000, 3222.33],
  [2500, 4000, 3133.33],
  [1800, 4000, 3100],
  [2000, 3500, 2750],
  [2000, 3000, 2500],
  [1800, 3000, 2433.33],
  [2000, 2700, 2375],
  [1500, 2800, 2150],
  [1500, 2300, 2100],
  [1600, 3500, 2057.14],
  [1500, 2600, 2037.5],
  [1500, 2417.54, 1905.85],
  [1500, 2000, 1775],
  [1500, 1800, 1650]
];
// prettier-ignore
const cities = ['北京', '上海', '深圳', '广州', '苏州', '杭州', '南京', '福州', '青岛', '济南', '长春', '大连', '温州', '郑州', '武汉', '成都', '东莞', '沈阳', '烟台'];
const barHeight = 50;
option = {
  title: {
    text: 'text',
    subtext: 'text'
  },
  legend: {
    show: true,
    top: 'bottom',
    data: ['Range', 'Average']
  },
  grid: {
    top: 100
  },
  angleAxis: {
    type: 'category',
    data: cities
  },
  tooltip: {
    show: true,
    formatter: function (params) {
      const id = params.dataIndex;
      return (
        cities[id] +
        '<br>Lowest:' +
        data[id][0] +
        '<br>Highest:' +
        data[id][1] +
        '<br>Average:' +
        data[id][2]
      );
    }
  },
  radiusAxis: {},
  polar: {},
  series: [
    {
      type: 'bar',
      itemStyle: {
        color: 'transparent'
      },
      data: data.map(function (d) {
        return d[0];
      }),
      coordinateSystem: 'polar',
      stack: 'Min Max',
      silent: true
    },
    {
      type: 'bar',
      data: data.map(function (d) {
        return d[1] - d[0];
      }),
      coordinateSystem: 'polar',
      name: 'Range',
      stack: 'Min Max'
    },
    {
      type: 'bar',
      itemStyle: {
        color: 'transparent'
      },
      data: data.map(function (d) {
        return d[2] - barHeight;
      }),
      coordinateSystem: 'polar',
      stack: 'Average',
      silent: true,
      z: 10
    },
    {
      type: 'bar',
      data: data.map(function (d) {
        return barHeight * 2;
      }),
      coordinateSystem: 'polar',
      name: 'Average',
      stack: 'Average',
      barGap: '-100%',
      z: 10
    }
  ]
};

    if (option && typeof option === 'object') {
      myChart.setOption(option);
    }

    window.addEventListener('resize', myChart.resize);
  </script>
</body>
</html>
  • 效果图

标签:polar,return,--,柱状图,2000,1500,data
From: https://www.cnblogs.com/dogleftover/p/18011728

相关文章

  • 柱状图(4)
    案例1参考代码如下<!-- 此示例下载自https://echarts.apache.org/examples/zh/editor.html?c=dataset-encode0--><!DOCTYPEhtml><htmllang="en"style="height:100%"><head><metacharset="utf-8"></head......
  • 柱状图(3)
    案例1参考代码如下<!-- 此示例下载自https://echarts.apache.org/examples/zh/editor.html?c=bar1--><!DOCTYPEhtml><htmllang="en"style="height:100%"><head><metacharset="utf-8"></head><bo......
  • 柱状图(2)
    案例1参考代码如下<!-- 此示例下载自https://echarts.apache.org/examples/zh/editor.html?c=bar-y-category--><!DOCTYPEhtml><htmllang="en"style="height:100%"><head><metacharset="utf-8"></head&......
  • 柱状图(1)
    案例1参考代码如下<!-- 此示例下载自https://echarts.apache.org/examples/zh/editor.html?c=bar-simple--><!DOCTYPEhtml><htmllang="en"style="height:100%"><head><metacharset="utf-8"></head>......
  • pandas 绘图 拆线图 多条拆线 柱状图 横向 纵向 饼状图
    Pandas利用plot()调用Matplotlib快速绘制出数据可视化图形。注意,第一次使用plot()时可能需要执行两次才能显示图形。可以使用plot()快速绘制折线图。df['Q1'].plot()#Q1成绩的折线分布 可以先选择要展示的数据,再绘图。df.loc['Ben','Q1':'Q4'].plot()#ben四个季度的成绩......
  • echart 柱状图x轴悬浮显示文字
    两种方法:1.自带属性,自带样式;2.自定义样式renderBarChart(){//letthat=thisconstbarChart=echarts.init(document.getElementById('bar-chart'))constbarOptions={title:{//text:this.selectEchartData.label.le......
  • [LeetCode Hot 100] LeetCode84. 柱状图中最大的矩形
    题目描述思路:枚举+优化(单调栈)先固定矩阵的高。然后向左向右找到第一个比当前元素值小的元素,确定好左右边界。对于元素2来说:向左找到第一个比当前元素值小的元素:1的右边界向右找到第一个比当前元素值小的元素:3的右边界枚举每个元素的上边界,确定往左数最远到达哪个边界......
  • Highcharts 用SVGRenderer方法使柱状图连接列边​
    需求在Highcharts中,可以使用SVGRenderer方法来创建路径连接柱状图的列边,并根据具体的数据和需求进行适当的调整和扩展。分析要使用Highcharts的SVGRenderer方法来绘制柱状图并连接列边,可以按照以下步骤进行操作:创建柱状图:使用Highcharts的 chart 方法创建一个柱状图,并......
  • vue中echarts图表---正负轴柱状图
    一、安装npmiecharts--save二、引入//全局引入importechartsfrom'echarts'Vue.prototype.$echarts=echarts//局部【这里使用局部引入】importechartsfrom'echarts';三、代码1<!--容器-->2<divid="cylinderEcharts"ref="cyl......
  • 代码随想训练营第六十天(Python)| 84. 柱状图中最大的矩形
    84.柱状图中最大的矩形1、双指针classSolution:deflargestRectangleArea(self,heights:List[int])->int:n=len(heights)#左右第一个小于i的下标min_l,min_r=[0]*n,[0]*nres=0min_l[0]=-1......