import React from "react"; import { localization } from "../Localization/localization"; import { Stack, StackItem } from "office-ui-fabric-react/lib/Stack"; import { DataSpecificationBlade } from "./DataSpecificationBlade"; import { Separator } from "office-ui-fabric-react/lib/Separator"; import { IWizardTabProps } from "../IWizardTabProps"; import { WizardFooter } from "./WizardFooter"; import { List } from "office-ui-fabric-react/lib/List"; import { mergeStyleSets } from "@uifabric/styling"; import { Icon } from "office-ui-fabric-react/lib/Icon"; import { IBinnedResponse } from "../IBinnedResponse"; import { Text } from "office-ui-fabric-react/lib/Text"; import { Modal } from 'office-ui-fabric-react/lib/Modal'; import { ActionButton } from "office-ui-fabric-react/lib/Button"; import BinDialog from "./BinDialog"; import { INumericRange, RangeTypes } from "mlchartlib"; interface IFeatureItem { title: string; description: string; onSelect: (index: number) => void; selected: boolean; categories?: string[]; } export interface IFeatureTabProps extends IWizardTabProps { featureBins: IBinnedResponse[]; selectedFeatureIndex: number; selectedFeatureChange: (value: number) => void; saveBin: (bin: IBinnedResponse) => void; } interface IState { expandedBins: number[]; editingFeatureIndex: number | undefined; } export class FeatureTab extends React.PureComponent { private static readonly classNames = mergeStyleSets({ itemCell: { display: "flex", flexDirection: "row", padding: "20px 0", width: "100%", cursor: "pointer", boxSizing: "border-box", borderBottom: "1px solid #CCCCCC", selectors: { '&:hover': { background: "lightgray" } } }, iconClass: { fontSize: "20px" }, itemsList: { overflowY: "auto" }, frame: { height: "100%", }, main: { height: "100%", maxWidth: "700px", flex: 1 }, header: { color: "#333333", fontSize: "32px", lineHeight: "39px", fontWeight: "100" }, textBody: { paddingTop: "12px", fontSize: "18px", lineHeight: "24px", fontWeight: "300", marginBottom: "15px" }, tableHeader: { display: "flex", flexDirection: "row", justifyContent: "space-between", paddingBottom: "15px", color: "#333333", fontSize: "15px", lineHeight: "18px", fontWeight: "500", borderBottom: "1px solid #CCCCCC" }, itemTitle: { margin: 0, color: "#333333", fontSize: "22px", lineHeight: "26px", fontWeight: "300" }, valueCount: { paddingTop: "15px", color: "#333333", fontSize: "15px", lineHeight: "18px", fontWeight: "500" }, iconWrapper: { paddingTop: "4px", paddingLeft: "5px", width: "30px" }, featureDescriptionSection: { flex: 1, paddingRight: "20px", minHeight:"75px" }, binSection:{ width:"130px", }, expandButton: { paddingLeft: 0, selectors: { "& i":{ marginLeft: 0 } } }, category: { textOverflow: "ellipsis", whiteSpace: "nowrap", overflow: "hidden" }, subgroupHeader: { width: "130px" } }); constructor(props: IFeatureTabProps) { super(props); this.state = { expandedBins: [], editingFeatureIndex: undefined }; } render(): React.ReactNode { return( { this.state.editingFeatureIndex !== undefined && }

{localization.Feature.header}

{localization.Feature.body}

{localization.Intro.features}
{localization.Feature.subgroups}
); } private readonly hideModal = (): void => { this.setState({editingFeatureIndex: undefined}); } private readonly onBinSave = (bin: IBinnedResponse): void => { this.setState({editingFeatureIndex: undefined}); this.props.saveBin(bin); } private readonly editBins = (index: number) => { this.setState({editingFeatureIndex: index}); } private readonly _onRenderCell = (item: IBinnedResponse, index: number | undefined): JSX.Element => { return (

{this.props.dashboardContext.modelMetadata.featureNames[index]}

{item.rangeType === RangeTypes.categorical &&
{localization.formatString(localization.Feature.summaryCategoricalCount, item.array.length) as string}
} {item.rangeType !== RangeTypes.categorical &&
{localization.formatString(localization.Feature.summaryNumericCount, (this.props.dashboardContext.modelMetadata.featureRanges[index] as INumericRange).min, (this.props.dashboardContext.modelMetadata.featureRanges[index] as INumericRange).max, item.labelArray.length) as string}
} {!this.props.dashboardContext.modelMetadata.featureIsCategorical[index] && {localization.Feature.editBinning} }
{!this.state.expandedBins.includes(index) && !!item.labelArray &&
{item.labelArray.slice(0,7).map((category, index) =>
{category}
)} {item.labelArray.length > 7 && {localization.Feature.showCategories}}
} {this.state.expandedBins.includes(index) && !!item.labelArray &&
{item.labelArray.map((category, index) =>
{category}
)} {{localization.Feature.hideCategories}}
}
); } private readonly updateExpandedList = (value?: number): void => { this.setState(() => {return {expandedBins: [value]}}) } }