vue+highCharts---一些常用的设置

此文章专门用来跟踪记录vue+highCharts在使用过程中的一些常见的需求设置。本人每次开发图表的时候,看官方文档脑壳都大了,属性太多,密密麻麻的,根本记不住。所以整理一些常见的功能实现方式,方便自己今后查阅。(后续会根据实际情况不断更新)

1、隐藏右下角logo

在这里插入图片描述

xAxis:{...},
yAxis:{...},
credits: {
		enabled: false// 隐藏右下角水印
	}

2、隐藏横线网格

在这里插入图片描述

yAxis:{
		gridLineColor: 'transparent' //颜色改成透明色
	}

3、显示y轴线

在这里插入图片描述

yAxis:{
		lineWidth: 1
	}

4、自定义轴线颜色和文字颜色

在这里插入图片描述

xAxis:{
		  lineColor: 'red',
          labels: {
            style: {
              color: 'red'
            }
          }
	}

5、自定义线条颜色

在这里插入图片描述

yAxis:{...},
series: [{
		data: [...],
		color:'red'
	}]

6、隐藏数据点marker

在这里插入图片描述

yAxis:{...},
series: [{
		data: [...],
		marker: {
            enabled: false
        }
	}]

7、指定分区显示不同的颜色或者线条样式 官网在线例子

在这里插入图片描述

yAxis:{...},
series: [{
		data: [...],
		zoneAxis: 'x',
		zones: [{
			value: 8
		}, {
			dashStyle: 'dot',
			color: { //设置颜色为渐变色,渐变色效果需要面积图才明显
              linearGradient: {
                x1: 0,
                y1: 0,
                x2: 0,
                y2: 1
              },
              stops: [
                [0, 'red'],
                [0.9, '#303642']
              ]
            }
		}]
	}]

8、自定义图表背景颜色

chart: {
          backgroundColor: '#303642',
          //backgroundColor: 'rgba(0,0,0,0)'  //透明背景
          type: 'spline'
        }

9、去掉导出图表按钮

yAxis: {},
exporting: { enabled:false }

10、改变柱状图柱子颜色

在这里插入图片描述

方法一:
    plotOptions: {
		series: {
			colorByPoint: true,
			colors: ['red', 'blue']
		}
	}

方法二:
xAxis: {...},
series: [{
		data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
		colorByPoint: true,
		colors: ['red', 'blue']
}]

11、更改数据点大小

在这里插入图片描述

xAxis:{},
plotOptions: {
	series: {
		animation: false, // 去除渲染动画
        turboThreshold: 0, // 不限制点数,
        marker: {
        	enabled: true,
            symbol: 'circle',
            radius: 10, // 更改数据点大小
            states: {
              hover: {
                 enabled: true
              }
            }
        }
	}
}

12、曲线面积图

在这里插入图片描述

chart:{
	type: 'areaspline',
    marginRight: 10
},
xAxis:{},
plotOptions: {
	series: {
		animation: false, // 去除渲染动画
        turboThreshold: 0, // 不限制点数,
        fillColor: {// 注意!!!如果是柱状图请使用color,如果是面积图请使用fillColor
              linearGradient: {
                x1: 0,
                y1: 0,
                x2: 0,
                y2: 1
              },
              stops: [
                [0, '#9CABE2'],
                [1, HighCharts.Color('white').setOpacity(0).get('rgba')]
              ]
         }
	}
}

13、更改数据点颜色

在这里插入图片描述

xAxis:{},
series: [{
          name: '噪声',
          data: [{ 
	          x: 1637117403000,
	          y: 20,
	          marker: { fillColor: 'red' } //设置每个数据点的颜色
          }]
}]

14、添加合格基准线(假设为60分)

在这里插入图片描述

yAxis: {
          plotLines: [{ // 一条延伸到整个绘图区的线,标志着轴中一个特定值。
            color: 'red',
            dashStyle: 'Dash', // Dash,Dot,Solid,默认Solid
            width: 1,
            value: 60, // y轴显示位置
            zIndex: 5
          }]
}

15、时间标签格式化

在这里插入图片描述

点击查看highcharts时间格式化函数
		xAxis: {
          type: 'datetime',
          dateTimeLabelFormats: {
            day: '%m月%e号'
          }
        }
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值