Skip to content

Commit

Permalink
replace deprecated APIs of ScatterplotLayer in documentation (visgl#2706
Browse files Browse the repository at this point in the history
)
  • Loading branch information
XiaokaiUber authored Feb 21, 2019
1 parent b82c47d commit 413e394
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ npm install deck.gl

deck.gl offers an extensive catalog of pre-packaged visualization "layers", including [ScatterplotLayer](http://deck.gl/#/documentation/deckgl-api-reference/layers/scatterplot-layer), [ArcLayer](http://deck.gl/#/documentation/deckgl-api-reference/layers/arc-layer), [TextLayer](http://deck.gl/#/documentation/deckgl-api-reference/layers/text-layer), [GeoJsonLayer](http://deck.gl/#/documentation/deckgl-api-reference/layers/geojson-layer), etc. The input to a layer is usually an array of JSON objects. Each layer offers highly-flexible API to customize how the data should be rendered.

Example constructing a deck.gl ScatterplotLayer:
Example constructing a deck.gl ScatterplotLayer:

```js
import {ScatterplotLayer} from '@deck.gl/layers';
Expand All @@ -50,7 +50,7 @@ const scatterplotLayer = new ScatterplotLayer({
data: 'https://github.com/uber-common/deck.gl-data/blob/master/website/bart-stations.json',
getRadius: d => Math.sqrt(d.entries) / 100,
getPosition: d => d.coordinates,
getColor: [255, 228, 0],
getFillColor: [255, 228, 0],
});
```

Expand Down
4 changes: 2 additions & 2 deletions dev-docs/RFCs/v7.x/binary-data-rfc.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ new ScatterplotLayer({
data,
getPosition: d => d.position,
getRadius: d => d.radius,
getColor: d => d.color
getFillColor: d => d.color
});
```

Expand All @@ -68,7 +68,7 @@ new ScatterplotLayer({
getRadius: (object, {index, data}) => {
return data.src[index * 6 + 2];
},
getColor: (object, {index, data, target}) => {
getFillColor: (object, {index, data, target}) => {
target[0] = data.src[index * 6 + 3];
target[1] = data.src[index * 6 + 4];
target[2] = data.src[index * 6 + 5];
Expand Down
14 changes: 7 additions & 7 deletions docs/api-reference/layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,27 +244,27 @@ Sometimes `data` remains the same, but the outcome of an accessor has changed. I
```js
const layer = new ScatterplotLayer({
... // Other props
getColor: d => d.male ? maleColor : femaleColor
getFillColor: d => d.male ? maleColor : femaleColor
});
```

In this case, you need to explicitly inform deck.gl to re-evaluate `getColor` for all data items. You do so by defining `updateTriggers`:
In this case, you need to explicitly inform deck.gl to re-evaluate `getFillColor` for all data items. You do so by defining `updateTriggers`:

```js
const layer = new ScatterplotLayer({
... // Other props
getColor: d => d.male ? maleColor : femaleColor,
getFillColor: d => d.male ? maleColor : femaleColor,
updateTriggers: {
getColor: [maleColor, femaleColor]
getFillColor: [maleColor, femaleColor]
}
});
```

`updateTriggers` expect an object whose keys are names of accessor props of this layer, and values are one or more variables that affect the output of the accessors.

For example, `updateTriggers.getColor` is a list of variables that affect the output of
`getColor`. If either value in the array changes, all attributes that depend on
`getColor` will be updated.
For example, `updateTriggers.getFillColor` is a list of variables that affect the output of
`getFillColor`. If either value in the array changes, all attributes that depend on
`getFillColor` will be updated.
The variables may be numbers, strings, objects or functions. During each rendering cycle, deck.gl shallow-compares them with the previous values.


Expand Down
4 changes: 2 additions & 2 deletions docs/api-reference/mapbox/mapbox-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const deck = new Deck({
],
getPosition: d => d.position,
getRadius: d => d.size,
getColor: [255, 0, 0]
getFillColor: [255, 0, 0]
})
]
});
Expand All @@ -77,7 +77,7 @@ deck.setProps({
],
getPosition: d => d.position,
getRadius: d => d.size,
getColor: [0, 0, 255]
getFillColor: [0, 0, 255]
})
]
});
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/mapbox/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class App extends React.Component {
],
getPosition: d => d.position,
getRadius: d => d.size,
getColor: [255, 0, 0]
getFillColor: [255, 0, 0]
})
];

Expand Down
13 changes: 7 additions & 6 deletions docs/developer-guide/composite-layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,23 @@ class NiceScatterplotLayer extends CompositeLayer {
new ScatterplotLayer({
...this.props,
id: 'fill',
getColor: this.props.getFillColor,
outline: false,
getFillColor: this.props.getFillColor,
filled: true,
updateTriggers: {
...updateTrigger,
getColor: updateTrigger.getFillColor
getFillColor: updateTrigger.getFillColor
}
}),
// the outlines
new ScatterplotLayer({
...this.props,
id: 'outline',
getColor: this.props.getStrokeColor,
outline: true,
getLineColor: this.props.getStrokeColor,
stroked: true,
filled: false,
updateTriggers: {
...updateTrigger,
getColor: updateTrigger.getStrokeColor
getLineColor: updateTrigger.getStrokeColor
}
})
];
Expand Down
4 changes: 2 additions & 2 deletions docs/get-started/interactivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const deck = new Deck({
],
getPosition: d => d.position,
getRadius: 1000,
getColor: [255, 255, 0],
getFillColor: [255, 255, 0],
// Enable picking
pickable: true,
// Update tooltip
Expand Down Expand Up @@ -101,7 +101,7 @@ class App extends React.Component {
],
getPosition: d => d.position,
getRadius: 1000,
getColor: [255, 255, 0],
getFillColor: [255, 255, 0],
// Enable picking
pickable: true,
// Update app state
Expand Down
2 changes: 1 addition & 1 deletion examples/experimental/json-common/examples/dot-text.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"data": [
{"position": [-122.45, 37.8]}
],
"getColor": [255, 0, 0, 255],
"getFillColor": [255, 0, 0, 255],
"getRadius": 1000
}, {
"type": "TextLayer",
Expand Down
2 changes: 1 addition & 1 deletion examples/experimental/json-common/examples/line.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"data": "https://raw.githubusercontent.com/uber-common/deck.gl-data/master/examples/line/airports.json",
"radiusScale": 20,
"getPosition": "coordinates",
"getColor": [255, 140, 0],
"getFillColor": [255, 140, 0],
"getRadius": 60
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"radiusScale": 30,
"radiusMinPixels": 0.25,
"getPosition": "-",
"getColor": [0, 128, 255],
"getFillColor": [0, 128, 255],
"getRadius": 1
}
]
Expand Down
4 changes: 2 additions & 2 deletions showcases/graph/graph-layer/graph-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ export default class GraphLayer extends CompositeLayer {
data: nodes,
getPosition: getNodePosition,
getRadius: getNodeSize,
getColor: n => (n.highlighting ? [255, 255, 0, 255] : getNodeColor(n)),
getFillColor: n => (n.highlighting ? [255, 255, 0, 255] : getNodeColor(n)),
opacity,
pickable,
coordinateSystem,
updateTriggers: {
getPosition: layoutTime,
getColor: layoutTime
getFillColor: layoutTime
},
visible
});
Expand Down
2 changes: 1 addition & 1 deletion showcases/wind/src/wind-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class WindDemo extends Component {
id: 'stations',
data: stations,
getPosition: d => [-d.long, d.lat, d.elv],
getColor: d => [200, 200, 100],
getFillColor: d => [200, 200, 100],
getRadius: d => 150,
opacity: 0.2,
radiusScale: 30
Expand Down

0 comments on commit 413e394

Please sign in to comment.