Code Monkey home page Code Monkey logo

angular2-chartjs2's Introduction

Chart.js v2 Angular 2 Component

This repository contains a component for Chart v2 used in an Angular 2 component. The basic principles were taken from: https://github.com/valor-software/ng2-charts, but differed that far a some point, that I created an own repository.

Usage

Currently there are no sample files, and also no things package.json files. What you need to do, to get Chart.js v2 running with this Angular 2 component is as follows:

Include your Chart.js file in your index.html as follows:

<script src="lib/Chart.js"></script>

Include the chart-renderer.ts in your bootstrap.ts as follows:

import { ChartRenderer } from './services/chart/chart-renderer';

Include the chart-renderer.ts in your @Component/@View as follows:

`import { ChartRenderer } from '../../services/chart/chart-renderer';``

@Component({
  ...
  directives: [
    ChartRenderer
  ]
})
...

Include a chart in your HTML file as follows:

<base-chart class="chart"
		 [data]="chart.data"
		 [labels]="chart.labels"
		 [series]="chart.series"
		 [chartType]="chart.type"
		 [options]="chart.options"
		 (chart-hover)="chartHovered($event)"
		 (chart-click)="chartClicked($event)"></base-chart>

API

Properties

  • data (Array<any>) - set of points of the chart, it should be Array<Array<number>> only for line, bar and radar, otherwise Array<number>
  • labels (?Array<any>) - x axis labels. It's necessary for charts: line, bar and radar. And just labels (on hover) for charts: polar area, pie and doughnut
  • chartType (?string) - indicates the type of charts, it can be: 'Line', 'Bar', 'Radar', 'Pie', 'PolarArea', 'Doughnut'
  • options (?any) - chart options (as from Chart.js documentation)
  • series (?Array<any>) - name points on the chart, work for line, bar and radar
  • colours (?Array<any>) - data colours, will use default colours if not specified (see readme for components)
  • legend: (?boolean=false) - if true show legend below the chart, otherwise not be shown

Events

  • chartClick: fires when click on a chart has occurred, returns information regarding active points and labels
  • chartHover: fires when mousemove (hover) on a chart has occurred, returns information regarding active points and labels

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

License

The MIT License (see the LICENSE file for the full text)

angular2-chartjs2's People

Contributors

jhiemer avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.