-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(charts): height should be self-adaption for Line, Area and DualAxes
- Loading branch information
1 parent
f1b50fb
commit ea73549
Showing
11 changed files
with
5,068 additions
and
13,541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Area ref ref 1`] = ` | ||
<div | ||
data-chart-source-type="G2Plot" | ||
size-sensor-id="1" | ||
style="height: inherit;" | ||
> | ||
<div | ||
style="position:relative;" | ||
> | ||
<canvas | ||
height="400" | ||
style="width: 400px; height: 400px; display: inline-block; vertical-align: middle;" | ||
width="400" | ||
/> | ||
</div> | ||
<object | ||
class="size-sensor-object" | ||
data="about:blank" | ||
style="display: block; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0;" | ||
tabindex="-1" | ||
type="text/html" | ||
/> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Area } from '@oceanbase/charts'; | ||
|
||
describe('Area ref', () => { | ||
it('ref', () => { | ||
const DemoArea = () => { | ||
const ref = useRef(null); | ||
useEffect(() => { | ||
expect(ref.current).not.toBeNull(); | ||
expect(typeof ref.current?.getChart).toBe('function'); | ||
}, []); | ||
const config = { | ||
data: [], | ||
xField: 'x', | ||
yField: 'y', | ||
}; | ||
return <Area {...config} ref={ref} />; | ||
}; | ||
const { asFragment } = render(<DemoArea />); | ||
expect(asFragment().firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/charts/src/DualAxes/__tests__/__snapshots__/ref.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DualAxes ref ref 1`] = ` | ||
<div | ||
data-chart-source-type="G2Plot" | ||
size-sensor-id="1" | ||
style="height: inherit;" | ||
> | ||
<div | ||
style="position:relative;" | ||
> | ||
<canvas | ||
height="400" | ||
style="width: 400px; height: 400px; display: inline-block; vertical-align: middle;" | ||
width="400" | ||
/> | ||
</div> | ||
<object | ||
class="size-sensor-object" | ||
data="about:blank" | ||
style="display: block; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0;" | ||
tabindex="-1" | ||
type="text/html" | ||
/> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { DualAxes } from '@oceanbase/charts'; | ||
|
||
describe('DualAxes ref', () => { | ||
it('ref', () => { | ||
const DemoDualAxes = () => { | ||
const ref = useRef(null); | ||
useEffect(() => { | ||
expect(ref.current).not.toBeNull(); | ||
expect(typeof ref.current?.getChart).toBe('function'); | ||
}, []); | ||
const config = { | ||
data: [[], []], | ||
xField: 'x', | ||
yField: ['y1', 'y2'], | ||
}; | ||
return <DualAxes {...config} ref={ref} />; | ||
}; | ||
const { asFragment } = render(<DemoDualAxes />); | ||
expect(asFragment().firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/charts/src/Line/__tests__/__snapshots__/ref.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Line ref ref 1`] = ` | ||
<div | ||
data-chart-source-type="G2Plot" | ||
size-sensor-id="1" | ||
style="height: inherit;" | ||
> | ||
<div | ||
style="position:relative;" | ||
> | ||
<canvas | ||
height="400" | ||
style="width: 400px; height: 400px; display: inline-block; vertical-align: middle;" | ||
width="400" | ||
/> | ||
</div> | ||
<object | ||
class="size-sensor-object" | ||
data="about:blank" | ||
style="display: block; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0;" | ||
tabindex="-1" | ||
type="text/html" | ||
/> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Line } from '@oceanbase/charts'; | ||
|
||
describe('Line ref', () => { | ||
it('ref', () => { | ||
const DemoLine = () => { | ||
const ref = useRef(null); | ||
useEffect(() => { | ||
expect(ref.current).not.toBeNull(); | ||
expect(typeof ref.current?.getChart).toBe('function'); | ||
}, []); | ||
const config = { | ||
data: [], | ||
xField: 'x', | ||
yField: 'y', | ||
}; | ||
return <Line {...config} ref={ref} />; | ||
}; | ||
const { asFragment } = render(<DemoLine />); | ||
expect(asFragment().firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.