legend.ts 737 B

123456789101112131415161718192021222324252627
  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. export type Legend = TableLegend | ScaleLegend
  8. export interface TableLegend {
  9. kind: 'table-legend'
  10. table: [ string, Color ][]
  11. }
  12. export function TableLegend(table: [ string, Color ][]): TableLegend {
  13. return { kind: 'table-legend', table }
  14. }
  15. export interface ScaleLegend {
  16. kind: 'scale-legend'
  17. minLabel: string,
  18. maxLabel: string,
  19. colors: Color[]
  20. }
  21. export function ScaleLegend(minLabel: string, maxLabel: string, colors: Color[]): ScaleLegend {
  22. return { kind: 'scale-legend', minLabel, maxLabel, colors }
  23. }