Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import * as React from "react" import { SampleColumnSlugs, SynthesizeGDPTable, } from "../../coreTable/OwidTableSynthesizers" import { Spreadsheet } from "./Spreadsheet" import { action, computed, observable } from "mobx" import { observer } from "mobx-react" import { Bounds } from "../../clientUtils/Bounds" import { ChartTypeName } from "../core/GrapherConstants" import { ChartComponentClassMap, DefaultChartClass, } from "../chart/ChartTypeMap" import { OwidTableSlugs } from "../../coreTable/OwidTableConstants" import { ChartTypeSwitcher } from "../chart/ChartTypeSwitcher" import { OwidTable } from "../../coreTable/OwidTable" export default { title: "Spreadsheet", component: Spreadsheet, } const getRandomTable = (): OwidTable => SynthesizeGDPTable({ entityCount: 2, timeRange: [2020, 2024], }) .dropColumns([ SampleColumnSlugs.GDP, SampleColumnSlugs.Population, OwidTableSlugs.entityCode, OwidTableSlugs.entityId, ]) .sortColumns([OwidTableSlugs.entityName, OwidTableSlugs.year]) @observer class Editor extends React.Component { @observable.ref table = getRandomTable() @action.bound private shuffleTable(): void { this.table = getRandomTable() } @computed get yColumnSlugs(): string[] { return this.table.suggestedYColumnSlugs } @computed get xColumnSlug(): string { return this.table.timeColumn?.slug } @observable chartTypeName = ChartTypeName.LineChart @computed get selection(): any[] { return this.table.availableEntityNames } @action.bound private changeChartType(type: ChartTypeName): void { this.chartTypeName = type } render(): JSX.Element { const ChartClass = ChartComponentClassMap.get(this.chartTypeName) ?? DefaultChartClass return ( <div> <Spreadsheet manager={this} /> <svg width={400} height={300}> <ChartClass manager={this} bounds={new Bounds(0, 0, 400, 300)} /> </svg> <button onClick={this.shuffleTable}>Shuffle</button> <ChartTypeSwitcher onChange={this.changeChartType} /> </div> ) } } export const Default = (): JSX.Element => <Editor /> |