From 0341327d294d7b84c742e12735e4ec9c47f0706e Mon Sep 17 00:00:00 2001 From: jojocys Date: Wed, 23 Nov 2022 22:03:46 +0800 Subject: [PATCH] fix: stat err --- README.md | 4 +++ citations.md | 3 +- package.json | 2 +- packages/rath-client/src/App.tsx | 2 -- .../rath-client/src/components/imgCorp.tsx | 35 ------------------- .../src/components/userSettings.tsx | 4 +-- .../rath-client/src/lib/meta/fieldMeta.ts | 13 ++++--- .../src/pages/loginInfo/header.tsx | 1 - packages/rath-client/src/store/commonStore.ts | 20 ++++------- packages/rath-client/src/utils/user.ts | 24 +------------ 10 files changed, 26 insertions(+), 82 deletions(-) delete mode 100644 packages/rath-client/src/components/imgCorp.tsx diff --git a/README.md b/README.md index 9deefd7d..2c5e447f 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,10 @@ Welcome to the [Kanaries RATH](https://kanaries.net/). We are so excited to have - 🎨 [Data painter](https://kanaries.net/docs/data-painter): An interactive, instinctive yet powerful tool for exploratory data analysis by directly coloring your data, with further analytical features. +- :bar_chart: Dashboard: build beautiful interactive data dashboard. + +- :construction: Causal Analysis: Provide causal discovery and explainations for complex relation analysis. + - 🎓 Wanna learn more about RATH? Visit our [Free online Courses](https://kanaries.net/docs/rath-academy): Access learning materials, detailed instructions and skill tests for **FREE**! ## Share with the community diff --git a/citations.md b/citations.md index 0b955fd1..238a0825 100644 --- a/citations.md +++ b/citations.md @@ -6,4 +6,5 @@ Rath is insipired by several excellent works below: + [3] Wongsuphasawat, Kanit, et al. "Voyager 2: Augmenting visual analysis with partial view specifications." Proceedings of the 2017 CHI Conference on Human Factors in Computing Systems. ACM, 2017. + [4] B. Tang et al, "Extracting top-K insights from multi-dimensional data," in 2017, . DOI: 10.1145/3035918.3035922. + [5] Vega-Lite: A Grammar of Interactive Graphics. Arvind Satyanarayan, Dominik Moritz, Kanit Wongsuphasawat, Jeffrey Heer. IEEE Trans. Visualization & Comp. Graphics (Proc. InfoVis), 2017 -+ [6] Kim, Younghoon, et al. "Graphscape: A model for automated reasoning about visualization similarity and sequencing." Proceedings of the 2017 CHI conference on human factors in computing systems. 2017. \ No newline at end of file ++ [6] Kim, Younghoon, et al. "Graphscape: A model for automated reasoning about visualization similarity and sequencing." Proceedings of the 2017 CHI conference on human factors in computing systems. 2017. ++ [7] Amit Sharma, Emre Kiciman. DoWhy: An End-to-End Library for Causal Inference. 2020. https://arxiv.org/abs/2011.04216 \ No newline at end of file diff --git a/package.json b/package.json index c2d7f64b..9615ccc7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "Rath", + "name": "rath", "private": true, "version": "1.0.0", "description": "![](https://img.shields.io/github/license/Kanaries/Rath)", diff --git a/packages/rath-client/src/App.tsx b/packages/rath-client/src/App.tsx index d7872a38..b8876cea 100644 --- a/packages/rath-client/src/App.tsx +++ b/packages/rath-client/src/App.tsx @@ -21,9 +21,7 @@ import CausalPage from './pages/causal'; import PerformanceWindow from './components/performance-window'; import LoginInfo from './pages/loginInfo'; import Account from './pages/loginInfo/account'; -import Info from './pages/loginInfo/info'; import Setup from './pages/loginInfo/setup'; -import Header from './pages/loginInfo/header'; export enum PreferencesType { Account = 'account', diff --git a/packages/rath-client/src/components/imgCorp.tsx b/packages/rath-client/src/components/imgCorp.tsx deleted file mode 100644 index b6647188..00000000 --- a/packages/rath-client/src/components/imgCorp.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React, { useRef } from "react"; -import Cropper from "react-cropper"; -import "cropperjs/dist/cropper.css"; -interface CorpProps { - imgUrl: string; - onChangeFileImg: (file: any) => void; -} -const Corp: React.FC = (props) => { - const cropperRef = useRef(null); - const { imgUrl, onChangeFileImg } = props; - const onCrop = (event: CustomEvent) => { - const imageElement: any = cropperRef?.current; - const cropper: any = imageElement?.cropper; - cropper.getCroppedCanvas().toBlob((blob: BlobPart) => { - const file = new File([blob], "head.jpg"); - onChangeFileImg(file); - }); - }; - - return ( - - ); -}; -export default Corp; diff --git a/packages/rath-client/src/components/userSettings.tsx b/packages/rath-client/src/components/userSettings.tsx index 8b61e599..a5c16bc9 100644 --- a/packages/rath-client/src/components/userSettings.tsx +++ b/packages/rath-client/src/components/userSettings.tsx @@ -24,7 +24,7 @@ const UserSettings: React.FC = () => { - {/* {navMode === 'text' && ( + {navMode === 'text' && ( { ))} - )} */} + )}
v > 0))); maxEnt = Math.log2(dist.length); - const sum = values.reduce((t, v) => t + v, 0); - const mean = sum / values.length; + let i = 0; + let size = values.length; + for (i = 0; i < size; i++) { + sum += values[i]; + } + mean = sum / size; for (let i = 0; i < values.length; i++) { s += (values[i] - mean) ** 2; } @@ -43,7 +48,7 @@ export function computeFieldFeatures(values: any[], semanticType: ISemanticType) max: _max, min: _min, sum: sum, - mean: sum / values.length, + mean: mean, count: values.length, stdev: s, qt_25, diff --git a/packages/rath-client/src/pages/loginInfo/header.tsx b/packages/rath-client/src/pages/loginInfo/header.tsx index e694233c..f3441e6f 100644 --- a/packages/rath-client/src/pages/loginInfo/header.tsx +++ b/packages/rath-client/src/pages/loginInfo/header.tsx @@ -4,7 +4,6 @@ import intl from 'react-intl-universal'; import styled from 'styled-components'; import { getDefaultAvatarURL, AVATAR_IMG_LIST, IAVATAR_TYPES } from '../../utils/user'; import { useGlobalStore } from '../../store'; -// import Corp from '../../components/imgCorp'; // enum HeaderList { // upload = 'Upload', // default = 'Default', diff --git a/packages/rath-client/src/store/commonStore.ts b/packages/rath-client/src/store/commonStore.ts index 320f469e..15366a07 100644 --- a/packages/rath-client/src/store/commonStore.ts +++ b/packages/rath-client/src/store/commonStore.ts @@ -2,7 +2,7 @@ import { makeAutoObservable, observable, runInAction } from 'mobx'; import { Specification } from 'visual-insights'; import { COMPUTATION_ENGINE, EXPLORE_MODE, PIVOT_KEYS } from '../constants'; import { IAccessPageKeys, ITaskTestMode, IVegaSubset } from '../interfaces'; -import { clearLoginCookie, getAvatarURL, getServerUrl, setLoginCookie, AVATAR_IMG_LIST, IAVATAR_TYPES } from '../utils/user'; +import { getAvatarURL, getServerUrl, AVATAR_IMG_LIST, IAVATAR_TYPES } from '../utils/user'; import { destroyRathWorker, initRathWorker, rathEngineService } from '../services/index'; import { transVegaSubset2Schema } from '../utils/transform'; import { notify } from '../components/error'; @@ -187,7 +187,7 @@ export class CommonStore { } else { notify({ type: 'error', - content: result.message, + content: `${result.message}`, title: 'Error', }); throw new Error(`${result.message}`); @@ -198,14 +198,12 @@ export class CommonStore { try { const res = await commitLoginService(this.login); if (res) { - setLoginCookie(this.login.userName); this.userName = this.login.userName; } return res; } catch (error) { - // console.error(error); notify({ - title: '发生错误', + title: 'Login error', type: 'error', content: `[/api/login] ${error}`, }); @@ -218,23 +216,19 @@ export class CommonStore { const res = await fetch(url, { method: 'GET', }); - console.log(res, 'Res'); if (res) { - clearLoginCookie(); runInAction(() => { this.userName = null; }); notify({ - title: '您已登出', - type: 'warning', - content: '您已登出,登出期间无法访问部分产品功能。', + title: 'Logout', + type: 'success', + content: 'Logout success!', }); - } else { - // throw '登出失败'; } } catch (error) { notify({ - title: '发生错误', + title: 'logout error', type: 'error', content: `[/api/logout] ${error}`, }); diff --git a/packages/rath-client/src/utils/user.ts b/packages/rath-client/src/utils/user.ts index f4a60476..50e0144f 100644 --- a/packages/rath-client/src/utils/user.ts +++ b/packages/rath-client/src/utils/user.ts @@ -1,7 +1,3 @@ -import md5 from "crypto-js/md5"; -import Cookies from 'js-cookie'; - - export enum IAVATAR_TYPES { gravatar = 'gravatar', default = 'default' @@ -20,23 +16,6 @@ export const AVATAR_IMG_LIST: string[] = new Array(18) export const DEFAULT_AVATAR_URL_PREFIX = 'https://foghorn-assets.s3.ap-northeast-1.amazonaws.com/avatar/'; -const AUTH_COOKIE_KEY = 'userAuthed'; - -export function setLoginCookie(userName: string) { - Cookies.set(AUTH_COOKIE_KEY, userName, { expires: 1 }); -} -export function checkLoginCookie() { - const userName = Cookies.get(AUTH_COOKIE_KEY); - if (userName && userName !== '') { - return userName; - } - return null; -} - -export function clearLoginCookie() { - Cookies.remove(AUTH_COOKIE_KEY); -} - export function getServerUrl(path: string) { const baseURL = new URL(window.location.href); const DATA_SERVER_URL = @@ -61,7 +40,6 @@ type AvatarProps = { export function getAvatarURL(props: AvatarProps) { if (props.avatarType === IAVATAR_TYPES.default) { return `${DEFAULT_AVATAR_URL_PREFIX}${props.size}/${props.avatarKey}` - } else { - return `https://www.gravatar.com/avatar/${md5(props.email.toLowerCase()).toString()}`; } + return '' }