folkehelseinstituttet / Fhi.Frontend.Demo

MIT License
2 stars 1 forks source link

Update the FHI AngularHighcharts API #540

Closed proand closed 1 month ago

proand commented 2 months ago

Description

API consumer gets confused when using the current FHI Angular Highcharts API because the naming is hard to understand and the behavior is inconsistent.

Acceptance Criteria

  1. Go to https://dev-designsystem.fhi.no/developer/components/highcharts
  2. Check that all diagrams works as before. There should be no changes at all!
  3. Go to FHI Angular Highcharts API
  4. Check that the docomuentation make sense and that
    • the interface is the same as the one below
    • all sub interfaces also are documented
    • all deprecated properties are still there, but marked for deprecation in later version

Supplementary information

NEW API interface (with more grouping):

export interface FhiDiagramOptions {
  activeDiagramType: FhiDiagramTypeIds;
  controls?: FhiDiagramControls;;
  footer?: FhiDiagramFooter;
  openSource?: boolean;
  series: Array<FhiDiagramSerie>;
  tableOrientation?: FhiTableOrientations;
  title: string;
  unit?: Array<FhiDiagramUnit>;

  // The followin will be deprecated in v5
  creditsHref?: string;
  creditsText?: string;
  decimals?: number;
  diagramTypeId?: FhiDiagramTypeIds;
  diagramTypeNavId?: keyof typeof DiagramTypeNavIds;
  diagramTypeSubset?: Array<FhiDiagramTypeIds>;
  disclaimer?: string;
  flags?: Array<FhiDiagramFlag>;
  lastUpdated?: string;
  mapTypeId?: keyof typeof MapTypeIds;
  metadataButton?: boolean;
  showFullScreenButton?: boolean;
}

All properties:

export interface FhiDiagramOptions {
  activeDiagramType: FhiDiagramTypeIds;
  controls?: {
    fullScreenButton?: {
      show?: boolean;
    };
    metadataButton?: {
      show?: boolean;
    };
    navigation?: {
      items?: {
        chartTypes?: Array<keyof typeof ChartTypeIds>;
        mapTypes?: Array<keyof typeof MapTypeIds>;
      };
      show?: boolean;
      type?: keyof typeof DiagramTypeNavIds;
    };
    tableOrientationButton?: {
      show?: boolean;
    };
  };
  footer?: {
    credits?: {
      href: string;
      text: string;
    };
    disclaimer?: string;
    flags?: Array<FhiDiagramFlag>;
    lastUpdated?: string;
  };
  openSource?: boolean;
  series: [
    {
      data: {
        name: string;
        y: number | string;
      };
      name: string | Array<string>;
      stack?: string;
      unitId?: number | string;
    },
  ];
  tableOrientation?: FhiTableOrientations;
  title: string;
  unit?: [
    {
      id: number | string;
      decimals: number;
      label: string;
      symbol: string;
      position: keyof typeof UnitSymbolPosition;
    },
  ];
}

Add console.warning "This "comp. prop" will be deprecated in v5, see https:// for more info.

proand commented 2 months ago

Note to my self: check Fhi.Frontend.RnD #11 for more info

proand commented 2 months ago

@yleaxeman Here are some of my earlier thoughts: https://github.com/folkehelseinstituttet/Fhi.Frontend.Demo/commit/4efe3f85cfbd394d64f30bbaad5f101d765e358e