Top

Charts


you have to install Google Chart


 npm i ng2-google-charts

<google-chart [data]="areaChart1"></google-chart>
            
google-chart.ts file

import { Component } from '@angular/core';
import * as chartData from '../../../../shared/data/chart/google-chart';
import { Ng2GoogleChartsModule } from 'ng2-google-charts';

@Component({
    selector: 'app-area-chart1',
    templateUrl: './area-chart1.html',
    styleUrls: ['./area-chart1.scss'],
    standalone: true,
    imports: [Ng2GoogleChartsModule]
})

export class AreaChart1 {

  public areaChart1 = chartData.areaChart1

}


    import { GoogleChartType } from "ng2-google-charts";

    let primary_color = localStorage.getItem('primary_color') || '#678f44';
    let secondary_color = localStorage.getItem('secondary_color') || '#d1823f';

    export var areaChart1 = {
        chartType: 'AreaChart',
        dataTable: [
            ['Year', 'Sales', 'Expenses'],
            ['2013', 1000, 400],
            ['2014', 1170, 460],
            ['2015', 660, 1120],
            ['2016', 1030, 540]
        ],
        options: {
            title: 'Company Performance',
            hAxis: { title: 'Year', titleTextStyle: { color: '#333' } },
            vAxis: { minValue: 0 },
            width: '100%',
            height: 400,
            colors: [primary_color, secondary_color],
            backgroundColor: 'transparent'
        },
    };
<!-- Html code -->
<canvas baseChart class="chart" [datasets]="barChartChartData" [labels]="barChartChartLabels"
    [options]="barChartChartOptions" [legend]="barChartChartLegend" [type]="barChartChartType">
</canvas>


import { ChartType } from "chart.js";

let primary_color =  '#678f44';
let secondary_color =  '#d1823f';

export const barChart = {
  labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  responsive: false,
  datasets: [
    {
      label: 'My First dataset',
      backgroundColor: 'rgba(43, 94, 94, 0.4)',
      borderColor: primary_color,
      borderWidth: 2,
      data: [35, 59, 80, 81, 56, 55, 40],
    },
    {
      label: 'My Second dataset',
      borderColor: secondary_color,
      backgroundColor: 'rgba(192, 98, 64, 0.4)',
      borderWidth: 2,
      data: [28, 48, 40, 19, 86, 27, 90],
    },
  ],
  barOptions: [
    {
      scaleBeginAtZero: true,
      scaleShowGridLines: true,
      scaleGridLineColor: 'rgba(0,0,0,0.1)',
      scaleGridLineWidth: 1,
      scaleShowHorizontalLines: true,
      scaleShowVerticalLines: true,
      barShowStroke: true,
      barStrokeWidth: 2,
      barValueSpacing: 5,
      barDatasetSpacing: 1,
    },
  ],
};



import { Component } from '@angular/core';
import * as chartData from '../../../../shared/data/chart/chartsjs';
import { BaseChartDirective } from 'ng2-charts';

@Component({
    selector: 'app-bars-chart',
    templateUrl: './bars-chart.html',
    styleUrls: ['./bars-chart.scss'],
    standalone: true,
    imports: [BaseChartDirective]
})

export class BarsChart {

  public barChart = chartData.barChart;

}

app.config.ts

import { HttpClient, provideHttpClient } from '@angular/common/http';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { provideCharts, withDefaultRegisterables } from 'ng2-charts';

export const appConfig: ApplicationConfig = {
  providers: [
    provideZoneChangeDetection({ eventCoalescing: true }),
    provideRouter(routes),
    provideHttpClient(),
    provideAnimations(),
    provideCharts(withDefaultRegisterables()),
  ]
};

you have to install Chartist charts

  npm i ng-chartist

<x-chartist [configuration]="chart1"></x-chartist>

import { Component } from '@angular/core';
import * as chartData from '../../../../shared/data/chart/chartist';
import { ChartistModule } from 'ng-chartist';

@Component({
    selector: 'app-advanced-smil',
    templateUrl: './advanced-smil.html',
    styleUrls: ['./advanced-smil.scss'],
    standalone: true,
    imports: [ChartistModule]
})
export class AdvancedSmil {

  public chart1 = chartData.chart1;

}


import { LineChartConfiguration } from 'ng-chartist

let primary_color = localStorage.getItem('primary_color') || '#678f44';
let secondary_color = localStorage.getItem('secondary_color') || '#d1823f';

export var chart1: LineChartConfiguration = {
  type: 'Line',
  data: {
    labels: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
    series: [
      [12, 9, 7, 8, 5, 4, 6, 2, 3, 3, 4, 6],
      [4, 5, 3, 7, 3, 5, 5, 3, 4, 4, 5, 5],
      [5, 3, 4, 5, 6, 3, 3, 4, 5, 6, 3, 4],
      [3, 4, 5, 6, 7, 6, 4, 5, 6, 7, 6, 3],
    ],
  },
  options: {
    low: 0,
    showArea: false,
    fullWidth: true,
    height: 250,
  },
};

you have to install Apex charts

 npm i ng-apexcharts

<apx-chart [chart]="basicAreaChart.chart" [series]="basicAreaChart.series" [colors]="basicAreaChart.colors"
   [dataLabels]="basicAreaChart.dataLabels" [xaxis]="basicAreaChart.xaxis" [yaxis]="basicAreaChart.yaxis"
   [stroke]="basicAreaChart.stroke" [labels]="basicAreaChart.labels" [legend]="basicAreaChart.legend">
</apx-chart>

import { Component } from '@angular/core';
import * as chartData from '../../../../shared/data/chart/apex-charts';
import { NgApexchartsModule } from 'ng-apexcharts';

@Component({
    selector: 'app-basic-area-chart',
    templateUrl: './basic-area-chart.html',
    styleUrls: ['./basic-area-chart.scss'],
    standalone: true,
    imports: [NgApexchartsModule]
})

export class BasicAreaChart {

  public basicAreaChart = chartData.splineArea1

}
<!-- data file -->
import {BasicChart} from '../../interface/charts/apex-charts';

let primary_color = localStorage.getItem('primary_color') || '#678f44';
let secondary_color = localStorage.getItem('secondary_color') || '#d1823f';

export let splineArea1: BasicChart= {
    series: [
        {
            name: "STOCK ABC",
            data: [8107.85, 8128.0, 8122.9, 8165.5, 8340.7, 8423.7, 8423.5, 8514.3, 8481.85, 8487.7, 8506.9, 8626.2, 8668.95, 8602.3, 8607.55, 8512.9, 8496.25, 8600.65, 8881.1, 9340.85],
        }
    ],
    colors: ["var(--theme-default)"],
    chart: {
        type: "area",
        height: 350,
        toolbar: {
            show: false
        },
        zoom: {
            enabled: false
        }
    },
    dataLabels: {
        enabled: false
    },
    stroke: {
        curve: "straight"
    },
    labels: ["13 Nov 2017", "14 Nov 2017", "15 Nov 2017", "16 Nov 2017", "17 Nov 2017", "20 Nov 2017", "21 Nov 2017", "22 Nov 2017", "23 Nov 2017", "24 Nov 2017", "27 Nov 2017", "28 Nov 2017", "29 Nov 2017", "30 Nov 2017", "01 Dec 2017", "04 Dec 2017", "05 Dec 2017", "06 Dec 2017", "07 Dec 2017", "08 Dec 2017"
    ],
    xaxis: {
        type: "datetime"
    },
    yaxis: {
        opposite: true
    },
    legend: {
        horizontalAlign: "left"
    }
};