New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ngx-chart

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-chart

Ngx-Chart provides chart solution for Angular.Currently supports Bar, Pie and Donut chart

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
40
-2.44%
Maintainers
1
Weekly downloads
 
Created
Source

NgxChart

npm npm GitHub stars GitHub issues

alt text alt text alt text

alt text alt text

Installation

To use ngx-chatbox in your project install it via npm:

npm i ngx-chart

Adding chart module to project

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { NgxChartModule } from 'ngx-chart';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgxChartModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Adding style for chart

styles.css

@import "~ngx-chart/styles.scss";

Bar Chart Usage

bar-example.component.ts

  chartData: ChartData[] = [
    { name: "India", value: 132, color: "#61b15a" },
    { name: "Nepal", value: 772, color: "#adce74" },
    { name: "USA", value: 142, color: "#fff76a" },
    { name: "UK", value: 112, color: "#ffce89" },
    { name: "Brazil", value: 162, color: "#d8f8b7" }
  ];
  chartOptions: BarChartOption = {
    roundedCorners: false,
    showLegend: true,
    legendTitle: 'Total',
    isHorizontal: false
  }
  barView: ChartView = {
    height: 400,
    width: 400
  }

bar-example.component.html

<ngx-bar-chart [chartData]='chartData' [chartOptions]='chartOptions' [view]='barView' ></ngx-bar-chart>

Pie Chart Usage

pie-example.component.ts

  chartData: ChartData[] = [
    { name: "India", value: 132, color: "#61b15a" },
    { name: "Nepal", value: 772, color: "#adce74" },
    { name: "USA", value: 142, color: "#fff76a" },
    { name: "UK", value: 112, color: "#ffce89" },
    { name: "Brazil", value: 162, color: "#d8f8b7" }
  ];
  pieView: PieChartView= {
    height:400,
    width:400,
    radius:160
  }
  chartOptions: ChartOption = {
    showLegend: true,
    legendTitle: 'Total'
  }

pie-example.component.html

<ngx-pie-chart [chartData]='chartData' [view]='pieView' [chartOptions]='chartOptions'></ngx-pie-chart>
To add hover effect for pie-chart
.ngx-pie .chart-wrapper path:hover {
    cursor: pointer;
    transform-origin: center;
    transform: scale(1.05);
}

Donut Chart Usage

donut-example.component.ts

  chartData: ChartData[] = [
    { name: "India", value: 132, color: "#61b15a" },
    { name: "Nepal", value: 772, color: "#adce74" },
    { name: "USA", value: 142, color: "#fff76a" },
    { name: "UK", value: 112, color: "#ffce89" },
    { name: "Brazil", value: 162, color: "#d8f8b7" }
  ];
  donutView: DonutChartView = {
    height: 400,
    width: 400,
    radius: 160,
    donutSize:40
  }
  chartOptions: ChartOption = {
    showLegend: true,
    legendTitle: 'Total'
  }

donut-example.component.html

<ngx-donut-chart [chartData]="chartData" [chartOptions]='chartOptions' [view]='donutView'></ngx-donut-chart>
To add hover effect for donut-chart
.ngx-donut .chart-wrapper path:hover {
    cursor: pointer;
    stroke-width: 55px;
}

License

GitHub license

Keywords

ngx-chart

FAQs

Package last updated on 24 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts