import { isString, map, uniq, flatten, filter, sortBy, keys } from "lodash"; import React from "react"; import PropTypes from "prop-types"; import { Section, Select } from "@/components/visualizations/editor"; const MappingTypes = { x: { label: "X Column" }, y: { label: "Y Columns", multiple: true }, series: { label: "Group by" }, yError: { label: "Errors column" }, size: { label: "Bubble Size Column" }, zVal: { label: "Color Column" }, }; export default function ColumnMappingSelect({ value, availableColumns, type, onChange }) { const options = sortBy(filter(uniq(flatten([availableColumns, value])), v => isString(v) && v !== "")); const { label, multiple } = MappingTypes[type]; return (
); } ColumnMappingSelect.propTypes = { value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]), availableColumns: PropTypes.arrayOf(PropTypes.string), type: PropTypes.oneOf(keys(MappingTypes)), onChange: PropTypes.func, }; ColumnMappingSelect.defaultProps = { value: null, availableColumns: [], type: null, onChange: () => {}, }; ColumnMappingSelect.MappingTypes = MappingTypes;