Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[website] Fix ghcn website example #8242

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions examples/website/ghcn/app.jsx → examples/website/ghcn/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {TextLayer, PathLayer} from '@deck.gl/layers';
import {SimpleMeshLayer} from '@deck.gl/mesh-layers';
import DeckGL from '@deck.gl/react';
import {Matrix4} from '@math.gl/core';
import type {MeshAttributes} from '@loaders.gl/schema';

import {scaleLinear} from 'd3-scale';
import {sortData} from './sort-data';
Expand All @@ -20,8 +21,11 @@ const CHART_HEIGHT = 500;
const SPACING = 60;
const ROW_SIZE = 25;

const borderMesh = {
positions: new Float32Array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0])
const borderMesh: MeshAttributes = {
positions: {
value: new Float32Array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0]),
size: 3
}
};
const xScale = scaleLinear()
.domain([1880, 2020]) // year
Expand All @@ -31,15 +35,15 @@ const yScale = scaleLinear()
.domain([-60, 35]) // temperature
.range([CHART_HEIGHT, 0]);
const yTicks = [-60, -30, 0, 30];
export const colorScale = scaleLinear()
export const colorScale = scaleLinear<[number, number, number]>()
.domain([-60, -10, 30]) // temperature
.range([
[80, 160, 225],
[0, 80, 80],
[255, 80, 80]
]);

function getOffset(chartIndex) {
function getOffset(chartIndex: number) {
const y = Math.floor(chartIndex / ROW_SIZE);
const x = chartIndex % ROW_SIZE;
return [x * (CHART_WIDTH + SPACING), y * (CHART_HEIGHT + SPACING), 0];
Expand All @@ -59,7 +63,7 @@ function getTooltip({object}) {
);
}

export default function App({data, groupBy = 'Country'}) {
export default function App({data = null, groupBy = 'Country'}) {
const dataSlices = useMemo(() => sortData(data, groupBy), [data, groupBy]);

const initialViewState = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion examples/website/ghcn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div id="app"></div>
</body>
<script type="module">
import {renderToDOM} from './app.jsx';
import {renderToDOM} from './app.tsx';
renderToDOM(document.getElementById('app'));
</script>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ export default class SimpleMeshLayer<DataT = any, ExtraPropsT extends {} = {}> e
this.setTexture(props.texture);
}

// if (this.state.model) {
// this.state.model.setDrawMode(this.props.wireframe ? GL.LINE_STRIP : GL.TRIANGLES);
// }
if (this.state.model) {
this.state.model.setTopology(this.props.wireframe ? 'line-strip' : 'triangle-list');
}
}

finalizeState(context: LayerContext) {
Expand Down
Loading