如何使条形图和折线图的Y轴贴在PHPExcel的左侧? [英] How to make Y-axis of bar chart and line chart stick to left side for PHPExcel?

查看:115
本文介绍了如何使条形图和折线图的Y轴贴在PHPExcel的左侧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,当数据中存在负值时,默认情况下,条形图/折线图的y轴将移动到图形的中间.有没有办法使y轴停留在PHPExcel中图形的最左侧?

Currently when there are negative value in data, the y-axis of bar/line chart will be moved to middle of the graph by default. Is there a way to make the y-axis stick to the leftmost of the graph in PHPExcel?

推荐答案

可以通过设置Y& X轴样式.我不记得哪个版本实现了它们,因此它可能与您当前的版本兼容,或者不使用最新的 PHPExcel

That can be done by setting the Y & X Axis styles. I don't recall which version implemented them so it may work with your current version, or grab the latest PHPExcel

PHPExcel_Chart_Axis 是新对象将被创建.您可以在此处了解更多信息这是一个实际的例子:

PHPExcel_Chart_Axis is the new object that will be created. You can read more about it here and this is an example of it in action:

    $yAxisStyle =  new PHPExcel_Chart_Axis();
    $yAxisStyle->setAxisOptionsProperties('low', null, null, null, null, null, null, null, null, null); 

    $xAxisStyle =  new PHPExcel_Chart_Axis();
    $xAxisStyle->setAxisOptionsProperties('low', null, null, null, null, null, null, null, null, null); 

每个参数在上面的链接中都有解释,但这是一个悬崖笔记版本:

Each of those parameters are explained in the link above, but here is a cliff notes version:

        @param string $axis_labels                  'nextTo','low','high','none' (completely removes it altogether)
        @param string $horizontal_crosses_value     default=null (auto), numeric value 0-999
        @param string $horizontal_crosses           default=null,
        @param string $axis_orientation             default=null,
        @param string $major_tmt                    default=null, (major_tick_mark)
        @param string $minor_tmt                    default=null, (minor_tick_mark)
        @param string $minimum                      default=null,
        @param string $maximum                      default=null,
        @param string $major_unit                   default=null,
        @param string $minor_unit                   default=null,

在您的PHP文件中找到新的PHPExcel_Chart"部分.使用下面的示例,您可以添加Y和X轴样式:

Within your PHP file find the "new PHPExcel_Chart" section. Using the example below you can add in the Y and X axis styling:

    $chart= new PHPExcel_Chart(
                        'Chart1',       // name
                        $title,         // title displayed on chart
                        $legend,        // legend
                        $pa,            // plotArea
                        true,           // plotVisibleOnly
                        0,              // displayBlanksAs
                        NULL,           // xAxisLabel
                        $yAxisLabel,    // yAxisLabel
                        $xAxisStyle,    // X-axis styling vertical
                        $yAxisStyle,    //Y-axis style horizontal
                        null,
                        null
                    );

这篇关于如何使条形图和折线图的Y轴贴在PHPExcel的左侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆