Merge pull request #10710 from dataease/pr@dev-v2@refactor_chart_plugin

refactor(图表): 插件类型调整
This commit is contained in:
wisonic-s 2024-07-02 15:58:25 +08:00 committed by GitHub
commit 19b516a341
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 29 deletions

View File

@ -1,39 +1,13 @@
package io.dataease.extensions.view.plugin;
import io.dataease.exception.DEException;
import io.dataease.extensions.datasource.provider.Provider;
import io.dataease.extensions.view.dto.*;
import io.dataease.extensions.view.factory.PluginsChartFactory;
import io.dataease.extensions.view.model.SQLMeta;
import io.dataease.extensions.view.vo.XpackPluginsViewVO;
import io.dataease.license.utils.JsonUtil;
import io.dataease.plugins.template.DataEasePlugin;
import io.dataease.plugins.vo.DataEasePluginVO;
import java.util.List;
import java.util.Map;
public abstract class AbstractChartPlugin implements DataEasePlugin {
@Override
public void loadPlugin() {
XpackPluginsViewVO viewConfig = getConfig();
PluginsChartFactory.loadPlugin(viewConfig.getRender(), viewConfig.getChartValue(), this);
}
public XpackPluginsViewVO getConfig() {
DataEasePluginVO pluginInfo = null;
try {
pluginInfo = getPluginInfo();
} catch (Exception e) {
DEException.throwException(e);
}
String config = pluginInfo.getConfig();
XpackPluginsViewVO vo = JsonUtil.parseObject(config, XpackPluginsViewVO.class);
vo.setIcon(pluginInfo.getIcon());
return vo;
}
public abstract class AbstractChartPlugin {
/**
* 处理视图需要用到的轴字段大部分图表都聚合成两个字段X Y
@ -72,8 +46,9 @@ public abstract class AbstractChartPlugin implements DataEasePlugin {
/**
* 构建视图将计算结果处理成最终视图
* @param view 原视图对象
* @param calcResult 计算结果
*
* @param view 原视图对象
* @param calcResult 计算结果
* @param formatResult 轴字段处理结果
* @param filterResult 过滤条件处理结果
* @return 返回前端的视图建议数据放在 data 过滤条件放在 filter 其他字段可自行添加可参考主工程

View File

@ -0,0 +1,30 @@
package io.dataease.extensions.view.plugin;
import io.dataease.exception.DEException;
import io.dataease.extensions.view.factory.PluginsChartFactory;
import io.dataease.extensions.view.vo.XpackPluginsViewVO;
import io.dataease.license.utils.JsonUtil;
import io.dataease.plugins.template.DataEasePlugin;
import io.dataease.plugins.vo.DataEasePluginVO;
public abstract class DataEaseChartPlugin extends AbstractChartPlugin implements DataEasePlugin {
@Override
public void loadPlugin() {
XpackPluginsViewVO viewConfig = getConfig();
PluginsChartFactory.loadPlugin(viewConfig.getRender(), viewConfig.getChartValue(), this);
}
public XpackPluginsViewVO getConfig() {
DataEasePluginVO pluginInfo = null;
try {
pluginInfo = getPluginInfo();
} catch (Exception e) {
DEException.throwException(e);
}
String config = pluginInfo.getConfig();
XpackPluginsViewVO vo = JsonUtil.parseObject(config, XpackPluginsViewVO.class);
vo.setIcon(pluginInfo.getIcon());
return vo;
}
}