Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@feature23/ngx-linear-pie

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feature23/ngx-linear-pie

A linear "pie" chart component for Angular Material.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by233.33%
Maintainers
0
Weekly downloads
 
Created
Source

ngx-linear-pie

A linear "pie" chart component for Angular Material.

Installation

npm i --save @feature23/ngx-linear-pie

Usage

Import NgxLinearPieComponent into either your standalone component's imports array, or the module in which it will be used.

Create an array of NgxLinearPieData objects where each element in the array represents a data point, or "slice," of the pie. The value property should be the raw value of the data point. There is no need to compute percentages yourself; the component will do this based on the sum of all of the values.

data: NgxLinearPieData[] = [
    { 
        name: "cs", 
        title: "C#", 
        value: 705,
    },
    { 
        name: "ts", 
        title: "TypeScript", 
        value: 462,
    },
    { 
        name: "html", 
        title: "HTML",
        value: 390,
    },
    { 
        name: "scss", 
        title: "SCSS",
        value: 275,
    },
    { 
        name: "sql", 
        title: "SQL",
        value: 42, 
    },
];

Only name and value are required properties. The title value is shown in the UI if provided, otherwise the name value is shown. This can allow you to use the name property as a programmatic value (i.e. an identifier) if desired.

By default, the component will use a rainbow palette using Material colors. If you wish to customize the colors, you can provide a color property to each data object.

For further customization, you can provide a className property to each data object to give each slice a CSS class name.

The data may be computed if desired, and this component works well with Angular Signals, too.

Once you have your data, add the component to your HTML template:

<ngx-linear-pie [data]="data" />

Inputs

The ngx-linear-pie component allows for the following inputs to customize its appearance and behavior:

InputTypeDescription
[data]NgxLinearPieData[](Required) The data to display in the component
[allowClick]boolean(Optional; default false) Whether to allow clicking pie slices or legend entries. Not very useful without subscribing to the (sliceClick) event.
[showLegend]boolean(Optional; default false) Whether to show a legend below the chart
[valuesAsPercentages]boolean(Optional; default false) Whether to show tooltip and legend values as percentages (if true) or the raw values (if false).

Events

The following output events are available to support interactivity:

OutputEvent/Argument TypeDescription
(sliceClick)NgxLinearPieDataEmitted when the user clicks or presses Enter on a pie chart slice or legend entry. This event is not emitted if [allowClick] is false or unset.

FAQs

Package last updated on 23 Sep 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc