-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,533 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[flake8] | ||
extend-ignore = E124,E128,E301,E302,E305,E402,E501,E261,W504 | ||
# E124: closing bracket does not match visual indentation | ||
# E128: continuation line under-indented for visual indent | ||
# E301: expected 1 blank line, found 0 | ||
# E302: expected 2 blank lines, found 1 | ||
# E305: expected 2 blank lines after class or function definition, found 1 | ||
# E402: module level import not at top of file | ||
# E501: line too long (82 > 79 characters) | ||
# E261: at least two spaces before inline comment | ||
# W504: line break after binary operator |
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,21 @@ | ||
import sortingview.views as vv | ||
import kachery_cloud as kcl | ||
import plotly.graph_objects as go | ||
|
||
|
||
def main(): | ||
kcl.use_sandbox() | ||
view = example_plotly() | ||
|
||
url = view.url(label="Plotly example") | ||
print(url) | ||
|
||
|
||
def example_plotly(): | ||
fig = go.Figure(data=[go.Scatter(x=[1, 2, 3, 4], y=[10, 11, 12, 13], mode='markers')]) | ||
view = vv.PlotlyFigure(fig=fig) | ||
return view | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
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
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
41 changes: 41 additions & 0 deletions
41
gui/src/libraries/core-views/view-plotly-figure/PlotlyFigureView.tsx
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,41 @@ | ||
import React, { FunctionComponent, Suspense } from 'react'; | ||
import { isEqualTo, validateObject } from '../../core-utils'; | ||
|
||
const Plot = React.lazy(() => (import('react-plotly.js'))) | ||
|
||
export type PlotlyFigureViewData = { | ||
type: 'PlotlyFigure' | ||
fig: any | ||
} | ||
export const isPlotlyFigureViewData = (x: any): x is PlotlyFigureViewData => { | ||
return validateObject(x, { | ||
type: isEqualTo('PlotlyFigure'), | ||
fig: () => true | ||
}) | ||
} | ||
|
||
type Props = { | ||
data: PlotlyFigureViewData | ||
width: number | ||
height: number | ||
} | ||
|
||
const PlotlyFigureView: FunctionComponent<Props> = ({data, width, height}) => { | ||
const {fig} = data | ||
return ( | ||
<div style={{position: 'absolute', width, height}}> | ||
<Suspense fallback={<div>Loading plotly</div>}> | ||
<Plot | ||
data={fig.data} | ||
layout={{ | ||
...fig.layout, | ||
width: width, | ||
height: height | ||
}} | ||
/> | ||
</Suspense> | ||
</div> | ||
) | ||
} | ||
|
||
export default PlotlyFigureView |
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,3 @@ | ||
export { default as PlotlyFigureView } from './PlotlyFigureView' | ||
export { isPlotlyFigureViewData } from './PlotlyFigureView' | ||
export type { PlotlyFigureViewData } from './PlotlyFigureView' |
Oops, something went wrong.