-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
33 changed files
with
868 additions
and
164 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.auto-domain-input--custom { | ||
padding-top: 4px; | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...hared/components/ColorSchemeDropdown.scss → ...d/components/ColorSchemeDropdownItem.scss
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Libraries | ||
import React, {CSSProperties, FunctionComponent} from 'react' | ||
|
||
const generateGradientStyle = (colors: string[]): CSSProperties => { | ||
const stops = colors | ||
.map((hex, i) => `${hex} ${Math.round((i / (colors.length - 1)) * 100)}%`) | ||
.join(', ') | ||
|
||
return { | ||
background: `linear-gradient(to right, ${stops})`, | ||
} | ||
} | ||
|
||
interface Props { | ||
name: string | ||
colors: string[] | ||
} | ||
|
||
const ColorSchemeDropdownItem: FunctionComponent<Props> = ({name, colors}) => { | ||
return ( | ||
<div className="color-scheme-dropdown-item"> | ||
<div | ||
className="color-scheme-dropdown-item--swatches" | ||
style={generateGradientStyle(colors)} | ||
/> | ||
<div className="color-scheme-dropdown-item--name">{name}</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ColorSchemeDropdownItem |
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 |
---|---|---|
@@ -1,19 +1,34 @@ | ||
import {PureComponent} from 'react' | ||
import {FunctionComponent} from 'react' | ||
|
||
interface Props { | ||
name?: string | ||
export const isFlagEnabled = (flagName: string) => { | ||
return JSON.parse(window.localStorage.featureFlags || {})[flagName] === true | ||
} | ||
|
||
export default class extends PureComponent<Props> { | ||
public render() { | ||
if (this.isHidden) { | ||
return null | ||
} | ||
export const toggleFlag = (flagName: string) => { | ||
const featureFlags = JSON.parse(window.localStorage.featureFlags || {}) | ||
|
||
return this.props.children | ||
} | ||
featureFlags[flagName] = !featureFlags[flagName] | ||
|
||
window.localStorage.featureFlags = JSON.stringify(featureFlags) | ||
} | ||
|
||
interface Props { | ||
name: string | ||
} | ||
|
||
private get isHidden(): boolean { | ||
return process.env.NODE_ENV !== 'development' | ||
const FeatureFlag: FunctionComponent<Props> = ({name, children}) => { | ||
if (!isFlagEnabled(name)) { | ||
return null | ||
} | ||
|
||
return children as any | ||
} | ||
|
||
export default FeatureFlag | ||
|
||
// Expose toggleFlag on the window for convenience | ||
const w = window as any | ||
|
||
w.influx = { | ||
toggleFeatureFlag: toggleFlag, | ||
} |
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,107 @@ | ||
// Libraries | ||
import React, {FunctionComponent} from 'react' | ||
import {Config, Table} from '@influxdata/vis' | ||
import {get} from 'lodash' | ||
|
||
// Components | ||
import EmptyGraphMessage from 'src/shared/components/EmptyGraphMessage' | ||
import GraphLoadingDots from 'src/shared/components/GraphLoadingDots' | ||
|
||
// Utils | ||
import {useVisDomainSettings} from 'src/shared/utils/useVisDomainSettings' | ||
import {getFormatter} from 'src/shared/utils/vis' | ||
|
||
// Constants | ||
import {VIS_THEME} from 'src/shared/constants' | ||
import {DEFAULT_LINE_COLORS} from 'src/shared/constants/graphColorPalettes' | ||
import {INVALID_DATA_COPY} from 'src/shared/copy/cell' | ||
|
||
// Types | ||
import {RemoteDataState, HeatmapView} from 'src/types' | ||
|
||
interface Props { | ||
table: Table | ||
loading: RemoteDataState | ||
viewProperties: HeatmapView | ||
children: (config: Config) => JSX.Element | ||
} | ||
|
||
const HeatmapContainer: FunctionComponent<Props> = ({ | ||
table, | ||
loading, | ||
viewProperties: { | ||
xColumn, | ||
yColumn, | ||
xDomain: storedXDomain, | ||
yDomain: storedYDomain, | ||
xAxisLabel, | ||
yAxisLabel, | ||
xPrefix, | ||
xSuffix, | ||
yPrefix, | ||
ySuffix, | ||
colors: storedColors, | ||
binSize, | ||
}, | ||
children, | ||
}) => { | ||
const [xDomain, onSetXDomain, onResetXDomain] = useVisDomainSettings( | ||
storedXDomain, | ||
get(table, ['columns', xColumn, 'data'], []) | ||
) | ||
|
||
const [yDomain, onSetYDomain, onResetYDomain] = useVisDomainSettings( | ||
storedYDomain, | ||
get(table, ['columns', yColumn, 'data'], []) | ||
) | ||
|
||
const isValidView = | ||
xColumn && yColumn && table.columns[xColumn] && table.columns[yColumn] | ||
|
||
if (!isValidView) { | ||
return <EmptyGraphMessage message={INVALID_DATA_COPY} /> | ||
} | ||
|
||
const colors = | ||
storedColors && storedColors.length | ||
? storedColors | ||
: DEFAULT_LINE_COLORS.map(c => c.hex) | ||
|
||
const xFormatter = getFormatter(table.columns[xColumn].type, xPrefix, xSuffix) | ||
const yFormatter = getFormatter(table.columns[yColumn].type, yPrefix, ySuffix) | ||
|
||
const config: Config = { | ||
...VIS_THEME, | ||
table, | ||
xAxisLabel, | ||
yAxisLabel, | ||
xDomain, | ||
onSetXDomain, | ||
onResetXDomain, | ||
yDomain, | ||
onSetYDomain, | ||
onResetYDomain, | ||
valueFormatters: { | ||
[xColumn]: xFormatter, | ||
[yColumn]: yFormatter, | ||
}, | ||
layers: [ | ||
{ | ||
type: 'heatmap', | ||
x: xColumn, | ||
y: yColumn, | ||
colors, | ||
binSize, | ||
}, | ||
], | ||
} | ||
|
||
return ( | ||
<div className="vis-plot-container"> | ||
{loading === RemoteDataState.Loading && <GraphLoadingDots />} | ||
{children(config)} | ||
</div> | ||
) | ||
} | ||
|
||
export default HeatmapContainer |
Oops, something went wrong.