forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'streaming-test-data-alt' of github.com:ryantxu/grafana …
…into streaming-test-data-alt * 'streaming-test-data-alt' of github.com:ryantxu/grafana: PanelChrome: delay state update while other panel is in fullscreen/edit TestData: don't reuse unsubbed stream workers PanelQueryState: give code a bit of air (space) PanelQuery: Minor refactoring sqlstore: use column name in order by (grafana#16583) user friendly guide (grafana#16743) Provisioning: Interpolate env vars in provisioning files (grafana#16499) admin: add more stats about roles (grafana#16667) Feature: Migrate Legend components to grafana/ui (grafana#16468) playlist: fix loading dashboards by tag (grafana#16727) CloudWatch: Use default alias if there is no alias for metrics (grafana#16732) Provisioning: Support FolderUid in Dashboard Provisioning Config (grafana#16559)
- Loading branch information
Showing
73 changed files
with
6,027 additions
and
450 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
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
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
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
105 changes: 105 additions & 0 deletions
105
packages/grafana-ui/src/components/Graph/GraphLegend.story.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,105 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
|
||
import { GraphLegend } from './GraphLegend'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { select, number } from '@storybook/addon-knobs'; | ||
import { withHorizontallyCenteredStory } from '../../utils/storybook/withCenteredStory'; | ||
import { generateLegendItems } from '../Legend/Legend.story'; | ||
import { LegendPlacement, LegendDisplayMode } from '../Legend/Legend'; | ||
|
||
const GraphLegendStories = storiesOf('Visualizations/Graph/GraphLegend', module); | ||
GraphLegendStories.addDecorator(withHorizontallyCenteredStory); | ||
|
||
const getStoriesKnobs = (isList = false) => { | ||
const statsToDisplay = select( | ||
'Stats to display', | ||
{ | ||
none: [], | ||
'single (min)': [{ text: '10ms', title: 'min', numeric: 10 }], | ||
'multiple (min, max)': [ | ||
{ text: '10ms', title: 'min', numeric: 10 }, | ||
{ text: '100ms', title: 'max', numeric: 100 }, | ||
], | ||
}, | ||
[] | ||
); | ||
|
||
const numberOfSeries = number('Number of series', 3); | ||
|
||
const containerWidth = select( | ||
'Container width', | ||
{ | ||
Small: '200px', | ||
Medium: '500px', | ||
'Full width': '100%', | ||
}, | ||
'100%' | ||
); | ||
|
||
const legendPlacement = select<LegendPlacement>( | ||
'Legend placement', | ||
{ | ||
under: 'under', | ||
right: 'right', | ||
}, | ||
'under' | ||
); | ||
|
||
return { | ||
statsToDisplay, | ||
numberOfSeries, | ||
containerWidth, | ||
legendPlacement, | ||
}; | ||
}; | ||
|
||
GraphLegendStories.add('list', () => { | ||
const { statsToDisplay, numberOfSeries, containerWidth, legendPlacement } = getStoriesKnobs(true); | ||
return ( | ||
<div style={{ width: containerWidth }}> | ||
<GraphLegend | ||
displayMode={LegendDisplayMode.List} | ||
items={generateLegendItems(numberOfSeries, statsToDisplay)} | ||
onLabelClick={(item, event) => { | ||
action('Series label clicked')(item, event); | ||
}} | ||
onSeriesColorChange={(label, color) => { | ||
action('Series color changed')(label, color); | ||
}} | ||
onSeriesAxisToggle={(label, useRightYAxis) => { | ||
action('Series axis toggle')(label, useRightYAxis); | ||
}} | ||
onToggleSort={sortBy => { | ||
action('Toggle legend sort')(sortBy); | ||
}} | ||
placement={legendPlacement} | ||
/> | ||
</div> | ||
); | ||
}); | ||
|
||
GraphLegendStories.add('table', () => { | ||
const { statsToDisplay, numberOfSeries, containerWidth, legendPlacement } = getStoriesKnobs(); | ||
return ( | ||
<div style={{ width: containerWidth }}> | ||
<GraphLegend | ||
displayMode={LegendDisplayMode.Table} | ||
items={generateLegendItems(numberOfSeries, statsToDisplay)} | ||
onLabelClick={item => { | ||
action('Series label clicked')(item); | ||
}} | ||
onSeriesColorChange={(label, color) => { | ||
action('Series color changed')(label, color); | ||
}} | ||
onSeriesAxisToggle={(label, useRightYAxis) => { | ||
action('Series axis toggle')(label, useRightYAxis); | ||
}} | ||
onToggleSort={sortBy => { | ||
action('Toggle legend sort')(sortBy); | ||
}} | ||
placement={legendPlacement} | ||
/> | ||
</div> | ||
); | ||
}); |
Oops, something went wrong.