简体   繁体   English

如何从svggraph(php库)反转y轴数据?

[英]How can I inverse the y axis data from a svggraph(php library)?

I need to inverse the data from my chart, like when I get the data from March 2015 to April 2014, I want that March 2015(actual time) to be on the right, not on the left. 我需要对图表中的数据求逆,例如当我获得2015年3月至2014年4月的数据时,我希望2015年3月(实际时间)在右边,而不是左边。 I'm using SVGGraph library. 我正在使用SVGGraph库。 Thank you! 谢谢!

$graph = new SVGGraph($w, $h, $settings);
$data = [];
for ($i = 1; $i <= 12; $i++) {
    switch ($op) {
        case "eaqf-f":
            $data["$y-$m"] = StatUtil::getTotalEaInvoiced($y, $m, $oid);
            $data["$y-$m"] = $data["$y-$m"]['q'];
        break;

        case "cv-val":
            $data["$y-$m"] = StatUtil::getInvoicedCVs($y, $m, $oid);
        break;

        case "eaqf-r":
            $data["$y-$m"] = StatUtil::getTotalConsumption($y, $m, $oid);
        break;

        default: throw RuntimeException("Unsupported op: $op");
    }

    if (--$m == 0) {
        $m = 12;
        --$y;
    }
}

$graph ->Values($data);
$graph ->Render("Linegraph");
for ($i = 1; $i <= 12; $i++) {
$_key = sprintf('%1$04d-%2$02d', $y, $m);
    switch ($op) {
    case "eaqf-f":
        $data[$_key] = StatUtil::getTotalEaInvoiced($y, $m, $oid);
        $data[$_key] = $data[$_key]['q'];
        break;

and use ksort before the rendering 并在渲染之前使用kso​​rt

ksort($data, SORT_STRING);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM