legend.ts 805 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { Color } from './color';
  7. import { ColorListEntry } from './color/color';
  8. export type Legend = TableLegend | ScaleLegend
  9. export interface TableLegend {
  10. kind: 'table-legend'
  11. table: [ string, Color ][]
  12. }
  13. export function TableLegend(table: [ string, Color ][]): TableLegend {
  14. return { kind: 'table-legend', table };
  15. }
  16. export interface ScaleLegend {
  17. kind: 'scale-legend'
  18. minLabel: string,
  19. maxLabel: string,
  20. colors: ColorListEntry[]
  21. }
  22. export function ScaleLegend(minLabel: string, maxLabel: string, colors: ColorListEntry[]): ScaleLegend {
  23. return { kind: 'scale-legend', minLabel, maxLabel, colors };
  24. }