@Override public void updateAreaWithDataFormat(ExtendArea area, String dataFormat) { FormatModel model = area.getFormatModel(); model.getDataFormat().putAll(convertStr2Map(dataFormat)); }
/** * decorate chart with extend area * * @param chart * @param area * @param index */ public static void decorateChart(DIReportChart chart, ExtendArea area, Schema schema, int index) { if (area.getType() == ExtendAreaType.CHART) { assert area.getLogicModel() != null : "当前区域未设置逻辑模型"; // 设置topN默认设置 if (area.getLogicModel().getTopSetting() != null) { MeasureTopSetting topSetting = area.getLogicModel().getTopSetting(); chart.setRecordSize(topSetting.getRecordSize()); chart.setTopedMeasureId(topSetting.getMeasureId()); chart.setTopType(topSetting.getTopType().name()); chart.setAreaId(area.getId()); } FormatModel formatModel = area.getFormatModel(); if (formatModel != null && formatModel.getDataFormat() != null) { addDataFormatInfo(chart, formatModel.getDataFormat()); Map<String, String> colorFormat = formatModel.getColorFormat(); if (colorFormat != null && !colorFormat.isEmpty() && chart.getSeriesData() != null) { for (SeriesDataUnit data : chart.getSeriesData()) { if (data == null) { continue; } data.setColorDefine(colorFormat.get(data.getyAxisName())); } } Map<String, String> positions = formatModel.getPositions(); if (colorFormat != null && !positions.isEmpty() && chart.getSeriesData() != null) { for (SeriesDataUnit data : chart.getSeriesData()) { if (data == null) { continue; } data.setPosition(positions.get(data.getyAxisName())); } } } chart.getRender().setAxisCaption(area.getChartFormatModel().getSetting().getAxisCaption()); chart.setAppearance(area.getChartFormatModel().getAppearance().getLegend()); final Map<String, String> dimMap = Maps.newConcurrentMap(); String[] allDims = area.getLogicModel() .getSelectionDims() .values() .stream() .map( item -> { OlapElement tmp = getOlapElement(area, schema, item); if (tmp != null) { dimMap.put(tmp.getId(), tmp.getName()); return tmp.getCaption(); } else { return null; } }) .filter(x -> x != null) .toArray(String[]::new); chart.setDimMap(dimMap); chart.setAllDims(allDims); String[] allMeasures = area.getLogicModel() .getSelectionMeasures() .values() .stream() .map( item -> { OlapElement tmp = getOlapElement(area, schema, item); if (tmp != null) { chart.getMeasureMap().put(tmp.getId(), tmp.getCaption()); return tmp.getCaption(); } else { return null; } }) .filter(x -> x != null) .toArray(String[]::new); chart.setAllMeasures(allMeasures); final Item[] columns = area.getLogicModel().getColumns(); List<String> tmp = getOlapElementNames(columns, area.getCubeId(), schema); if (tmp.size() > 0) { chart.setDefaultMeasures(tmp.toArray(new String[0])); } for (int i = 0; i < columns.length; ++i) { chart.getMeasureMap().put(columns[i].getOlapElementId(), tmp.get(i)); } if (index >= 0 && index < chart.getAllMeasures().length) { chart.setDefaultMeasures(new String[] {chart.getAllMeasures()[index]}); } } else if (area.getType() == ExtendAreaType.LITEOLAP_CHART) { addDataFormatInfo(chart, area.getFormatModel().getDataFormat()); } }