Echarts 屬性大全設置

折线图显示圆滑:smooth:true

 series: 
              {
                name: "数据",
                type: "line",
                data:b,
                smooth: true,
                color:"#0ff",

}
             
              

X轴的图显示位置:

 xAxis: {
            
              {
                axisTick:{
                  alignWithLabel:true
              },
  
            },

对比:

柱状图间距:

{
            label: {
            stack: '1',
            color: "#4db9f7",
            barGap: '0%', 
            name: "",
            barWidth: '20%',
            type: "bar",
            data: d,
          },

title設置:

 var option1 = {
        title: [{
            text: 'AAAAAAA',
            x: '23%',
            y: '34%',
          },
          {
            text: "BBBBBBB",
            x: '70%',
            y: '34%',
          }
        ],

坐标轴两边空白策略:

   xAxis: {
            boundaryGap: true
          },

坐标轴隐藏刻度线:

 yAxis: {
            axisTick: {
              show: false
            },
  }

 xAxis: {
            axisTick: {
              show: false
            },
  }

给纵坐标设置最大最小值和增长间距:

  yAxis: {
            type:'value',
            min:50,
            max:100,
            interval:15,}

设置图例样式:

legend: {

icon: "circle",   //  这个字段控制形状  类型包括 circle,rect ,roundRect,triangle,diamond,pin,arrow,none

itemWidth: 10,  // 设置宽度

itemHeight: 10, // 设置高度

itemGap: 40 // 设置间距

},

 設置縱坐標百分比和坐標軸顏色:

yAxis: {
            // 縱坐標百分比
            axisLabel: {
              show: true,
              formatter: '{value} %'  
            },
            // 縱坐標軸顏色
            axisLine: {
              lineStyle: {
                color: '#00a2ff'
              }
            },
           // 縱坐標線顏色
            splitLine: {
              show: true,
              lineStyle: {
                color: "rgba(0,162,255,0.2)",
                width: 1,
              }
            }
          },

1.設置Y軸從數據最小的開始顯示:

yAxis: {
          scale:true,
      
        },

 

2.min可以设置为特殊值‘dataMin’,此时取数据在该轴上的最小值作为最小刻度。

  1.  

    yAxis: {
    
    min: 'dataMin' // 最小值
    
    },

     

 設置漸變色:

  areaStyle: {
            normal: {
               // //颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1,[{
                offset: 0, color: '#4e8aeb' // 0% 处的颜色
            }, {
                offset: 0.5, color: '#f00' // 50% 处的颜色
            }, {
                offset: 1, color: '#fff' // 100% 处的颜色
            }]
        ),
            }
          },

折線圖拐點的樣式:

symbol:"circle";

// 默认色板
color: ['#ff7f50','#87cefa','#da70d6','#32cd32','#6495ed',
        '#ff69b4','#ba55d3','#cd5c5c','#ffa500','#40e0d0',
        '#1e90ff','#ff6347','#7b68ee','#00fa9a','#ffd700',
        '#6699FF','#ff6666','#3cb371','#b8860b','#30e0e0'],

// 图表标题
title: {
    x: 'left',                 // 水平安放位置,默认为左对齐,可选为:
                               // 'center' ¦ 'left' ¦ 'right'
                               // ¦ {number}(x坐标,单位px)
    y: 'top',                  // 垂直安放位置,默认为全图顶端,可选为:
                               // 'top' ¦ 'bottom' ¦ 'center'
                               // ¦ {number}(y坐标,单位px)
    //textAlign: null          // 水平对齐方式,默认根据x设置自动调整
    backgroundColor: 'rgba(0,0,0,0)',
    borderColor: '#ccc',       // 标题边框颜色
    borderWidth: 0,            // 标题边框线宽,单位px,默认为0(无边框)
    padding: 5,                // 标题内边距,单位px,默认各方向内边距为5,
                               // 接受数组分别设定上右下左边距,同css
    itemGap: 10,               // 主副标题纵向间隔,单位px,默认为10,
    textStyle: {
        fontSize: 18,
        fontWeight: 'bolder',
        color: '#333'          // 主标题文字颜色
    },
    subtextStyle: {
        color: '#aaa'          // 副标题文字颜色
    }
},

// 图例
legend: {
    orient: 'horizontal',      // 布局方式,默认为水平布局,可选为:
                               // 'horizontal' ¦ 'vertical'
    x: 'center',               // 水平安放位置,默认为全图居中,可选为:
                               // 'center' ¦ 'left
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 ECharts 图表中控制纵坐标的小数位数,并添加单位%,可以通过设 yAxis.axisLabel.formatter 属来实现。为了确保数值不相同,您可以在 formatter 函数内部进行额外的处理。 以下是一个示例代码: ```javascript // 假设有一个名为 chart 的 ECharts 实例 chart.setOption({ yAxis: { axisLabel: { formatter: function (value) { // 保留两位小数 var formattedValue = value.toFixed(2); // 添加单位% formattedValue += "%"; // 处理数值相同的情况 if (this.scale && this.scale.hasOwnProperty(formattedValue)) { var idx = this.scale[formattedValue] + 1; formattedValue += " (" + idx + ")"; this.scale[formattedValue] = idx; } else { this.scale = {}; this.scale[formattedValue] = 0; } return formattedValue; } } }, // 其他配项... }); ``` 在这个示例中,通过设 yAxis.axisLabel.formatter 属为一个函数。在函数内部,首先使用 toFixed(2) 方法将 value 保留两位小数,并将结果赋给 formattedValue。然后,通过 += 运算符将单位%添加到 formattedValue 的末尾。 为了确保数值不相同,我们使用一个名为 scale 的对象来跟踪已经出现的数值。如果当前的 formattedValue 已经在 scale 对象中存在,则说明该数值已经出现过,需要进行处理。我们将数值后面添加一个序号,表示第几次出现该数值。如果 formattedValue 是第一次出现,则将其添加到 scale 对象,并将序号设为 0。 最后,返回 formattedValue 作为纵坐标的标签显示。 请注意,这只会影响坐标轴上的标签显示,不会改变实际的数据值。如果需要改变数据值本身的小数位数、单位等,请在数据处理阶段进行相应的处理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值