如何动态调整Google表格图表的垂直(y)轴的最小值和最大值以适应数据集?

时间:2019-06-09 13:56:40

标签: google-apps-script google-sheets google-visualization google-sheets-charts

我正在努力调整Google表格折线图,以使垂直y轴自动适应我的数据集。

例如,我不希望y轴从0开始,而是我的数据集中的最小值和最大值。

在我的工作表中,最小值为0.712,最大值为0.811。理想的情况是,图表的y轴然后可以调整为从0.712减去10%(最小值)和y轴最大值0.811 + 10%(最小值)开始。

这应该为我的数据创建一个整洁的图表。我正在努力做到这一点,而且似乎无法在垂直轴“最小”和“最大”下的图表的自定义选项中输入公式或某些内容。由于我要绘制的数据非常动态,因此仅输入硬值是行不通的,因此图表的垂直轴需要根据数据进行调整。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

下面的代码在一张纸上保持两个图表的最小和最大。

if($_POST) {
    if(($_POST['type'] == '0') && ($_POST['priceminrahn'] != '') && ($_POST["priceminej"] != '') && ($_POST["mahale"] != '0')) {
        $sql = "select * from orders JOIN city ON orders.orders_mahaleh = city.id where orders_show='1' AND orders_mahaleh='$mahal' AND  orders_polpish between '$priceminrahn' AND '$pricemaxrahn' AND orders_ejarehbaha between '$priceminej' AND '$pricemaxej' AND orders_subject='1'";
    }
    if(($_POST['type'] == '0') && ($_POST['priceminrahn'] != '')) {
        $sql = "select * from orders JOIN city ON orders.orders_mahaleh = city.id where orders_show='1' AND orders_polpish between '$priceminrahn' AND '$pricemaxrahn' AND orders_subject='1'";
    }
    if(($_POST['type'] == '0') && ($_POST['priceminrahn'] != '') && ($_POST["priceminej"] != '')) {
        $sql = "select * from orders JOIN city ON orders.orders_mahaleh = city.id where orders_show='1' AND  orders_polpish between '$priceminrahn' AND '$pricemaxrahn' AND orders_ejarehbaha between '$priceminej' AND '$pricemaxej' AND orders_subject='1'";
    }
    if(($_POST['type'] == '0') && ($_POST["mahale"] != '')) {
        $sql = "select * from orders JOIN city ON orders.orders_mahaleh = city.id where orders_show='1' AND orders_mahaleh='$mahal' AND orders_subject='1'";
    }
    if(($_POST['type'] == '0') && ($_POST["state"] != '') && ($_POST["mahale"] == '0')) {
        $sql = "select * from orders JOIN city ON orders.orders_mahaleh = city.id where orders_show='1' AND orders_ostan='$ostan' AND orders_subject='1'";
    }
} else {
    $sql = "select * from orders JOIN city ON orders.orders_mahaleh = city.id where orders_show='1'";
}