Skip to content

Commit

Permalink
fix: compatibility of safari (PaddlePaddle#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPanZH committed Jun 23, 2020
1 parent f31522f commit 62b4802
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 41 deletions.
21 changes: 2 additions & 19 deletions frontend/packages/core/components/LineChart.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
import * as chart from '~/utils/chart';

import React, {useEffect, useImperativeHandle} from 'react';
import {WithStyled, position, primaryColor, size} from '~/utils/style';
import {WithStyled, primaryColor} from '~/utils/style';
import useECharts, {Wrapper} from '~/hooks/useECharts';

import {EChartOption} from 'echarts';
import GridLoader from 'react-spinners/GridLoader';
import defaultsDeep from 'lodash/defaultsDeep';
import {formatTime} from '~/utils';
import styled from 'styled-components';
import useECharts from '~/hooks/useECharts';
import {useTranslation} from '~/utils/i18n';

const Wrapper = styled.div`
position: relative;
> .echarts {
height: 100%;
}
> .loading {
${size('100%')}
${position('absolute', 0, null, null, 0)}
display: flex;
justify-content: center;
align-items: center;
}
`;

type LineChartProps = {
options?: EChartOption;
title?: string;
Expand Down
23 changes: 2 additions & 21 deletions frontend/packages/core/components/StackChart.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
import * as chart from '~/utils/chart';

import React, {useCallback, useEffect, useImperativeHandle} from 'react';
import {WithStyled, position, primaryColor, size} from '~/utils/style';
import {WithStyled, primaryColor} from '~/utils/style';
import useECharts, {Wrapper} from '~/hooks/useECharts';

import {EChartOption} from 'echarts';
import GridLoader from 'react-spinners/GridLoader';
import {dataURL2Blob} from '~/utils/image';
import defaultsDeep from 'lodash/defaultsDeep';
import {saveAs} from 'file-saver';
import styled from 'styled-components';
import useECharts from '~/hooks/useECharts';
import {useTranslation} from '~/utils/i18n';

const Wrapper = styled.div`
position: relative;
> .echarts {
height: 100%;
}
> .loading {
${size('100%')}
${position('absolute', 0, null, null, 0)}
display: flex;
justify-content: center;
align-items: center;
}
`;

type renderItem = NonNullable<EChartOption.SeriesCustom['renderItem']>;
type renderItemArguments = NonNullable<renderItem['arguments']>;
type RenderItem = (
Expand Down
22 changes: 21 additions & 1 deletion frontend/packages/core/hooks/useECharts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {MutableRefObject, useCallback, useEffect, useLayoutEffect, useRef, useState} from 'react';
import {maskColor, primaryColor, textColor} from '~/utils/style';
import {maskColor, position, primaryColor, size, textColor} from '~/utils/style';

import {ECharts} from 'echarts';
import {dataURL2Blob} from '~/utils/image';
import {saveAs} from 'file-saver';
import styled from 'styled-components';

const useECharts = <T extends HTMLElement, W extends HTMLElement = HTMLDivElement>(options: {
loading?: boolean;
Expand Down Expand Up @@ -99,3 +100,22 @@ const useECharts = <T extends HTMLElement, W extends HTMLElement = HTMLDivElemen
};

export default useECharts;

export const Wrapper = styled.div`
position: relative;
display: flex;
justify-content: center;
align-items: stretch;
> .echarts {
width: 100%;
}
> .loading {
${size('100%')}
${position('absolute', 0, null, null, 0)}
display: flex;
justify-content: center;
align-items: center;
}
`;

0 comments on commit 62b4802

Please sign in to comment.