【问题标题】:Is there a way to add white space before and after x-axis in an apex chart?有没有办法在顶点图表中的 x 轴之前和之后添加空格?
【发布时间】:2021-03-30 10:17:35
【问题描述】:

我需要找到一种方法在 Apex 图表中的图形前后添加一些空格。 目前我的图表显示在 0,0 并在最后一个数据点结束,见图

..但我想要的是在第一个数据点之前添加空间,在最后一个数据点之后,请参见图片

我看不到执行此操作的设置,并且我尝试过破解它但无济于事。任何帮助将不胜感激。

【问题讨论】:

    标签: javascript vue.js charts apexcharts


    【解决方案1】:

    您可以使用网格选项在侧面添加填充

    
    import ApexCharts from 'apexcharts'
    
    
    var options = {
      chart: {
        type: 'line'
      },
      series: [{
        name: 'sales',
        data: [30,40,35,50,49,60,70,91,125]
      }],
      xaxis: {
        categories: [1991,1992,1993,1994,1995,1996,1997, 1998,1999],
        
      },
      grid: {
        show: true,
        borderColor: '#90A4AE',
        strokeDashArray: 0,
        position: 'back',
        xaxis: {
            lines: {
                show: false
            }
        },   
        yaxis: {
            lines: {
                show: false
            }
        },  
        row: {
            colors: undefined,
            opacity: 0.5
        },  
        column: {
            colors: undefined,
            opacity: 0.5
        },  
        padding: {
            top: 0,
            right: 50,
            bottom: 0,
            left: 50
        },  
    }
    }
    
    var chart = new ApexCharts(document.querySelector("#app"), options);
    
    chart.render()
    
    

    【讨论】:

    • 感谢@anees 的回复,它在图表的左右添加了填充,但没有像我上面的屏幕截图那样添加到实际数据本身。
    • 哦,好吧。也许你可以添加一个底部边框,如果有帮助就不要使用默认值
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-09
    • 2018-02-07
    • 2016-11-17
    • 2011-11-12
    • 1970-01-01
    • 2013-10-05
    相关资源
    最近更新 更多