-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
eb2cf2f
commit e33cf89
Showing
26 changed files
with
748 additions
and
46 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
23 changes: 23 additions & 0 deletions
23
js/notebook/src/tableDisplay/dataGrid/cell/DataGridCell.ts
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,23 @@ | ||
/* | ||
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { CellRenderer } from "@phosphor/datagrid"; | ||
|
||
export default class DataGridCell { | ||
static isHeaderCell(config: CellRenderer.ICellConfig) { | ||
return config.region === 'column-header' || config.region === 'corner-header'; | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
js/notebook/src/tableDisplay/dataGrid/highlighter/HeatmapHighlighter.ts
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,52 @@ | ||
/* | ||
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as d3scale from 'd3-scale'; | ||
import { formatColor, getDefaultColor } from "../style/dataGridStyle"; | ||
import Highlighter from "./Highlighter"; | ||
import IHihglighterState, { HIGHLIGHTER_STYLE } from "../interface/IHighlighterState"; | ||
import DataGridColumn from "../column/DataGridColumn"; | ||
import {CellRenderer} from "@phosphor/datagrid"; | ||
import { find } from "@phosphor/algorithm"; | ||
|
||
export default class HeatmapHighlighter extends Highlighter { | ||
colorScale: Function; | ||
|
||
constructor(column: DataGridColumn, state: IHihglighterState) { | ||
super(column, state); | ||
|
||
this.state.minVal = this.state.minVal || this.column.minValue; | ||
this.state.maxVal = this.state.maxVal || this.column.maxValue; | ||
this.state.minColor = formatColor(state.minColor || getDefaultColor('blue')); | ||
this.state.maxColor = formatColor(state.maxColor || getDefaultColor('red')); | ||
|
||
this.colorScale = d3scale.scaleLinear() | ||
.domain([this.state.minVal, this.state.maxVal]) | ||
.range([this.state.minColor, this.state.maxColor]); | ||
} | ||
|
||
getBackgroundColor(config: CellRenderer.ICellConfig) { | ||
let value = config.value; | ||
|
||
if (this.state.style === HIGHLIGHTER_STYLE.FULL_ROW) { | ||
value = find(this.column.valuesIterator.clone(), (value, index) => { | ||
return index === config.row; | ||
}); | ||
} | ||
|
||
return this.colorScale(value); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
js/notebook/src/tableDisplay/dataGrid/highlighter/Highlighter.ts
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,35 @@ | ||
/* | ||
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import IHihglighterState, { HIGHLIGHTER_STYLE } from "../interface/IHighlighterState"; | ||
import { DEFAULT_CELL_BACKGROUND } from "../cell/CellRendererFactory"; | ||
import { CellRenderer } from "@phosphor/datagrid"; | ||
import DataGridColumn from "../column/DataGridColumn"; | ||
|
||
export default class Highlighter { | ||
column: DataGridColumn; | ||
state: IHihglighterState; | ||
|
||
constructor(column: DataGridColumn, state: IHihglighterState) { | ||
this.column = column; | ||
this.state = state; | ||
this.state.style = state.style || HIGHLIGHTER_STYLE.SINGLE_COLUMN; | ||
} | ||
|
||
getBackgroundColor(config: CellRenderer.ICellConfig) { | ||
return DEFAULT_CELL_BACKGROUND; | ||
} | ||
} |
Oops, something went wrong.