From 39212e638b6b6b62cd7fbc30ec5ad74725122793 Mon Sep 17 00:00:00 2001 From: Abhas Bhattacharya Date: Mon, 9 Jul 2018 19:09:15 +0530 Subject: [PATCH] Add "WithPopupOnValueClick" example --- stories/GridAreaWithPopupOnValueClick.js | 82 ++++++++++++++++++++++++ stories/index.stories.js | 3 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 stories/GridAreaWithPopupOnValueClick.js diff --git a/stories/GridAreaWithPopupOnValueClick.js b/stories/GridAreaWithPopupOnValueClick.js new file mode 100644 index 0000000..aec6236 --- /dev/null +++ b/stories/GridAreaWithPopupOnValueClick.js @@ -0,0 +1,82 @@ +import React from 'react'; + +import { + XYPlot, + XAxis, + YAxis, + HorizontalGridLines, + VerticalGridLines, + LineSeries +} from 'react-vis/dist'; +import GridArea from '../src/grid-area'; +import '../node_modules/react-vis/dist/style.css'; + +const MSEC_DAILY = 86400000; + +export default class GridAreaWithPopupOnValueClick extends React.Component { + constructor() { + super(); + this.state = {}; + this.state.tooltipNode = undefined; + } + render() { + const timestamp = new Date('September 9 2017').getTime(); + const tooltipNodeRect = this.state.tooltipNode ? this.state.tooltipNode.getBoundingClientRect() : undefined; + + return ( +
+ + + + { + console.log(ev); + this.setState({ tooltipNode: ev.currentTarget }); + }} + /> + + + + + + + + { + (this.state.tooltipNode !== undefined) ? + ( +
+ Here's a tooltip +
+ ) : + ( + undefined + ) + } + +
+ ); + } +} \ No newline at end of file diff --git a/stories/index.stories.js b/stories/index.stories.js index a4c9e53..be58c1c 100644 --- a/stories/index.stories.js +++ b/stories/index.stories.js @@ -11,6 +11,7 @@ import GridAreaWithDefaultStyle from './GridAreaWithDefaultStyle'; import GridAreaWithSeriesEventListeners from './GridAreaWithSeriesEventListeners'; import GridAreaWithValueEventListeners from './GridAreaWithValueEventListeners'; import GridAreaWithPopupOnValueHover from './GridAreaWithPopupOnValueHover'; +import GridAreaWithPopupOnValueClick from './GridAreaWithPopupOnValueClick'; storiesOf('Welcome', module).add('to Storybook', () => ); @@ -21,4 +22,4 @@ storiesOf('Grid area', module) .add('With series event handler', () => ) .add('With value event handler', () => ) .add('With value event hover tooltip', () => ) - + .add('With value event click tooltip', () => )