Exemplo n.º 1
0
function get_chart_series_fields(&$arr_data_series, &$arr_label_series)
{
    if (is_groupby_chart()) {
        return get_chart_groupbyseries_fields($arr_data_series, $arr_label_series);
    }
    $root =& $_SESSION['webcharts'];
    $arr_data_series = array();
    $arr_label_series = array();
    $arr_join_tables = getChartTablesList();
    for ($i = 0; $i < count($arr_join_tables); $i++) {
        $t = $arr_join_tables[$i];
        $arr_fields = GetNumberFieldsList($t);
        for ($j = 0; $j < count($arr_fields); $j++) {
            if (!is_wr_custom()) {
                $arr_data_series[] = array("field" => $t . "." . $arr_fields[$j], "label" => WRChartLabel($t . "." . $arr_fields[$j]));
            } else {
                $arr_data_series[] = array("field" => $arr_fields[$j], "label" => WRChartLabel($arr_fields[$j]));
            }
        }
        $arr_fields = WRGetNBFieldsList($t);
        for ($j = 0; $j < count($arr_fields); $j++) {
            if (!is_wr_custom()) {
                $arr_label_series[] = array("field" => $t . "." . $arr_fields[$j], "label" => WRChartLabel($t . "." . $arr_fields[$j]));
            } else {
                $arr_label_series[] = array("field" => $arr_fields[$j], "label" => WRChartLabel($arr_fields[$j]));
            }
        }
    }
    if (!count($arr_data_series)) {
        $arr_data_series = $arr_label_series;
    }
}
Exemplo n.º 2
0
function set_default_chart_parameter($idx, $labelMode, $addLabel)
{
    $root =& $_SESSION["webcharts"];
    $arr_join_tables = getChartTablesList();
    if (is_groupby_chart()) {
        for ($i = 0; $i < count($root["group_by_condition"]) - 1; $i++) {
            if (!$root["group_by_condition"][$i]["group_by_value"]) {
                continue;
            }
            $type = WRGetFieldType($root["group_by_condition"][$i]["field_opt"]);
            $grvalue = $root["group_by_condition"][$i]["group_by_value"];
            if (!$labelMode && (IsNumberType($type) || $grvalue != "GROUP BY") || $labelMode) {
                $table = "";
                $field = "";
                WRSplitFieldName($root["group_by_condition"][$i]["field_opt"], $table, $field);
                $root["parameters"][$idx]["name"] = $field;
                $root["parameters"][$idx]["table"] = $table;
                if ($grvalue != "GROUP BY") {
                    $root["parameters"][$idx]["agr_func"] = $grvalue;
                }
                if ($addLabel) {
                    $root["parameters"][$idx]["label"] = $field;
                }
                break;
            }
        }
    } else {
        foreach ($arr_join_tables as $tbl) {
            if (!$labelMode) {
                $fields = GetNumberFieldsList($tbl);
            } else {
                $fields = WRGetNBFieldsList($tbl);
            }
            if (count($fields)) {
                $root["parameters"][$idx]["name"] = $fields[0];
                $root["parameters"][$idx]["table"] = $tbl;
                $root["parameters"][$idx]["agr_func"] = "";
                if ($addLabel) {
                    $root["parameters"][$idx]["label"] = WRChartLabel($tbl . "." . $fields[0]);
                }
                break;
            }
        }
    }
}