@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
53 lines • 2.38 kB
JavaScript
;
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 __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
// (C) 2007-2018 GoodData Corporation
var React = require("react");
var unescape = require("lodash/unescape");
var common_1 = require("../../utils/common");
var VISIBLE_COLOR = "#6D7680";
var DISABLED_COLOR = "#CCCCCC";
var LegendItem = /** @class */ (function (_super) {
__extends(LegendItem, _super);
function LegendItem() {
return _super !== null && _super.apply(this, arguments) || this;
}
LegendItem.prototype.render = function () {
var _this = this;
var _a = this.props, item = _a.item, chartType = _a.chartType, width = _a.width;
var itemChartType = common_1.isComboChart(chartType) ? item.type : chartType;
var enableBorderRadius = common_1.isLineChart(itemChartType) || common_1.isAreaChart(itemChartType);
var iconStyle = {
borderRadius: enableBorderRadius ? "50%" : "0",
backgroundColor: item.isVisible ? item.color : DISABLED_COLOR,
};
var nameStyle = {
color: item.isVisible ? VISIBLE_COLOR : DISABLED_COLOR,
};
var style = width ? { width: width + "px" } : {};
var onItemClick = function () {
return _this.props.onItemClick(item);
};
return (React.createElement("div", { style: style, className: "series-item", onClick: onItemClick },
React.createElement("div", { className: "series-icon", style: iconStyle }),
React.createElement("div", { className: "series-name", style: nameStyle, title: unescape(item.name) }, item.name)));
};
LegendItem.defaultProps = {
width: null,
};
return LegendItem;
}(React.Component));
exports.default = LegendItem;
//# sourceMappingURL=LegendItem.js.map