From dfb4460f583e3d515c3ca8eede32c8fa3bd93511 Mon Sep 17 00:00:00 2001 From: jojocys Date: Wed, 14 Sep 2022 11:01:55 +0800 Subject: [PATCH 1/4] refactor: delete useless repo in packages --- packages/dev/package.json | 12 ------------ packages/dev/src/index.ts | 3 --- packages/dev/tsconfig.json | 18 ------------------ packages/rath-embed/package.json | 12 ------------ 4 files changed, 45 deletions(-) delete mode 100644 packages/dev/package.json delete mode 100644 packages/dev/src/index.ts delete mode 100644 packages/dev/tsconfig.json delete mode 100644 packages/rath-embed/package.json diff --git a/packages/dev/package.json b/packages/dev/package.json deleted file mode 100644 index e8f26d78..00000000 --- a/packages/dev/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@kanaries/dev", - "version": "1.0.0", - "description": "", - "main": "src/index.ts", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC" -} diff --git a/packages/dev/src/index.ts b/packages/dev/src/index.ts deleted file mode 100644 index 646f7ff3..00000000 --- a/packages/dev/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function dev_test () { - console.log('this is a dev module test') -} \ No newline at end of file diff --git a/packages/dev/tsconfig.json b/packages/dev/tsconfig.json deleted file mode 100644 index 2f245bb6..00000000 --- a/packages/dev/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "outDir": "build", - "module": "ES6", - "lib": ["dom", "es2015", "ESNext"], - "types": ["node"], - "target": "ES2019", - "moduleResolution": "node", - "strict": true, - "noEmit": true, - "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": true - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/packages/rath-embed/package.json b/packages/rath-embed/package.json deleted file mode 100644 index f2bd3da1..00000000 --- a/packages/rath-embed/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "rath-embed", - "version": "0.0.1", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "GPL" -} From c039339a2f5eed3c2b8829fe28af3977d3b937fe Mon Sep 17 00:00:00 2001 From: jojocys Date: Wed, 14 Sep 2022 16:38:43 +0800 Subject: [PATCH 2/4] fix: locales for semanticType --- packages/rath-client/package.json | 1 - packages/rath-client/public/locales/en-US.json | 9 ++++++++- packages/rath-client/public/locales/zh-CN.json | 9 ++++++++- .../rath-client/src/components/fieldFilter/index.tsx | 7 ++++--- .../src/pages/dataSource/dataTable/headerCell.tsx | 2 +- .../src/pages/dataSource/metaView/metaList.tsx | 7 ++++++- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/rath-client/package.json b/packages/rath-client/package.json index c8263cab..e53087bd 100644 --- a/packages/rath-client/package.json +++ b/packages/rath-client/package.json @@ -14,7 +14,6 @@ "@kanaries/graphic-walker": "0.1.0", "@kanaries/loa": "0.0.5", "@kanaries/web-data-loader": "0.1.7", - "@kanaries/dev": "1.0.0", "@material-ui/core": "^5.0.0-beta.5", "@uifabric/icons": "^7.5.17", "@uifabric/react-hooks": "^7.13.9", diff --git a/packages/rath-client/public/locales/en-US.json b/packages/rath-client/public/locales/en-US.json index 4250e1f8..18a4e890 100644 --- a/packages/rath-client/public/locales/en-US.json +++ b/packages/rath-client/public/locales/en-US.json @@ -7,7 +7,14 @@ "settings": "Settings", "history": "History", "hide": "Hide", - "expand": "Expand" + "expand": "Expand", + "filter": "Filter", + "semanticType": { + "nominal": "nominal", + "ordinal": "ordinal", + "temporal": "temporal", + "quantitative": "quantitative" + } }, "menu": { "dataSource": "DataSource", diff --git a/packages/rath-client/public/locales/zh-CN.json b/packages/rath-client/public/locales/zh-CN.json index d47638a6..e2918e3f 100644 --- a/packages/rath-client/public/locales/zh-CN.json +++ b/packages/rath-client/public/locales/zh-CN.json @@ -7,7 +7,14 @@ "settings": "设置", "history": "历史记录", "hide": "隐藏", - "expand": "展开" + "expand": "展开", + "filter": "筛选", + "semanticType": { + "nominal": "类别类型", + "ordinal": "有序类型", + "temporal": "时间类型", + "quantitative": "数值类型" + } }, "menu": { "dataSource": "数据源", diff --git a/packages/rath-client/src/components/fieldFilter/index.tsx b/packages/rath-client/src/components/fieldFilter/index.tsx index 8b8238f3..fcf7f46d 100644 --- a/packages/rath-client/src/components/fieldFilter/index.tsx +++ b/packages/rath-client/src/components/fieldFilter/index.tsx @@ -2,12 +2,13 @@ import { useId } from '@uifabric/react-hooks'; import produce from 'immer'; import { toJS } from 'mobx'; import { observer } from 'mobx-react-lite'; -import { Callout, ChoiceGroup, DefaultButton, IconButton, PrimaryButton, Stack, Selection, SelectionMode, Toggle } from 'office-ui-fabric-react'; +import { Callout, ChoiceGroup, DefaultButton, PrimaryButton, Stack, Selection, SelectionMode, Toggle, ActionButton } from 'office-ui-fabric-react'; import React, { useCallback, useMemo, useState } from 'react'; import { IFilter } from '../../interfaces'; import { useGlobalStore } from '../../store'; import RangeSelection from './rangeSelection'; import SetSelection from './setSelection'; +import intl from 'react-intl-universal'; interface FieldFilterProps { @@ -75,8 +76,8 @@ const FieldFilter: React.FC = props => { }, []) return
- diff --git a/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx b/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx index e1835bd0..4264753b 100644 --- a/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx +++ b/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx @@ -111,7 +111,7 @@ const HeaderCell: React.FC = props => { }}> {DataTypeOptions.map((op) => ( ))} diff --git a/packages/rath-client/src/pages/dataSource/metaView/metaList.tsx b/packages/rath-client/src/pages/dataSource/metaView/metaList.tsx index f32d3291..e51d0fd2 100644 --- a/packages/rath-client/src/pages/dataSource/metaView/metaList.tsx +++ b/packages/rath-client/src/pages/dataSource/metaView/metaList.tsx @@ -100,6 +100,11 @@ const MetaItem: React.FC = props => { ...ch, text: intl.get(`common.${ch.key}`) })) + + const SEMANTIC_TYPE_CHOICES_LANG: IChoiceGroupOption[] = SEMANTIC_TYPE_CHOICES.map(ch => ({ + ...ch, + text: intl.get(`common.semanticType.${ch.key}`) + })) return
@@ -130,7 +135,7 @@ const MetaItem: React.FC = props => {
{ onChange && option && onChange(colKey, 'semanticType', option.key) From 1c114c824c9e8b1534a158475dfed7c21645553b Mon Sep 17 00:00:00 2001 From: jojocys Date: Wed, 14 Sep 2022 17:05:54 +0800 Subject: [PATCH 3/4] fix: distibution mini chart style bug --- .../src/components/dropDownSelect.tsx | 2 +- .../dataTable/distributionMiniChart.tsx | 77 --------- .../pages/dataSource/dataTable/headerCell.tsx | 148 ++++++++++-------- .../src/pages/dataSource/dataTable/index.tsx | 3 + .../src/pages/dataSource/index.tsx | 1 - .../pages/dataSource/metaView/distChart.tsx | 2 +- 6 files changed, 88 insertions(+), 145 deletions(-) delete mode 100644 packages/rath-client/src/pages/dataSource/dataTable/distributionMiniChart.tsx diff --git a/packages/rath-client/src/components/dropDownSelect.tsx b/packages/rath-client/src/components/dropDownSelect.tsx index 4142b3f7..86cf91da 100644 --- a/packages/rath-client/src/components/dropDownSelect.tsx +++ b/packages/rath-client/src/components/dropDownSelect.tsx @@ -46,7 +46,7 @@ const Cont = styled.div<{border?: boolean}>` font-size: inherit; height: 100%; outline: none; - padding-left: 7px; + padding-left: ${props => props.border ? '7px' : '0px'}; width: 100%; } ` diff --git a/packages/rath-client/src/pages/dataSource/dataTable/distributionMiniChart.tsx b/packages/rath-client/src/pages/dataSource/dataTable/distributionMiniChart.tsx deleted file mode 100644 index 1cb582c8..00000000 --- a/packages/rath-client/src/pages/dataSource/dataTable/distributionMiniChart.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import React, { useRef, useEffect } from 'react'; -import embed from 'vega-embed'; -import { ISemanticType } from 'visual-insights'; -import { IRow } from '../../../interfaces'; -export interface DistributionChartProps { - fieldType: ISemanticType; - x: string; - y: string; - dataSource: IRow[] -} - -const DistributionChart: React.FC = (props) => { - const chart = useRef(null); - const { x, y, dataSource, fieldType } = props; - useEffect(() => { - if (chart.current) { - let values: typeof dataSource = []; - let hasIndex = false; - if (fieldType === 'ordinal' && dataSource.some(member => { - return /(\[|\()-?([0-9.]+|Infinity),\s*([0-9.]+|Infinity)(\]|\))/.test(member.memberName) - })) { - values = dataSource.map(member => { - hasIndex = true; - let result = /(\[|\()(?-?([0-9.]+|Infinity)),\s*([0-9.]+|Infinity)(\]|\))/.exec(member.memberName); - - return { - ...member, - index: result === null ? member.name : Number(result.groups!.left) - } - }) - } else { - values = dataSource - } - values = values.slice(0, 100) - let sortBy: string | undefined | any = undefined; - if (fieldType === 'nominal') { - sortBy = '-y' - } else if (fieldType === 'ordinal' && hasIndex) { - sortBy = { field: 'index' } - } - const resultPromise = embed(chart.current, { - background: 'rgba(0,0,0,0)', - data: { - values - }, - view: { - stroke: null, - fill: null - }, - height: 80, - width: 180, - mark: ['quantitative', 'temporal'].includes(fieldType) ? 'line' : 'bar', - encoding: { - x: { - field: x, - title: null, - axis: null, - type: fieldType, sort: sortBy - }, - y: { field: y, type: 'quantitative', aggregate: 'sum', title: null, axis: null } - } - }, { - actions: false - }) - return () => { - resultPromise.then(res => { - if (res) { - res.finalize() - } - }).catch(console.error) - } - } - }, [x, y, dataSource, fieldType]) - return
-} - -export default DistributionChart; \ No newline at end of file diff --git a/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx b/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx index 4264753b..5551e030 100644 --- a/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx +++ b/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx @@ -1,7 +1,6 @@ import React, { useMemo, useState } from 'react'; import styled from 'styled-components'; import intl from 'react-intl-universal'; -// import DistributionMiniChart from './distributionMiniChart'; import DistributionChart from '../metaView/distChart'; import DropdownSelect from '../../../components/dropDownSelect' import { IFieldMeta, IRawField } from '../../../interfaces'; @@ -18,6 +17,12 @@ const HeaderCellContainer = styled.div` right: 0px; top: 0px; margin: 0px 1px; + } + .info-container{ + min-height: 50px; + } + .viz-container{ + } .dim { background-color: #1890ff; @@ -32,9 +37,17 @@ const HeaderCellContainer = styled.div` margin-top: 0px; margin-bottom: 0px; } + .checkbox-container{ + display: flex; + items-align: center; + margin-top: 2px; + label{ + margin-right: 6px; + } + } `; -function getClassName (type: 'dimension' | 'measure', disable: boolean) { +function getClassName(type: 'dimension' | 'measure', disable: boolean) { if (disable) return 'disable' return type === "dimension" ? "dim" : "mea" } @@ -56,7 +69,7 @@ const DataTypeOptions: IOption[] = [ { key: 'temporal', text: 'temporal' } ] -function useBIFieldTypeOptions (): IOption[] { +function useBIFieldTypeOptions(): IOption[] { const dimensionLabel = intl.get('meta.dimension'); const measureLabel = intl.get('meta.measure'); const options = useMemo[]>(() => { @@ -75,76 +88,81 @@ const HeaderCell: React.FC = props => { const buttonId = useId('edit-button'); return ( -

- {name} - { - setShowNameEditor(true) - }} - /> - {meta && meta.geoRole !== 'none' && 'lalal'} +
+

+ {name} + { + setShowNameEditor(true) + }} + /> + {meta && meta.geoRole !== 'none' && 'lalal'} + { + meta && meta.geoRole !== 'none' && + } +

{ - meta && meta.geoRole !== 'none' && - } -

- { - showNameEditor && { setShowNameEditor(false); }} - > -
-

{intl.get('dataSource.table.edit')}

+ showNameEditor && { setShowNameEditor(false); }} + >
- { - onChange && onChange(code, 'name', `${val}`) - }} /> +

{intl.get('dataSource.table.edit')}

+
+ { + onChange && onChange(code, 'name', `${val}`) + }} /> +
-
-
- } - {meta && ( - { - if (onChange) { - onChange(code, 'semanticType', e.target.value as ISemanticType) - } - }}> - {DataTypeOptions.map((op) => ( - - ))} - - )} - { - { - if (onChange) { - // FIXME: 弱约束问题 - onChange(code, 'analyticType', e.target.value as IAnalyticType); - } - }}> - { - optionsOfBIFieldType.map(op => ) - } - - } -
- - { - onChange && onChange(code, 'disable', !e.target.checked) - }} /> + + } + {meta && ( + { + if (onChange) { + onChange(code, 'semanticType', e.target.value as ISemanticType) + } + }}> + {DataTypeOptions.map((op) => ( + + ))} + + )} + { + { + if (onChange) { + // FIXME: 弱约束问题 + onChange(code, 'analyticType', e.target.value as IAnalyticType); + } + }}> + { + optionsOfBIFieldType.map(op => ) + } + + } +
+ + { + onChange && onChange(code, 'disable', !e.target.checked) + }} /> +
+
+
+ {meta && }
{/* { onChange && onChange(code, 'disable', !isChecked) }} /> */} {/* {meta && } */} - {meta && } +
); diff --git a/packages/rath-client/src/pages/dataSource/dataTable/index.tsx b/packages/rath-client/src/pages/dataSource/dataTable/index.tsx index 0a175d5d..d70bf56b 100644 --- a/packages/rath-client/src/pages/dataSource/dataTable/index.tsx +++ b/packages/rath-client/src/pages/dataSource/dataTable/index.tsx @@ -12,6 +12,9 @@ const CustomBaseTable = styled(BaseTable)` .${Classes.tableHeaderCell} { position: relative; } + thead{ + vertical-align: top; + } `; const TableInnerStyle = { diff --git a/packages/rath-client/src/pages/dataSource/index.tsx b/packages/rath-client/src/pages/dataSource/index.tsx index 6fcf873d..463d3196 100644 --- a/packages/rath-client/src/pages/dataSource/index.tsx +++ b/packages/rath-client/src/pages/dataSource/index.tsx @@ -262,7 +262,6 @@ const DataSourceBoard: React.FC = (props) => { /> - {intl.get('dataSource.recordCount', { count: cleanedData.length })}
{intl.get('dataSource.rowsInViews', { origin: rawData.length, select: filteredData.length, clean: cleanedData.length })}
({ - [valueField]: `[${i + 1}]${Math.round(_min + i * step)}`, + [valueField]: Math.round(_min + i * step), [ctField]: b })) } From 0c193309d26574f3c34a9a3edcc30e9be9e29f23 Mon Sep 17 00:00:00 2001 From: jojocys Date: Wed, 14 Sep 2022 17:09:42 +0800 Subject: [PATCH 4/4] fix: column name font-size --- .../rath-client/src/pages/dataSource/dataTable/headerCell.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx b/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx index 5551e030..4941651c 100644 --- a/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx +++ b/packages/rath-client/src/pages/dataSource/dataTable/headerCell.tsx @@ -36,6 +36,8 @@ const HeaderCellContainer = styled.div` .header{ margin-top: 0px; margin-bottom: 0px; + font-size: 18px; + line-height: 36px; } .checkbox-container{ display: flex;