3.2.0 • Published 16 days ago

@folkehelseinstituttet/angular-highcharts v3.2.0

Weekly downloads
-
License
-
Repository
github
Last release
16 days ago

FHI Angular Highcharts

An opinionated wrapper to the official minimal Highcharts wrapper for Angular

Dependencies

FHI Angular HighchartsFHI Angular ComponetsFHI StyleBootstrapNgBootstrapHighchartsHighcharts AngularAngularNode/NPM
3.246.25.3.21611.44.01718/10 *
3.14.06.25.3.21611.44.01718/10 *
34.065.3.21611.14.01718/10 *
23.15.95.3.21611.14.01718/10 *
1-551511.14.01618/9 *
0.7-551411.13.1.21518/9 *
0.6-551410.3.33.11518/9 *
0.5-551410.3.33.11518/9 *
0.4-5510.3.33.11518/9 *
0.3-5510.3.33.11518/9 *
0.2-4510.3.33.11518/9 *
0.1-4510.331416/8 *

For more dependencies see peerDependencies in package.json

* designsystem.fhi.no uses these Node/NPM versions, older versions may work, but then you're on your own :wink:

Get started

Install

Install with npm: npm install @folkehelseinstituttet/angular-highcharts

Add to app

After installing the package and all dependencies, add the following code to your app:

// In global css-file (usually style.scss)
@import "./node_modules/@folkehelseinstituttet/angular-highcharts/styles/import/all";
// In a standalone component or a shared module
import { FhiAngularHighchartsModule } from '@folkehelseinstituttet/angular-highcharts';
...
  imports: [FhiAngularHighchartsModule]
...
// In a component (.ts)
import { FhiDiagramOptions, FhiDiagramSerie, FhiDiagramTypeIds } from '@folkehelseinstituttet/angular-highcharts';
...
  data: FhiDiagramSerie[] = [...];
  diagramOptions: FhiDiagramOptions = {
    title: 'Diagram title',
    data: data,
    diagramTypeId: 'line'
  };
...
<!-- In a template -->
<fhi-angular-highcharts [diagramOptions]="diagramOptions"></fhi-angular-highcharts>

Remove warnings

Highcharts gives some warnings due to the use of CommonJs as described here: https://github.com/highcharts/highcharts/issues/14183

From one of the comments:

Highcharts uses the UMD pattern which includes AMD, and it is probably detected by angular. On the other hand, I don't think that using an ES6 module pattern will change anything in the performance matters, you would have to import the entire highcharts core anyway, so technically it will be the same package - I would suggest ignoring the warning by adding Highcharts to the allowedCommonJsDependencies property in the angular.json file.

This is where allowedCommonJsDependencies i located in angular.json

...
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "allowedCommonJsDependencies": ["highcharts"],
...

API

Inputs

InputTypeDefaultRequiredDescription
[diagramOptions]FhiDiagramOptions-yesAll properties used to configure the diagram. See FhiDiagramOptions for details. NB! The object sent in to @Input diagramOptions needs to be reassigned for change detection to kick in.

Outputs

OutputEvent typeDescription
(diagramTypeNavigation)FhiDiagramTypeIdsIf diagram type navigation i visible, this event will fire on every navigation. Outputs an existing diagram type id.
(metadataButtonClick)voidWhen link to "Om dataene" is clicked.

Type FhiDiagramOptions

PropertyTypeDefaultRequiredDescription
creditsHrefstring-noLink to source ref. in footer.
creditsTextstring-noText to source ref. in footer.
diagramTypeIdstringtablenoID to specify default diagram type. Values defined by enum FhiDiagramTypeIds
diagramTypeNavIdstring-noID to specify which type of navigation to use. If omitted, no navigation will be rendered. Values defined by enum DiagramTypeNavIds
[diagramTypeSubset]Array<string>-noID's for diagram types available in navigation, in addition to table. If omitted, all diagram types that are possible for the given series will show in the navigation. Values for each array item defined by enum FhiDiagramTypeIds
disclaimerstring-noText at the bootom of the footer used to say something about uncertainty in the data shown in a diagram.
[flags]Array<FhiDiagramFlag>-noList of all flags used in FhiDiagramSerie[].
metadataButtonbooleanfalsenoPossible to activate a button to trigger or navigate to metadata information in a way you desire.
lastUpdatedstring-noText after label Sist oppdatert in footer. Free format, but dd.mm.yyyy is the most common one.
mapTypeIdMapTypeIds-noID to specify map type. If omitted, map will not be available in the diagram navigation.
[openSource]booleantruenoIf false; the link to Highcharts.com disappears, AND LICENSE IS REQUIRED!
[series]Array<FhiDiagramSerie>-yesThe data used to render a diagram. See FhiDiagramSerie for details.
tableOrientationstring-noTranspose table by setting preferd orientation. Values defined by enum FhiTableOrientations
titlestring-yesThe title above the diagram.
unitArray<FhiDiagramUnit>-noDecimal count, and metadata for y-axis and tooltip.

Type FhiDiagramSerie

PropertyTypeDefaultRequiredDescription
dataArray<FhiDiagramSerieData>-yesThe individual data points in a serie.
namestring \| Array<string>-yesThe name of the serie as shown in the legend. NB! The type string is an formatted string; pipe (\|) is beeing used as seperator between category names if more than one category name is concatenated to one single serie name. To avoid dependency on a given separator, use an array of category names instead.
stackstring-yesThis option allows for grouping series in a stacked chart. Only applies to diagramTypeId barStacked and columnStacked.

Type FhiDiagramSerieData

FhiDiagramSerieData is a custum type for FHI Angular Highcharts, but it is based on the smallest possible subset of the chart.series.[chart type].data object as described under nr 3. here (line chart used as example).

PropertyTypeDefaultRequiredDescription
namestring-yesThe name of the data point as shown in the tooltip.
ynumber \| string-yesThe value of the data point. If type is string the data point is treated as a flagged value.

Type FhiDiagramFlag

PropertyTypeDefaultRequiredDescription
labelstring-yesDescription of the flag, ie. Anonymized
symbolstring-yesSymbol representing the flag, ie. :.

Type FhiDiagramUnit

PropertyTypeDefaultRequiredDescription
decimalsnumber-noThe decimal count. If not set the decimal count same as in data. Count is limited to 14 decimals due to loss of precision at runtime above 14. A warning will be given in the consol if more than 14 decimals.
labelstring-yesThe vertical y-axis label, showing next to the axis line.
symbolstring-noSymbol before or after the value in both tooltip and y-axis.
positionstring-noWether the symbol i placed before or after the numbers in the diagram. Possible values: 'start' \| 'end'

Changelog

You find the changelog here.

Contribute

Read about how to contribute here

Demo

3.2.0

16 days ago

3.1.0

30 days ago

3.0.0

2 months ago

2.1.1

3 months ago

2.1.0

3 months ago

1.1.2

3 months ago

1.1.1

3 months ago

2.0.0

4 months ago

1.1.0

4 months ago

1.0.0

5 months ago

0.7.0

9 months ago

0.6.1

10 months ago

0.6.0

11 months ago

0.5.0

11 months ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago