All Projects → gevgeny → Angular2 Highcharts

gevgeny / Angular2 Highcharts

Licence: mit
📊 📈 Highcharts for your Angular project

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Angular2 Highcharts

React Jsx Highcharts
Highcharts built with proper React components
Stars: ✭ 336 (-14.5%)
Mutual labels:  charting-library, highcharts
Chartkick.py
Create beautiful Javascript charts with minimal code
Stars: ✭ 695 (+76.84%)
Mutual labels:  charting-library, highcharts
Aachartkit
📈📊🚀🚀🚀An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的跨平台数据可视化图表框架,支持柱状图、条形图、折…
Stars: ✭ 4,358 (+1008.91%)
Mutual labels:  charting-library, highcharts
data-visualization
🔗 configurable data visualization
Stars: ✭ 18 (-95.42%)
Mutual labels:  highcharts
highcharts-export-clientside
Module for Highcharts to exports charts client-side
Stars: ✭ 49 (-87.53%)
Mutual labels:  highcharts
Gochart
A chart plotting tool implemented by Golang and Highcharts.
Stars: ✭ 293 (-25.45%)
Mutual labels:  highcharts
Anychart
AnyChart is a lightweight and robust JavaScript charting solution with great API and documentation. The chart types and unique features are numerous, the library works easily with any development stack.
Stars: ✭ 288 (-26.72%)
Mutual labels:  charting-library
Plotly.swift
Interactive data visualization library for Swift
Stars: ✭ 70 (-82.19%)
Mutual labels:  charting-library
Recharts
Redefined chart library built with React and D3
Stars: ✭ 17,455 (+4341.48%)
Mutual labels:  charting-library
Go Chart
go chart is a basic charting library in go.
Stars: ✭ 3,254 (+727.99%)
Mutual labels:  charting-library
Percentagechartview
An Android percentage chart that displays the progress of any single given task or information.
Stars: ✭ 324 (-17.56%)
Mutual labels:  charting-library
Dygraphs
Interactive visualizations of time series using JavaScript and the HTML canvas tag
Stars: ✭ 2,953 (+651.4%)
Mutual labels:  charting-library
ux-charts
Simple, responsive, modern Charts with zero dependencies
Stars: ✭ 22 (-94.4%)
Mutual labels:  charting-library
Lightweight Charts
Financial lightweight charts built with HTML5 canvas
Stars: ✭ 4,390 (+1017.05%)
Mutual labels:  charting-library
vue3-highcharts
Vue 3 component wrapper for Highcharts.js
Stars: ✭ 41 (-89.57%)
Mutual labels:  highcharts
Aachartcore Kotlin
📈📊⛰⛰⛰An elegant modern declarative data visualization chart framework for Android . Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types.极其精美而又强大的 Android 数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
Stars: ✭ 332 (-15.52%)
Mutual labels:  highcharts
asciichart-sharp
C# port of asciichart
Stars: ✭ 27 (-93.13%)
Mutual labels:  charting-library
Plottable
📊 A library of modular chart components built on D3
Stars: ✭ 2,834 (+621.12%)
Mutual labels:  charting-library
React Chartjs 2
React components for Chart.js, the most popular charting library
Stars: ✭ 4,667 (+1087.53%)
Mutual labels:  charting-library
Redispapa
another redis monitor by using flask, angular, socket.io
Stars: ✭ 389 (-1.02%)
Mutual labels:  highcharts

⚠️ Not supported anymore.
Consider using the offical Highcharts wrapper for Angular

angular2-highcharts

Highcharts chart components for Angular apps. 👉 Live Demo

build npm version npm dependencies npm downloads

Table of Contents

Setting Up

Install angular2-highcharts

npm install angular2-highcharts --save

Setup App @NgModule

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ChartModule } from 'angular2-highcharts';
import { App } from './App';

@NgModule({
    imports: [
      BrowserModule, 
      ChartModule.forRoot(require('highcharts'))
    ],
    declarations: [App],
    bootstrap: [App]
})
export class AppModule {}

For angular-cli and other Webpack environments

No any additional setup needed

For SystemJS environment

You should add appropriate mapping to your systemjs.config.js

...
map: {
  ...
  'angular2-highcharts': 'node_modules/angular2-highcharts',
  'highcharts': 'node_modules/highcharts',
}
...
packages: {
  ...
  highcharts: {
    main: './highcharts.js',
    defaultExtension: 'js'
  },
  'angular2-highcharts': {
    main: './index.js',
    defaultExtension: 'js'
  }
}

Usage

Basic Usage

Create First Chart Component

Main charts functionality provided by the chart component and its options property.

import { Component } from '@angular/core';

@Component({
    selector: 'simple-chart-example',
    template: `
        <chart [options]="options"></chart>
    `
})
export class App {
    constructor() {
        this.options = {
            title : { text : 'simple chart' },
            series: [{
                data: [29.9, 71.5, 106.4, 129.2],
            }]
        };
    }
    options: Object;
}

👉 Live Demo

Handling Events

Highcharts itself provides bunch of events, and you still can use them with angular2-higcharts via the options property of the chart component. But it is not an angular way to handle events like this. So that angular2-higcharts provides EventEmitter<ChartEvent> wrappers for highcharts events. ChartEvent is an angular2-higcharts class which simply wraps original Highcharts events (chartEvent.originalEvent) and adds event handler context (chartEvent.context) since it differs depending on events.

Chart Events

All the events from the options.chart.events are available as output properties of the chart component.

<chart [options]="options" (selection)="onChartSelection($event)"> </chart>
onChartSelection (e) {
  this.from = e.originalEvent.xAxis[0].min.toFixed(2);
  this.to = e.originalEvent.xAxis[0].max.toFixed(2);
}

👉 Live Demo

Series Events

To use series events the same way you need to add the series component as a child of your chart. The only purpose of this auxiliary component is to provide access to options.plotOptions.series.events API

<chart [options]="options">
    <series (mouseOver)="onSeriesMouseOver($event)">
    </series>
</chart>
<p><b>{{serieName}}</b> is hovered<p>
onSeriesMouseOver (e) {
  this.serieName = e.context.name;
}

👉 Live Demo

Point Events

Similary you can use the point to access to options.plotOptions.series.point.events API.

<chart [options]="options">
    <series>
        <point (select)="onPointSelect($event)"></point>
    </series>
</chart>
<p><b>{{point}}</b> is selected<p>

👉 Live Demo

Axis Events

Similary you can use the xAxis or yAxes to access to options.xAxis.events or options.yAxis.events API.

<chart [options]="options">
     <xAxis (afterSetExtremes)="onAfterSetExtremesX($event)"></xAxis>
     <yAxis (afterSetExtremes)="onAfterSetExtremesY($event)"></yAxis>
</chart>
<p>{{minX}} - {{maxX}}<p>
<p>{{minY}} - {{maxY}}<p>
onAfterSetExtremesX (e) {
  this.minX = e.context.min;
  this.maxX = e.context.max;
}
onAfterSetExtremesY (e) {
  this.minY = e.context.min;
  this.maxY = e.context.max;
}

👉 Live Demo

Dynamic Interaction with Chart Object

angular2-higcharts provides possibility to interact with native HighchartsChartObject chart object.

@Component({
    selector: 'my-app',
    directives: [CHART_DIRECTIVES],
    template: `
      <chart [options]="options" 
             (load)="saveInstance($event.context)">
      </chart>
    `
})
class AppComponent {
    constructor() {
        this.options = {
          chart: { type: 'spline' },
          title: { text : 'dynamic data example'}
          series: [{ data: [2,3,5,8,13] }]
        };
        setInterval(() => this.chart.series[0].addPoint(Math.random() * 10), 1000);
    }
    chart : Object;
    options: Object;
    saveInstance(chartInstance) {
        this.chart = chartInstance;
    }
}

👉 Live Demo

Highstock

<chart type="StockChart" [options]="options"></chart>

Also you need to change your @NgModule setup.

...
@NgModule({
    ...
    imports: [
      BrowserModule, 
      ChartModule.forRoot(
-       require('highcharts'),
+       require('highcharts/highstock')
      )
    ]
})

👉 Live Demo

Highmaps

<chart type="Map" [options]="options"></chart>

Also you need to change your @NgModule setup.

...
@NgModule({
    ...
    imports: [
      BrowserModule, 
      ChartModule.forRoot(
-       require('highcharts'),
+       require('highcharts/highmaps')
      )
    ],
})

👉 Live Demo

Add Highcharts Modules

Any other modules like highcharts-3d, highcharts-exporintg and etc. can be also added in @NgModule after main chart module

...
@NgModule({
    ...
    imports: [
      BrowserModule, 
      ChartModule.forRoot(
        require('highcharts'),
+       require('highcharts/highchart-3d'),
+       require('highcharts/modules/exporting')
      )
    ],
})

Check out structure of the node-modules/highcharts folder to find necessary module.

👉 Live Demo

Access to the Highcharts Static API

...
const Highcharts = require('highcharts');

Highcharts.setOptions({
  colors: ['#50B432']
});

@NgModule({
    ...
    imports: [
      BrowserModule, 
      ChartModule.forRoot(
-       require('highcharts'),
+       Highcharts
      )
    ],
})

👉 Live Demo

##More Examples

Here are some common charts examples with Webpack integration https://github.com/gevgeny/angular2-highcharts/tree/master/examples/webpack

##FAQ

Why don't my series, title, axes and etc redraw after I update initial options ?

Because angular-highcharts is just a thin wrapper of the [Highcharts](http:/ /www.highcharts.com/) library and doesn't bind to initial options. I understand that you expect more angular-way behaviour like data binding with appropriate redrawing. But it is barely possible to implement it without redundant complications and performance decrease because almost all options can be dynamic. So my idea was to avoid any additional logic more than just a sugar (like events for series and options). In the other hand Highcharts has great API for dynamic manipulations with chart and angular-highcharts provides you access to the original chart object.

License

MIT @ Eugene Gluhotorenko

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].