"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pie = void 0;
var tslib_1 = require("tslib");
var React = require("react");
var d3_shape_1 = require("d3-shape");
var d3_scale_1 = require("d3-scale");
var Arc_1 = require("../Arc/Arc");
var react_focus_1 = require("@fluentui/react-focus");
var colors_1 = require("../../../utilities/colors");
var Pie = /** @class */ (function (_super) {
    tslib_1.__extends(Pie, _super);
    function Pie(props) {
        var _this = _super.call(this, props) || this;
        _this.arcGenerator = function (d, i) {
            return (React.createElement(Arc_1.LabeledArc, { culture: _this.props.culture, key: i, data: d, innerRadius: _this.props.innerRadius, outerRadius: _this.props.outerRadius, color: "".concat(_this.colors(i)), theme: _this.props.theme }));
        };
        return _this;
    }
    Pie.prototype.render = function () {
        var _this = this;
        // const getClassNames = classNamesFunction<IPieProps, IPieStyles>();
        var _a = this.props, pie = _a.pie, data = _a.data, width = _a.width, height = _a.height, chartTitle = _a.chartTitle, theme = _a.theme;
        var defaultColors = [];
        if (data && !this.props.colors) {
            for (var i = 0; i < data.length; i++) {
                defaultColors.push((0, colors_1.getNextColor)(i, 0, theme === null || theme === void 0 ? void 0 : theme.isInverted));
            }
        }
        var _b = this.props.colors, colors = _b === void 0 ? defaultColors : _b;
        this.colors = (0, d3_scale_1.scaleOrdinal)().range(colors.map(function (color) { return (0, colors_1.getColorFromToken)(color); }));
        var piechart = pie(data);
        var translate = "translate(".concat(width / 2, ", ").concat(height / 2, ")");
        return (React.createElement(react_focus_1.FocusZone, { direction: react_focus_1.FocusZoneDirection.domOrder },
            React.createElement("svg", { width: width, height: height, "aria-label": chartTitle },
                React.createElement("g", { className: "pie", transform: translate }, piechart.map(function (d, i) { return _this.arcGenerator(d, i); })))));
    };
    Pie.defaultProps = {
        pie: (0, d3_shape_1.pie)()
            .padAngle(0.01)
            .sort(null)
            /* eslint-disable @typescript-eslint/no-explicit-any */
            .value(function (d) { return d.y; }),
    };
    return Pie;
}(React.Component));
exports.Pie = Pie;
//# sourceMappingURL=Pie.js.map