0.2.1 • Published 5 years ago

angular-pie v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Angular Pie

Installation

npm i angular-pie

Usage

Import the AngularPieComponent to app.modules.ts.

import { AngularPieComponent } from 'angular-pie';

@NgModule({
  declarations: [... , AngularPieComponent],
})

Add <lib-angular-pie></lib-angular-pie> to the app.component.html, then add a mousedown event to call the menu.

<div (mousedown)="callPie($event)" [style.width.px]="'100%'" [style.height.px]="'100%'">
  <lib-angular-pie></lib-angular-pie>
</div>

Import the AngularPieService to the app.component.ts, then create a call function, add the pie slices and options.

import { Component } from '@angular/core';
import { AngularPieService, PieOptions, PieSlice } from 'angular-pie';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.sass']
})
export class AppComponent {
    pieSlices: PieSlice[] = [{ title: 'Slice 1' }, { title: 'Slice 2' }, { title: 'Slice 3' }, { title: 'Slice 4' }];
    pieOptions: PieOptions = {};
    constructor(pie: AngularPieService) {}

    callPieMenu(event: MouseEvent) {

        this.pie.call(event: MouseEvent, this.pieSlices: PieSlice[], this.pieOptions: PieOptions);
    }
}

Slice Functions

Adding functions to a slice is simple, create a function, then add the function name, arguments and execution context to to slice that will activate the function.

Note: the context argument is set to this in this example because the function is part of this.

pieSliceWithFunction: PieSlice = { title: 'Slice 1', func: 'sliceFunction', args: ['string arg', 123], context: this }
pieSliceWithFunction2: PieSlice = { title: 'Slice 2', func: 'sliceFunction', args: ['different String', 321], context: this }
pieSlices: PieSlice[] = [ this.pieSliceWithFunction, this.pieSliceWithFunction2, { title: 'Slice 3' }, { title: 'Slice 4' }];

pieOptions: PieOptions = {};

constructor(private pie: AngularPieService) {}

callPie(event) {
    this.pie.call(event, this.pieSlices, this, this.pieOptions);
}

public sliceFunction(stringArg, numberArg) {
    console.log(stringArg);
    console.log(numberArg);
}

Pie Options

NameTypeDefaultDescription
borderColorstring#334157Slice border color when not Selected, Color in hex format.
borderColorHoverstring#517197Slice border color when Selected, Color in hex format.
borderWidthnumber2Width of Slice Border, in pixel.
borderRadiusnumber12Slice border Radius, in pixel.
colorstring#151619Color when slice is Not active or Selected, Color in hex format.
colorHoverstring#334157Color when slice is selected, Color in hex format.
colorActivestring#5595eeColor when slice is Active, Color in hex format.
circleBorderColorstring#151619Color if the inner circle border, Color in hex format.
circleBackgroundColorstring#00000000Color of the inner circle transparent by default, Color in hex format.
circleBorderWidthnumber2Width of the inner circle border, in pixel.
oneActiveColorbooleantrueIf true the border color will change to the active color (colorActive) when activated, Else the border color remains the same.
fontstringVerdanaFont family of slice title.
fontColorstring#eeeFont Color of slice title.
fontSizestring1Font size of slice title, in rem.
sizenumber180Size of slice container, in pixel
circleSizenumber80Size of the inner circle in, in pixel.
sliceXnumber100Slice width in pixel.
sliceYnumber24Slice height in pixel.
hideDelaynumber200Time the menu stays open after activation, in milliseconds.
roundbooleanfalseSlice width in pixel.
selectionDistancenumber40Selection Distance, in pixel.
activationDistancenumber60Activation Distance, in pixel, only acitve if activateAfterActivationDistance is set to true.
activationColorDistancenumber55Active color activation disatance, in pixel, only acitve if activateAfterActivationDistance is set to true.
activateAfterActivationDistancebooleanfalseIf true the menu gets activated after the activationDistance.
disableInnerMouseleaveActivationbooleantrueIf false the pie menu gets activated when the cursor leaves the inner circle.
disableMouseUpActivationbooleantrueIf false the pie menu gets activated when the mouse up event gets fired outside the inner circle.
disableCircleMousedownActvivationbooleantrueIf false the pie menu gets activated when the mouse down event gets fired in the inner circle.
disableOuterActivationbooleanfalseIf false the pie menu gets activated when the cursor leaves the outer circle, the outer circle width is size + SliceX same for the height.
disableInnnerMouseupbooleanfalseIf false the pie menu get activated when the mouse up event gets fired in the inner circle.

Pie Slice Options

NameOptionalTypeDescription
titleNostringSlice Title.
funcYesstringFunction Name of the function that gets fired when this slice gets activated.expected format is 'example' or 'function.example' do NOT include parentheses. arguments are passed in the args parameter.
argsYesany Function Arguments if the function that gets fired when this slice gets activated. expected format is 'arg1', 2, {arg: 3}
contextYesanyFunction Execution Context.
disableImgYesbooleanFalse by default, only enable when an image is nedded.
imgDataYesCustom { }Used to set the image properties of this slice.

imgData Object

NameOptionalTypeDescription
srcNostringImage Source
leftYesnumberLeft position relative to Slice, in pixel.
topYesnumberTop position relative to Slice, in pixel.
heightYesnumberImage height, in pixel.
widthYesnumberImage width, in pixel.

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago