diff --git a/frontend/packages/core/src/components/Audio.tsx b/frontend/packages/core/src/components/Audio.tsx index 4ced348466164952f3fb1d543098318b51cca18f..cb681d22b93ee0a83aee8ac2592d6e55a4313402 100644 --- a/frontend/packages/core/src/components/Audio.tsx +++ b/frontend/packages/core/src/components/Audio.tsx @@ -48,7 +48,7 @@ const Container = styled.div` cursor: pointer; ${transitionProps('color')} - &.volumn { + &.volume { font-size: ${rem(20)}; ${size(rem(20), rem(20))} } @@ -80,7 +80,7 @@ const Container = styled.div` } `; -const VolumnSlider = styled(Slider)` +const VolumeSlider = styled(Slider)` margin: ${rem(15)} ${rem(18)}; width: ${rem(4)}; height: ${rem(100)}; @@ -170,7 +170,7 @@ const Audio: FunctionComponent = ({ const [duration, setDuration] = useState('00:00'); const [decoding, setDecoding] = useState(false); const [playing, setPlaying] = useState(false); - const [volumn, setVolumn] = useState(100); + const [volume, setVolume] = useState(100); const [playAfterSeek, setPlayAfterSeek] = useState(false); const play = useCallback(() => player.current?.play(), []); @@ -199,7 +199,7 @@ const Audio: FunctionComponent = ({ const toggleMute = useCallback(() => { if (player.current) { player.current.toggleMute(); - setVolumn(player.current.volumn); + setVolume(player.current.volume); } }, []); @@ -228,9 +228,9 @@ const Audio: FunctionComponent = ({ useEffect(() => { if (player.current) { - player.current.volumn = volumn; + player.current.volume = volume; } - }, [volumn]); + }, [volume]); useEffect(() => { let p: AudioPlayer | null = null; @@ -269,15 +269,15 @@ const Audio: FunctionComponent = ({ }; }, [data, startTimer, stopTimer, onLoading, onLoad, audioContext]); - const volumnIcon = useMemo(() => { - if (volumn === 0) { + const volumeIcon = useMemo(() => { + if (volume === 0) { return 'mute'; } - if (volumn <= 50) { - return 'volumn-low'; + if (volume <= 50) { + return 'volume-low'; } - return 'volumn'; - }, [volumn]); + return 'volume'; + }, [volume]); if (loading) { return ; @@ -313,18 +313,18 @@ const Audio: FunctionComponent = ({ interactive hideOnClick={false} content={ - } > - - + + diff --git a/frontend/packages/core/src/components/ScalarPage/ScalarChart.tsx b/frontend/packages/core/src/components/ScalarPage/ScalarChart.tsx index 118c49c778e9b8966f1679144dd79eba4206dad2..0bd5209745ad0cde45aa07436ab33c87634fc901 100644 --- a/frontend/packages/core/src/components/ScalarPage/ScalarChart.tsx +++ b/frontend/packages/core/src/components/ScalarPage/ScalarChart.tsx @@ -201,7 +201,8 @@ const ScalarChart: FunctionComponent = ({ const formatter = useCallback( (params: EChartOption.Tooltip.Format | EChartOption.Tooltip.Format[]) => { const series: Dataset[number] = Array.isArray(params) ? params[0].data : params.data; - const points = nearestPoint(smoothedDatasets ?? [], runs, series[1]).map((point, index) => ({ + const idx = xAxisMap[xAxis]; + const points = nearestPoint(smoothedDatasets ?? [], runs, idx, series[idx]).map((point, index) => ({ ...point, ...datasetRanges?.[index] })); @@ -212,7 +213,7 @@ const ScalarChart: FunctionComponent = ({ i.run)} columns={columns} data={data} /> ); }, - [smoothedDatasets, datasetRanges, runs, sortingMethod, maxStepLength, t, i18n] + [smoothedDatasets, datasetRanges, runs, sortingMethod, xAxis, maxStepLength, t, i18n] ); const options = useMemo( diff --git a/frontend/packages/core/src/resource/graph/types.ts b/frontend/packages/core/src/resource/graph/types.ts index 7753403b1f4816f3aad80c6e9f5d9a8f2adeec85..fd9bfaee3e77ddfb07195f2a7f41016435872c41 100644 --- a/frontend/packages/core/src/resource/graph/types.ts +++ b/frontend/packages/core/src/resource/graph/types.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export type Property = { name?: string; value: string; diff --git a/frontend/packages/core/src/resource/high-dimensional/index.ts b/frontend/packages/core/src/resource/high-dimensional/index.ts index 82bd774d80a74a8ac9a839707d48e333cff5fe9a..47b3e75f96f4e09ad0d9d7746524b19015bd540d 100644 --- a/frontend/packages/core/src/resource/high-dimensional/index.ts +++ b/frontend/packages/core/src/resource/high-dimensional/index.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import type {Point} from './types'; export type {Dimension, Reduction, Point} from './types'; diff --git a/frontend/packages/core/src/resource/high-dimensional/types.ts b/frontend/packages/core/src/resource/high-dimensional/types.ts index 94d50ad78977c5f058f6667001996fa3d8ad747e..9997d39a68c35311dde9188ccfa33c5ec8a383a2 100644 --- a/frontend/packages/core/src/resource/high-dimensional/types.ts +++ b/frontend/packages/core/src/resource/high-dimensional/types.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export type Dimension = '2d' | '3d'; export type Reduction = 'pca' | 'tsne'; diff --git a/frontend/packages/core/src/resource/histogram/chart.ts b/frontend/packages/core/src/resource/histogram/chart.ts index a5ac04d750a46aad2ef912368dc1f9bc0e6dbb3e..870c35cd0faaeccfc145ae2f6a347f0c2d2d1004 100644 --- a/frontend/packages/core/src/resource/histogram/chart.ts +++ b/frontend/packages/core/src/resource/histogram/chart.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import type {EChartOption, VisualMap} from 'echarts'; import type {Modes} from './types'; diff --git a/frontend/packages/core/src/resource/histogram/data.ts b/frontend/packages/core/src/resource/histogram/data.ts index 892cf707ee546888d91c6dbde6402b1f9fe19015..228904c7924fe83626ee1aeed637a06b84c0e4f3 100644 --- a/frontend/packages/core/src/resource/histogram/data.ts +++ b/frontend/packages/core/src/resource/histogram/data.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import type {HistogramData, OffsetData, OffsetDataItem, OverlayData, OverlayDataItem} from './types'; import {Modes} from './types'; diff --git a/frontend/packages/core/src/resource/histogram/index.ts b/frontend/packages/core/src/resource/histogram/index.ts index 1b6ef986e22cebb7ba66f96dd0ea3dc2076d7972..8d189220e67f31a6d1a312c5028b581657e13642 100644 --- a/frontend/packages/core/src/resource/histogram/index.ts +++ b/frontend/packages/core/src/resource/histogram/index.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {Modes} from './types'; export const modes = [Modes.Offset, Modes.Overlay] as const; diff --git a/frontend/packages/core/src/resource/histogram/types.ts b/frontend/packages/core/src/resource/histogram/types.ts index 9d2b22afb5612bc0b86f4e7bbd32739216db002e..5f3c224fcbc811ddecad0f8c389ee931a5072a05 100644 --- a/frontend/packages/core/src/resource/histogram/types.ts +++ b/frontend/packages/core/src/resource/histogram/types.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export enum Modes { Offset = 'offset', Overlay = 'overlay' diff --git a/frontend/packages/core/src/resource/pr-curve/chart.ts b/frontend/packages/core/src/resource/pr-curve/chart.ts index 1c9102036bd382b0154ae3f5cf5f51fa0cb45dfc..17935d16ee76f60c19331935672612dcd074eaed 100644 --- a/frontend/packages/core/src/resource/pr-curve/chart.ts +++ b/frontend/packages/core/src/resource/pr-curve/chart.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export const options = { legend: { data: [] diff --git a/frontend/packages/core/src/resource/pr-curve/data.ts b/frontend/packages/core/src/resource/pr-curve/data.ts index 04ad797d02cd780a2992b2a02a01ea1856e6c00e..2bc37f92607b151cfee856ff9247c7e6b634ec59 100644 --- a/frontend/packages/core/src/resource/pr-curve/data.ts +++ b/frontend/packages/core/src/resource/pr-curve/data.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export const nearestPoint = (data: number[][][], recall: number): number[][][] => { return data.map(series => { let delta = Number.POSITIVE_INFINITY; diff --git a/frontend/packages/core/src/resource/pr-curve/index.ts b/frontend/packages/core/src/resource/pr-curve/index.ts index 0491f1aa432ba0e07f4a923522813663704dddcf..5443bd336042ca955cc7bb96b391ba3ef2610423 100644 --- a/frontend/packages/core/src/resource/pr-curve/index.ts +++ b/frontend/packages/core/src/resource/pr-curve/index.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export type {PRCurveData, Run, StepInfo, Tag} from './types'; export {TimeType} from './types'; export * from './chart'; diff --git a/frontend/packages/core/src/resource/pr-curve/types.ts b/frontend/packages/core/src/resource/pr-curve/types.ts index 373f73418df04a7bc0329caed33166a4d7ff2676..5926c362ffdf6bc99e4dd27ebde57d609670c092 100644 --- a/frontend/packages/core/src/resource/pr-curve/types.ts +++ b/frontend/packages/core/src/resource/pr-curve/types.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {Run as BaseRun, Tag as BaseTag, TimeMode} from '~/types'; export {TimeMode as TimeType}; diff --git a/frontend/packages/core/src/resource/scalar/chart.ts b/frontend/packages/core/src/resource/scalar/chart.ts index 2a83499c6e54ae7451a3931285c5ee75155d6c48..5ea581092bbb0fe144293f568f2cba71e9562541 100644 --- a/frontend/packages/core/src/resource/scalar/chart.ts +++ b/frontend/packages/core/src/resource/scalar/chart.ts @@ -1,13 +1,52 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// cSpell:words maxs coord + import type {Dataset, Range, TooltipData, XAxis} from './types'; import type I18n from 'i18next'; import type {Run} from '~/types'; import {format} from 'd3-format'; import {formatTime} from '~/utils'; +import moment from 'moment'; import {xAxisMap} from './index'; const valueFormatter = format('.5'); +const humanizeDuration = (ms: number) => { + const time = moment.duration(ms); + const hour = time.hours(); + if (hour) { + time.subtract(hour, 'hour'); + } + const minute = time.minutes(); + if (minute) { + time.subtract(minute, 'minute'); + } + const second = time.asSeconds(); + let str = Math.floor(second) + 's'; + if (hour) { + str = `${hour}h${minute}m${str}`; + } else if (minute) { + str = `${minute}m${str}`; + } + return str; +}; + export const options = { legend: { data: [] @@ -35,7 +74,7 @@ export const chartData = ({ // smoothed data: // [0] wall time // [1] step - // [2] orginal value + // [2] original value // [3] smoothed value // [4] relative const name = runs[i].label; @@ -144,7 +183,7 @@ export const tooltip = (data: TooltipData[], stepLength: number, i18n: typeof I1 valueFormatter(min ?? Number.NaN), valueFormatter(max ?? Number.NaN), formatTime(item[0], i18n.language), - Math.floor(item[4] * 60 * 60) + 's' + humanizeDuration(item[4]) ]) }; }; diff --git a/frontend/packages/core/src/resource/scalar/data.ts b/frontend/packages/core/src/resource/scalar/data.ts index fe47c37673b80f2d12a4a0126883a55f2987cb1b..8c61a9fd73753f7d734b2dc8cc5a254afee1ccf1 100644 --- a/frontend/packages/core/src/resource/scalar/data.ts +++ b/frontend/packages/core/src/resource/scalar/data.ts @@ -1,3 +1,21 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// cSpell:words quantile accum debias exponentiated + import type {Dataset, ScalarDataset} from './types'; import BigNumber from 'bignumber.js'; @@ -21,8 +39,8 @@ export const transform = ({datasets, smoothing}: {datasets: ScalarDataset[]; smo if (i === 0) { startValue = millisecond; } - // relative time, millisecond to hours. - d[4] = Math.floor(millisecond - startValue) / (60 * 60 * 1000); + // relative time in millisecond. + d[4] = Math.floor(millisecond - startValue); if (!nextVal.isFinite()) { d[3] = nextVal.toNumber(); } else { @@ -65,12 +83,12 @@ export const range = ({datasets}: {datasets: Dataset[]}) => { export const axisRange = ({datasets, outlier}: {datasets: Dataset[]; outlier: boolean}) => { const ranges = compact( datasets?.map(dataset => { - if (dataset.length == 0) { - return; + if (dataset.length === 0) { + return void 0; } const values = dataset.map(v => v[2]); if (!outlier) { - // Get the orgin data range. + // Get the origin data range. return { min: Math.min(...values) ?? 0, max: Math.max(...values) ?? 0 @@ -97,32 +115,23 @@ export const axisRange = ({datasets, outlier}: {datasets: Dataset[]; outlier: bo } }; -export const nearestPoint = (data: Dataset[], runs: Run[], step: number) => - data.map((series, index) => { - let nearestItem; - if (step === 0) { - nearestItem = series[0]; - } else { - for (let i = 0; i < series.length; i++) { - const item = series[i]; - if (item[1] === step) { - nearestItem = item; - break; - } - if (item[1] > step) { - nearestItem = series[i - 1 >= 0 ? i - 1 : 0]; - break; - } - if (!nearestItem) { - nearestItem = series[series.length - 1]; - } +export const nearestPoint = (data: Dataset[], runs: Run[], idx: number, value: number) => { + const result: {run: Run; item: Dataset[number]}[] = []; + data.forEach((series, index) => { + const run = runs[index]; + let d = Number.POSITIVE_INFINITY; + let dv = value; + for (let i = 0; i < series.length; i++) { + const dd = Math.abs(series[i][idx] - value); + if (d > dd) { + d = dd; + dv = series[i][idx]; } } - return { - run: runs[index], - item: nearestItem || [0, 0, 0, 0, 0] - }; + result.push(...series.filter(s => s[idx] === dv).map(item => ({run, item}))); }); + return result; +}; export const parseSmoothing = (value: unknown) => { const parsedValue = Number.parseFloat(String(value)); diff --git a/frontend/packages/core/src/resource/scalar/index.ts b/frontend/packages/core/src/resource/scalar/index.ts index 7a98dd050ccb61c513bed8c4660667dbda3c377f..2bebdba5b96bc50d684cb97390233a09d8ba24ac 100644 --- a/frontend/packages/core/src/resource/scalar/index.ts +++ b/frontend/packages/core/src/resource/scalar/index.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {SortingMethod as SM, XAxis} from './types'; import type {TooltipData} from './types'; @@ -14,7 +30,7 @@ export const sortingMethodMap: Record points, [SM.Descending]: (points: TooltipData[]) => sortBy(points, point => point.item[3]).reverse(), [SM.Ascending]: (points: TooltipData[]) => sortBy(points, point => point.item[3]), - // Compare other ponts width the trigger point, caculate the nearest sort. + // Compare other points width the trigger point, calculate the nearest sort. [SM.Nearest]: (points: TooltipData[], data: number[]) => sortBy(points, point => point.item[3] - data[2]) } as const; diff --git a/frontend/packages/core/src/resource/scalar/types.ts b/frontend/packages/core/src/resource/scalar/types.ts index 05f61dcd050e1bc09252f0f66a58ceb5377fa48f..429509f6fdac78633ea7341b5f4f5eb08555cc2e 100644 --- a/frontend/packages/core/src/resource/scalar/types.ts +++ b/frontend/packages/core/src/resource/scalar/types.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {Run, TimeMode} from '~/types'; type Value = number; diff --git a/frontend/packages/core/src/types/index.ts b/frontend/packages/core/src/types/index.ts index 75ce5880b993a93043ddd739bb77431bb4368744..5d4cef8d8ecc4e9fccbc934966a619c4e846cb39 100644 --- a/frontend/packages/core/src/types/index.ts +++ b/frontend/packages/core/src/types/index.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export interface TagsData { runs: string[]; tags: string[][]; diff --git a/frontend/packages/core/src/utils/audio.ts b/frontend/packages/core/src/utils/audio.ts index 919ec37936f355c2f0e12a9183ca0299eb792e54..259b2dae0b3ab554a9ad93079867654264b258a7 100644 --- a/frontend/packages/core/src/utils/audio.ts +++ b/frontend/packages/core/src/utils/audio.ts @@ -1,6 +1,22 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + interface AudioPlayerOptions { context?: AudioContext; - volumn?: number; + volume?: number; onplay?: () => void; onstop?: () => void; } @@ -17,7 +33,7 @@ export class AudioPlayer { private stopAt = 0; private offset = 0; - private toggleVolumn = 100; + private toggleVolume = 100; public playing = false; @@ -44,10 +60,10 @@ export class AudioPlayer { return this.decodedSampleRate; } - get volumn() { + get volume() { return this.gain.gain.value * 100; } - set volumn(value: number) { + set volume(value: number) { if (value > 100) { value = 100; } else if (value < 0) { @@ -59,7 +75,7 @@ export class AudioPlayer { constructor(options?: AudioPlayerOptions) { this.options = { context: options?.context ?? new AudioContext(), - volumn: 100, + volume: 100, onplay: () => void 0, onstop: () => void 0, ...options @@ -67,7 +83,7 @@ export class AudioPlayer { this.contextFromOptions = !!options?.context; this.context = this.options.context; this.gain = this.context.createGain(); - this.volumn = this.options.volumn; + this.volume = this.options.volume; } private reset() { @@ -208,11 +224,11 @@ export class AudioPlayer { } toggleMute() { - if (this.volumn === 0) { - this.volumn = this.toggleVolumn || 100; + if (this.volume === 0) { + this.volume = this.toggleVolume || 100; } else { - this.toggleVolumn = this.volumn; - this.volumn = 0; + this.toggleVolume = this.volume; + this.volume = 0; } } diff --git a/frontend/packages/core/src/utils/chart.ts b/frontend/packages/core/src/utils/chart.ts index bea31251d1d49284e36f43b77204a36e57d0d595..33b9e8bb7aaa119fdc341aab0c272badbed01363 100644 --- a/frontend/packages/core/src/utils/chart.ts +++ b/frontend/packages/core/src/utils/chart.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {colors} from '~/utils/theme'; import {format} from 'd3-format'; diff --git a/frontend/packages/core/src/utils/event.ts b/frontend/packages/core/src/utils/event.ts index 227709375d7f123e1e91877685fcdaa10cfebb86..edb7010400e1ec4319af730641ab5b958152caed 100644 --- a/frontend/packages/core/src/utils/event.ts +++ b/frontend/packages/core/src/utils/event.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import EventEmitter from 'eventemitter3'; export default new EventEmitter(); diff --git a/frontend/packages/core/src/utils/fetch.ts b/frontend/packages/core/src/utils/fetch.ts index b48b684a4d307a0efc447cbca976ae141a24d324..979bb18a5ddb0944701f1ac21acdce2370f4b140 100644 --- a/frontend/packages/core/src/utils/fetch.ts +++ b/frontend/packages/core/src/utils/fetch.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import type {TFunction} from 'i18next'; import i18next from 'i18next'; import queryString from 'query-string'; diff --git a/frontend/packages/core/src/utils/i18n.ts b/frontend/packages/core/src/utils/i18n.ts index c7d22c4b9d1d2994fa7d3304ec40eb7a4484b10c..eaf991db3c14db57c4f25a47f241b918af3acd99 100644 --- a/frontend/packages/core/src/utils/i18n.ts +++ b/frontend/packages/core/src/utils/i18n.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import Fetch from 'i18next-fetch-backend'; import LanguageDetector from 'i18next-browser-languagedetector'; import i18n from 'i18next'; diff --git a/frontend/packages/core/src/utils/image.ts b/frontend/packages/core/src/utils/image.ts index 7fb11e5dfcb656e1fef89030a21158634f4bafa3..e93d9811a3185685069551a5fc7b86d91548c15b 100644 --- a/frontend/packages/core/src/utils/image.ts +++ b/frontend/packages/core/src/utils/image.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export function dataURL2Blob(base64: string): Blob { const parts = base64.split(';base64,'); const contentType = parts[0].split(':')[1]; diff --git a/frontend/packages/core/src/utils/index.ts b/frontend/packages/core/src/utils/index.ts index 2599313335ba3ea72b76d6efd98c0a23c8822e2b..22a54799ff06bdb03b757dacc8916cd60aca08f5 100644 --- a/frontend/packages/core/src/utils/index.ts +++ b/frontend/packages/core/src/utils/index.ts @@ -1,3 +1,21 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// cSpell:words quantile + import BigNumber from 'bignumber.js'; import moment from 'moment'; diff --git a/frontend/packages/core/src/utils/style.ts b/frontend/packages/core/src/utils/style.ts index ee3219075eb207b0fd0934b704974ae605871bcd..69f280766c27ca271fe2ac3489036e0306a7b87a 100644 --- a/frontend/packages/core/src/utils/style.ts +++ b/frontend/packages/core/src/utils/style.ts @@ -1,3 +1,21 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// cSpell:words pxval mixins grayscale + import 'tippy.js/dist/tippy.css'; import 'tippy.js/animations/shift-away-subtle.css'; import 'react-toastify/dist/ReactToastify.css'; diff --git a/frontend/packages/core/src/utils/theme.ts b/frontend/packages/core/src/utils/theme.ts index 26c3ae7010d107cec8e300a7ac1de8096e560373..bbd55762ad2446b5dd19bcc923de7eb80055025e 100644 --- a/frontend/packages/core/src/utils/theme.ts +++ b/frontend/packages/core/src/utils/theme.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {darken, lighten} from 'polished'; import {css} from 'styled-components'; diff --git a/frontend/packages/core/src/utils/wasm.ts b/frontend/packages/core/src/utils/wasm.ts index 6647d980b259d8313336c8ee92c55f36574bb933..313de1d60bad0bed76f0856ce4e02ba52e251dff 100644 --- a/frontend/packages/core/src/utils/wasm.ts +++ b/frontend/packages/core/src/utils/wasm.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2020 Baidu Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import * as funcs from '@visualdl/wasm'; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/frontend/packages/wasm/src/scalar.rs b/frontend/packages/wasm/src/scalar.rs index 8d2027c12fc848ca58b3469ac41f15cbcb94d69e..7c7358258d0bd91cbc0ca82d572dcf04d459b992 100644 --- a/frontend/packages/wasm/src/scalar.rs +++ b/frontend/packages/wasm/src/scalar.rs @@ -2,7 +2,7 @@ pub struct Dataset(f64, i64, f64); #[derive(Serialize, Deserialize)] -pub struct Smoothed(i64, i64, f64, f64, f64); +pub struct Smoothed(i64, i64, f64, f64, i64); #[derive(Serialize, Deserialize)] pub struct Range { @@ -44,7 +44,7 @@ pub fn transform(datasets: &Vec>, smoothing: f64) -> Vec>, smoothing: f64) -> Vec>, outlier: bool) -> Range { if ranges.len() != 0 { min = ranges .iter() - .min_by(|x, y| x.min.partial_cmp(&y.max).unwrap()) + .min_by(|x, y| x.min.partial_cmp(&y.min).unwrap()) .unwrap() .min; max = ranges