Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
theiliad committed Nov 12, 2018
1 parent d20e883 commit 1fcf438
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions packages/core/src/donut-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,6 @@ import { interpolateNumber } from "d3-interpolate";
import { PieChart } from "./pie-chart";
import * as Configuration from "./configuration";

export class DonutChart extends PieChart {
center: DonutCenter;

constructor(holder: Element, configs: any) {
super(holder, configs, "donut");

// Check if the DonutCenter object is provided
if (configs.options.centerLabel) {
this.center = new DonutCenter({
label: configs.options.centerLabel
});
}
}

draw() {
super.draw();

// Draw the center text
if (this.center && this.center.configs) {
const sumOfDatapoints = this.displayData.datasets[0].data.reduce((accum, currVal) => accum + currVal.value, 0);
this.center.configs.number = sumOfDatapoints;

this.center.draw(this.innerWrap);
}
}

resizeChart() {
if (this.innerWrap) {
// Inherit resizing logic from PieChart
super.resizeChart();

if (this.center) {
// Trigger resize on DonutCenter as well
this.center.resize(this.innerWrap, this.getChartSize(this.container));
}
}
}

update() {
super.update();

if (this.center) {
const sumOfDatapoints = this.displayData.datasets[0].data.reduce((accum, currVal) => accum + currVal.value, 0);

this.center.configs.number = sumOfDatapoints;
this.center.update();
}
}
}

export class DonutCenter {
configs: any;
oldConfigs: any;
Expand Down Expand Up @@ -130,6 +80,56 @@ export class DonutCenter {
}
}

export class DonutChart extends PieChart {
center: DonutCenter;

constructor(holder: Element, configs: any) {
super(holder, configs, "donut");

// Check if the DonutCenter object is provided
if (configs.options.centerLabel) {
this.center = new DonutCenter({
label: configs.options.centerLabel
});
}
}

draw() {
super.draw();

// Draw the center text
if (this.center && this.center.configs) {
const sumOfDatapoints = this.displayData.datasets[0].data.reduce((accum, currVal) => accum + currVal.value, 0);
this.center.configs.number = sumOfDatapoints;

this.center.draw(this.innerWrap);
}
}

resizeChart() {
if (this.innerWrap) {
// Inherit resizing logic from PieChart
super.resizeChart();

if (this.center) {
// Trigger resize on DonutCenter as well
this.center.resize(this.innerWrap, this.getChartSize(this.container));
}
}
}

update() {
super.update();

if (this.center) {
const sumOfDatapoints = this.displayData.datasets[0].data.reduce((accum, currVal) => accum + currVal.value, 0);

this.center.configs.number = sumOfDatapoints;
this.center.update();
}
}
}

function donutCenterNumberTween(d3Ref, newNumber: number) {
// Remove commas from the current value string, and convert to an int
const currentValue = parseInt(d3Ref.text().replace(/[, ]+/g, ""), 10);
Expand Down

0 comments on commit 1fcf438

Please sign in to comment.