import { __extends } from "tslib";
import * as React from 'react';
import { pie as d3Pie } from 'd3-shape';
import { scaleOrdinal } from 'd3-scale';
import { LabeledArc } from '../Arc/Arc';
import { FocusZone, FocusZoneDirection } from '@fluentui/react-focus';
import { getColorFromToken, getNextColor } from '../../../utilities/colors';
var Pie = /** @class */ (function (_super) {
    __extends(Pie, _super);
    function Pie(props) {
        var _this = _super.call(this, props) || this;
        _this.arcGenerator = function (d, i) {
            return (React.createElement(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(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 = scaleOrdinal().range(colors.map(function (color) { return getColorFromToken(color); }));
        var piechart = pie(data);
        var translate = "translate(".concat(width / 2, ", ").concat(height / 2, ")");
        return (React.createElement(FocusZone, { direction: 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: d3Pie()
            .padAngle(0.01)
            .sort(null)
            /* eslint-disable @typescript-eslint/no-explicit-any */
            .value(function (d) { return d.y; }),
    };
    return Pie;
}(React.Component));
export { Pie };
//# sourceMappingURL=Pie.js.map