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

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - https://code-sample.com and https://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book