Angular 4

Angular 4 Line Chart Example – How to Use Line Chart in Angular 4?

Line Chart –
A line-chart is a chart which used to displays information as a series of data points and it is called straight line segments.

Stayed Informed - Angular4 Interview Q/A

Example for Line Chart –

LineChart.Component.ts –
import {Component} from '@angular/core';

export class LineChart {

   data: any;
   Message: any[];

    constructor() {
        this.data = {
            labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
            datasets: [
                {
                    label: '',
                    data: [62, 58, 80, 82, 57, 56, 40],
                    fill: false,
                    borderColor: '#4bc0c0'
                },
                {
                    label: '',
                    data: [29, 47, 42, 19, 84, 25, 90],
                    fill: false,
                    borderColor: '#565656'
                }
            ]
        }
    }

    selectChartData(event) {
        this.Message = [];
        this.Message.push({ severity: 'info', summary: 'Your Data Selected', 'detail': this.data.datasets[event.element._datasetIndex].data[event.element._index] });
    }
}

Linechart.html –

<div class="row">
    <div class="col-lg-12" id="LineChart">
        <p-growl [value]="Message"></p-growl>
        <p-chart type="line" [data]="data" (onDataSelect)="selectChartData($event)"></p-chart>
    </div>
</div>

Result –
I hope you are enjoying with this post! Please share with you friends!! Thank you!!!
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^