Skip to content

Commit

Permalink
NFINT-813: in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson committed Sep 12, 2023
1 parent 57c181e commit 2d8992d
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Meta, StoryObj } from '@storybook/react'
import TimelinePhase from './TimelinePhase'

const meta = {
title: 'Components/TimelinePhase',
component: TimelinePhase,
} satisfies Meta
export default meta
type Story = StoryObj<typeof meta>

export const Demo: Story = {
args: {},
}
83 changes: 83 additions & 0 deletions packages/synapse-react-client/src/components/TimelinePhase.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react'
import Plotly, { Layout } from 'plotly.js-basic-dist'
import createPlotlyComponent from 'react-plotly.js/factory'
const Plot = createPlotlyComponent(Plotly)

const timelineData = [
{
x: [10, 10],
y: [0, 1],
mode: 'lines',
line: {
color: 'gray',
width: 2,
},
textposition: 'top',
name: 'Event 1',
},
{
x: [20, 20],
y: [0, 1],
mode: 'lines',
line: {
color: 'gray',
width: 2,
},
textposition: 'top',
name: 'Event 1',
},
]

const layout: Partial<Layout> = {
showlegend: false,
xaxis: {
showgrid: false,
showticklabels: false,
showline: false,
zeroline: false,
},
yaxis: {
showgrid: false,
zeroline: false,
showline: false,
showticklabels: false,
},

// event annotations
annotations: [
{
x: 10,
y: -0.2,
text: '10', // Text to display
showarrow: false,
},
],

// Each phase has a shape
shapes: [
{
type: 'rect',
x0: 0,
x1: 100,
y0: 0.25,
y1: 0.75,
fillcolor: 'rgba(50, 171, 96, 0.5)',
line: {
width: 0,
},
},
],
}

const TimelinePhase = () => {
return (
<Plot
layout={layout}
data={timelineData}
style={{ width: '100%', height: '300px' }}
useResizeHandler={true}
/>
)
}

export default TimelinePhase

0 comments on commit 2d8992d

Please sign in to comment.