All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.datastax.data.exploration.service.chart.impl.StackedBarServiceImpl Maven / Gradle / Ivy

The newest version!
package com.datastax.data.exploration.service.chart.impl;

import com.datastax.data.exploration.biz.datatable.column.math.Function;
import com.datastax.data.exploration.biz.stat.StackedBar;
import com.datastax.data.exploration.common.DataTypeHandler;
import com.datastax.data.exploration.common.File2DataTable;
import com.datastax.data.exploration.dto.dataChart.stackedBar.StackedBarChartInit;
import com.datastax.data.exploration.dto.dataChart.stackedBar.StackedBarChartValue;
import com.datastax.data.exploration.service.chart.StackedBarService;
import com.datastax.data.exploration.util.Consts;
import org.javatuples.Pair;
import org.springframework.stereotype.Service;

import java.util.*;


/**
 * 堆叠图和交叉分组表
 */
@Service("stackedBarService")
public class StackedBarServiceImpl implements StackedBarService {


    /**
     * 获取堆叠图 初始化数据
     *
     * @param id 数据集 id
     * @return 返回的是交叉分组表初始化数据
     */
    @Override
    public StackedBarChartInit stackedBarInit(String id) {
        Pair, List> pair = DataTypeHandler.continuousDiscrete(File2DataTable.tableSchema(id));
        List listVal = pair.getValue0();
        List listGroupORStack = pair.getValue1();
        if (listGroupORStack.size() == 0) {
            listGroupORStack.add(Consts.NONE);
        }
        if (listVal.size() == 0) {
            listVal.add(Consts.NONE);
        }
        return new StackedBarChartInit(listGroupORStack, listGroupORStack, listVal, Function.getFunctions());
    }

    /**
     * 获取堆叠图 展示的数据
     *
     * @param id    数据集 id
     * @param group 分组属性
     * @param stack 堆叠属性
     * @param val   取值属性
     * @param func  聚合函数
     * @return 返回的是交叉分组表 展示的数据
     */
    @Override
    public List stackedBarSelect(String id, String group, String stack, String val, String func) {
        List listValue = new ArrayList<>();
        if (Consts.NONE.equals(group) || Consts.NONE.equals(stack)) {
            return listValue;
        }
        return StackedBar.operator(id, group, stack, val, func);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy