UNPKG

@carbon/charts

Version:
45 lines 1.95 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); // Internal Imports import { ChartModel } from './model'; /** The charting model layer which includes mainly the chart data and options, * as well as some misc. information to be shared among components */ var PieChartModel = /** @class */ (function (_super) { __extends(PieChartModel, _super); function PieChartModel(services) { return _super.call(this, services) || this; } PieChartModel.prototype.getTabularData = function (data) { var tabularData = _super.prototype.getTabularData.call(this, data); // if the data was changed to tabular format // update the group to the key so the slices render with the correct tooltips and colors if (data !== tabularData) { // If a label was set for the overall dataset, reassign it to key value tabularData.forEach(function (d) { if (d.key && d.key !== d.group) { d.group = d.key; } }); } return tabularData; }; PieChartModel.prototype.sanitize = function (data) { var tabularData = this.getTabularData(data); // Sort data based on value return tabularData.sort(function (a, b) { return b.value - a.value; }); }; return PieChartModel; }(ChartModel)); export { PieChartModel }; //# sourceMappingURL=../src/model-pie.js.map