Skip to content

Commit

Permalink
Merge pull request #141 from running-elephant/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Cuiyansong committed Aug 8, 2022
2 parents d4edf9a + fe2ab10 commit 45abf9f
Show file tree
Hide file tree
Showing 32 changed files with 345 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ private void excludeColumns(Dataframe data, Set<SelectColumn> include) {
if (include
.stream()
.noneMatch(selectColumn ->
column.columnKey().equals(selectColumn.getColumnKey()) || column.columnKey().equals(selectColumn.getAlias()))) {
column.columnKey().equals(selectColumn.getColumnKey())
|| column.columnKey().equals(selectColumn.getAlias())
|| column.columnKey().contains(selectColumn.getColumnKey()))) {
excludeIndex.add(i);
}
}
Expand Down
14 changes: 14 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"antd-theme-generator": "1.2.11",
"axios": "^0.21.1",
"classnames": "^2.3.1",
"currency.js": "^2.0.4",
"debounce-promise": "3.1.2",
"echarts": "5.3.1",
"echarts-wordcloud": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import {
toFormattedValue,
transformToDataSet,
} from 'app/utils/chartHelper';
import { isNumber } from 'app/utils/number';
import { DATARTSEPERATOR } from 'globalConstants';
import { precisionCalculation } from 'app/utils/number';
import { CalculationType, DATARTSEPERATOR } from 'globalConstants';
import { darken, getLuminance, lighten } from 'polished';
import { Debugger } from 'utils/debugger';
import { CloneValueDeep, isEmptyArray, Omit } from 'utils/object';
Expand Down Expand Up @@ -393,15 +393,7 @@ class BasicTableChart extends ReactChart {
? context?.translator?.('viz.palette.graph.summary') + ': '
: '') +
toFormattedValue(
total.reduce((acc, cur) => {
const num: number =
!isNumber(cur) || isNaN(cur)
? typeof cur === 'string' && !isNaN(Number(cur))
? Number(cur)
: 0
: cur;
return acc + num;
}, 0),
precisionCalculation(CalculationType.ADD, total),
currentSummaryField.format,
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/

import { ChartDataSectionType } from 'app/constants';
import Chart from 'app/models/Chart';
import { ChartSelectionManager } from 'app/models/ChartSelectionManager';
import {
ChartConfig,
ChartDataSectionField,
Expand All @@ -37,15 +39,15 @@ import {
getSelectedItemStyles,
getStyles,
hadAxisLabelOverflowConfig,
round,
setOptionsByAxisLabelOverflow,
toFormattedValue,
transformToDataSet,
} from 'app/utils/chartHelper';
import { precisionCalculation } from 'app/utils/number';
import currency from 'currency.js';
import { init } from 'echarts';
import { CalculationType } from 'globalConstants';
import { UniqArray } from 'utils/object';
import Chart from '../../../models/Chart';
import { ChartSelectionManager } from '../../../models/ChartSelectionManager';
import Config from './config';
import {
OrderConfig,
Expand Down Expand Up @@ -122,6 +124,7 @@ class WaterfallChart extends Chart {
onUnMount(options: BrokerOption, context: BrokerContext): void {
this.selectionManager?.removeWindowListeners(context.window);
this.selectionManager?.removeZRenderListeners(this.chart);
this.rowDataList = [];
this.chart?.dispose();
}

Expand Down Expand Up @@ -162,12 +165,12 @@ class WaterfallChart extends Chart {
);

return {
barWidth: this.getSerieBarWidth(styleConfigs),
barWidth: this.getSeriesBarWidth(styleConfigs),
...series,
};
}

private getSerieBarWidth(styles: ChartStyleConfig[]): number {
private getSeriesBarWidth(styles: ChartStyleConfig[]): number {
const [width] = getStyles(styles, ['bar'], ['width']);
return width;
}
Expand All @@ -192,7 +195,7 @@ class WaterfallChart extends Chart {
['isIncrement', 'ascendColor', 'descendColor'],
);
const label = this.getLabel(styles, aggregateConfigs[0].format);

this.rowDataList = [];
const dataList = chartDataSet.map(dc => {
this.rowDataList.push(getExtraSeriesRowData(dc));
return dc.getCell(aggregateConfigs[0]);
Expand Down Expand Up @@ -274,7 +277,10 @@ class WaterfallChart extends Chart {
const text = param.map((pa, index) => {
let data = pa.value;
if (!index && typeof param[1].value === 'number') {
data += param[1].value;
data = precisionCalculation(CalculationType.ADD, [
data,
param[1].value,
]);
}
return `${pa.seriesName}: ${toFormattedValue(
data,
Expand Down Expand Up @@ -317,16 +323,24 @@ class WaterfallChart extends Chart {
selectedItems?: SelectedItem[],
): WaterfallDataListConfig {
const [totalColor] = getStyles(styles, ['bar'], ['totalColor']);
const baseData: Array<number | string> = [];
const baseData: Array<number> = [];
const ascendOrder: OrderConfig[] = [];
const descendOrder: OrderConfig[] = [];
dataList.forEach((data, index) => {
const newData: number = parseFloat(data);
const newData: number = isNaN(currency(data).value)
? 0
: currency(data).value;
const lastData: number = isNaN(currency(dataList[index - 1]).value)
? 0
: currency(dataList[index - 1]).value;
if (index > 0) {
if (isIncrement) {
const result: number | string =
Number(dataList[index - 1]) >= 0
? round(dataList[index - 1] + baseData[index - 1])
const result: number =
lastData >= 0
? precisionCalculation(CalculationType.ADD, [
lastData,
baseData[index - 1],
])
: baseData[index - 1];
if (newData >= 0) {
baseData.push(result);
Expand All @@ -336,30 +350,38 @@ class WaterfallChart extends Chart {
});
descendOrder.push('-');
} else {
baseData.push(round(Number(result) + newData));
baseData.push(
precisionCalculation(CalculationType.ADD, [result, newData]),
);
ascendOrder.push('-');
descendOrder.push({
value: Math.abs(newData),
...getSelectedItemStyles('', index, selectedItems || []),
});
}
} else {
const result = round(Number(data) - parseFloat(dataList[index - 1]));
const result: number = precisionCalculation(
CalculationType.SUBTRACT,
[newData, lastData],
);
if (result >= 0) {
ascendOrder.push({
value: result,
...getSelectedItemStyles('', index, selectedItems || []),
});
descendOrder.push('-');
baseData.push(parseFloat(dataList[index - 1]));
baseData.push(lastData);
} else {
ascendOrder.push('-');
descendOrder.push({
value: Math.abs(result),
...getSelectedItemStyles('', index, selectedItems || []),
});
baseData.push(
round(parseFloat(dataList[index - 1]) - Math.abs(result)),
precisionCalculation(CalculationType.SUBTRACT, [
lastData,
Math.abs(result),
]),
);
}
}
Expand All @@ -383,9 +405,10 @@ class WaterfallChart extends Chart {
});
if (isIncrement && xAxisColumns?.data?.length) {
xAxisColumns.data.push(t?.('common.total'));
const resultData = round(
dataList[dataList.length - 1] + baseData[baseData.length - 1],
);
const resultData = precisionCalculation(CalculationType.ADD, [
dataList[dataList.length - 1],
baseData[baseData.length - 1],
]);
if (resultData > 0) {
ascendOrder.push({
value: resultData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ const config: ChartConfig = {
label: 'bar.radius',
key: 'radius',
comType: 'inputNumber',
options: {
min: 0,
},
},
{
label: 'bar.width',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ export const CheckboxGroupSetter: React.FC<CheckboxGroupControllerProps> = memo(
const renderOptions = useCallback(() => {
return (options || []).map(o => ({
label: o.label ?? o.value,
value: o.value,
value: o.value || '',
key: o.label + o.value,
}));
}, [options]);

return (
<Wrapper>
<Checkbox.Group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { memo, useContext } from 'react';
import styled from 'styled-components/macro';
import { LEVEL_1 } from 'styles/StyleConstants';
import { WidgetActionContext } from '../../../components/ActionProvider/WidgetActionProvider';
import { BoardToolBar } from '../components/BoardToolBar/BoardToolBar';
import { LayerTreePanel } from '../components/LayerPanel/LayerTreePanel';
Expand Down Expand Up @@ -46,6 +47,7 @@ const Wrapper = styled.div`
`;

const Editor = styled.div`
z-index: ${LEVEL_1};
display: flex;
flex: 1;
min-height: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/

import { BoardContext } from 'app/pages/DashBoardPage/components/BoardProvider/BoardProvider';
import React, { useContext } from 'react';
import { useContext } from 'react';
import styled from 'styled-components/macro';
import { LEVEL_1, SPACE, SPACE_XL } from 'styles/StyleConstants';
import { LEVEL_5, SPACE, SPACE_XL } from 'styles/StyleConstants';
import { BoardToolBarContext } from './context/BoardToolBarContext';
import { ToolBar } from './ToolBar';

Expand All @@ -37,7 +37,7 @@ export const BoardToolBar = () => {
};

const Wrapper = styled.div`
z-index: ${LEVEL_1};
z-index: ${LEVEL_5};
display: flex;
flex-shrink: 0;
align-items: center;
Expand Down
Loading

0 comments on commit 45abf9f

Please sign in to comment.