highchart的使用(X,Y轴title,显示数字的分隔符, 滚动条等)

以下是最近使用到报表,按照需求整理的一些常用属性。

本来计划使用echarts,结合需求经过实践还是使用了highchart

//记得引入jquery
<script src="https://cdn.highcharts.com.cn/highstock/highstock.js"></script>        let that = this;
        Highcharts.setOptions({
            lang: {
                thousandsSep: ','。 //显示数字的分隔符
            }
        });
        let max = 10;
    //根据X轴拿到的数据进行判断,没有超过10条就按照X轴拿到的数据总数显示
        if(that.xAxisCategories.length < 10) {
            max = that.xAxisCategories.length -1;
        }
        Highcharts.chart('chart', {
            chart: {
                type: 'column'
            },
            scrollbar: {
              enabled: true      //显示滚动条
            },
            legend: {
                enabled: false   //不现实图例
            },
            title: {
                text: ''      //不显示标题
            },
            credits: {
                enabled: false //去掉默认右下角的highchart.com
            },
            subtitle: {
                text: '' //不现实子标题
            },
            xAxis: {
                categories: that.xAxisCategories,   //X轴数据,如:['2022-01-01', '2022-01-02', '2022-01-03', '2022-01-04', '2022-01-05', '2022-01-06', '2022-01-07']
                tickWidth: 1,    //X轴刻度显示
        //很关键,控制超出多少个会出现滚动条
                min: 0,
                max: max
            },
            yAxis: {
                title: {
                    enabled: false     //Y轴标题是否显示
                },
                gridLineDashStyle: 'longdash',   //背景显示虚线格
                lineWidth: 1,                   //显示Y轴
                tickWidth: 1,                   //显示Y轴刻度
           //Y轴值为0的时候不居中显示,使用以下两个属性
                min: 0,                       
                minRange: 1
            },
            plotOptions: {
                 //控制显示出来的柱状图样式,颜色等
                column: {
                    borderWidth: 0,
                    dataLabels: {
                        enabled: true,    //
                        style: {
                            fontWeight: 'normal',
                            color: '#666666'
                        }
                    },
                    color: '#45DDCC'
                }
            },
            series: [{
                name: that.typeText,    //鼠标放在柱状图上,显示的文字
                data: that.seriesData   //Y轴数据,如:[1,2,3,4,5,6,7]
            }]
        });
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值