| 43 | } |
| 44 | |
| 45 | function vegaTimeFormat(values: [number, number][], d3TimeFormat: string) { |
| 46 | const name = 'timeFormat'; |
| 47 | const as = 'output'; |
| 48 | const spec: Spec = { |
| 49 | $schema: 'https://vega.github.io/schema/vega/v3.json', |
| 50 | data: [{ |
| 51 | name, |
| 52 | values, |
| 53 | transform: [{ |
| 54 | type: 'formula', |
| 55 | expr: `timeFormat(datum[0], '${d3TimeFormat}') + ' - ' + timeFormat(datum[1], '${d3TimeFormat}')`, |
| 56 | as, |
| 57 | }], |
| 58 | }], |
| 59 | }; |
| 60 | const runtime = VegaDeckGl.base.vega.parse(spec); |
| 61 | const view = new VegaDeckGl.ViewGl(runtime).run(); |
| 62 | return view.data(name).map(row => row[as]); |
| 63 | } |