Skip to content

Commit

Permalink
fix: stat err
Browse files Browse the repository at this point in the history
  • Loading branch information
jojocys committed Nov 23, 2022
1 parent 38b7be3 commit 0341327
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 82 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion citations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
+ [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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Rath",
"name": "rath",
"private": true,
"version": "1.0.0",
"description": "![](https://img.shields.io/github/license/Kanaries/Rath)",
Expand Down
2 changes: 0 additions & 2 deletions packages/rath-client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
35 changes: 0 additions & 35 deletions packages/rath-client/src/components/imgCorp.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions packages/rath-client/src/components/userSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const UserSettings: React.FC = () => {
<Container
style={navMode === 'icon' ? { flexDirection: 'column' } : { flexDirection: 'row', alignItems: 'center' }}
>
{/* {navMode === 'text' && (
{navMode === 'text' && (
<DropdownSelect
border
value={langStore.lang}
Expand All @@ -38,7 +38,7 @@ const UserSettings: React.FC = () => {
</option>
))}
</DropdownSelect>
)} */}
)}
<div ref={target}>
<ActionButton
text={commonStore.navMode === 'text' ? intl.get('preference.title') : ''}
Expand Down
13 changes: 9 additions & 4 deletions packages/rath-client/src/lib/meta/fieldMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ export function computeFieldFeatures(values: any[], semanticType: ISemanticType)
sum = 0,
qt_25 = 0,
qt_50 = 0,
qt_75 = 0;
qt_75 = 0,
mean = 0;

if (semanticType === 'quantitative') {
ent = Statistics.entropy(rangeNormilize(bin(values).filter((v) => 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;
}
Expand All @@ -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,
Expand Down
1 change: 0 additions & 1 deletion packages/rath-client/src/pages/loginInfo/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 7 additions & 13 deletions packages/rath-client/src/store/commonStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -187,7 +187,7 @@ export class CommonStore {
} else {
notify({
type: 'error',
content: result.message,
content: `${result.message}`,
title: 'Error',
});
throw new Error(`${result.message}`);
Expand All @@ -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}`,
});
Expand All @@ -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}`,
});
Expand Down
24 changes: 1 addition & 23 deletions packages/rath-client/src/utils/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import md5 from "crypto-js/md5";
import Cookies from 'js-cookie';


export enum IAVATAR_TYPES {
gravatar = 'gravatar',
default = 'default'
Expand All @@ -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 =
Expand All @@ -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 ''
}

0 comments on commit 0341327

Please sign in to comment.