kristw commented on a change in pull request #5758: [SIP-5] Refactor and 
improve histogram
URL: 
https://github.com/apache/incubator-superset/pull/5758#discussion_r213864985
 
 

 ##########
 File path: superset/assets/src/visualizations/Histogram.jsx
 ##########
 @@ -0,0 +1,131 @@
+import PropTypes from 'prop-types';
+import React from 'react';
+import ReactDOM from 'react-dom';
+import { Histogram, BarSeries, XAxis, YAxis } from '@data-ui/histogram';
+import { chartTheme } from '@data-ui/theme';
+import { LegendOrdinal } from '@vx/legend';
+import { scaleOrdinal } from '@vx/scale';
+import { getColorFromScheme } from '../modules/colors';
+import './histogram.css';
+
+const propTypes = {
+  className: PropTypes.string,
+  data: PropTypes.arrayOf(PropTypes.shape({
+    key: PropTypes.string,
+    values: PropTypes.arrayOf(PropTypes.number),
+  })).isRequired,
+  width: PropTypes.number.isRequired,
+  height: PropTypes.number.isRequired,
+  colorScheme: PropTypes.string,
+  normalized: PropTypes.bool,
+  binCount: PropTypes.number,
+  opacity: PropTypes.number,
+  xAxisLabel: PropTypes.string,
+  yAxisLabel: PropTypes.string,
+};
+const defaultProps = {
+  className: '',
+  colorScheme: '',
+  normalized: false,
+  binCount: 15,
+  opacity: 1,
+  xAxisLabel: '',
+  yAxisLabel: '',
+};
+
+class CustomHistogram extends React.PureComponent {
+  render() {
+    const {
+      className,
+      data,
+      width,
+      height,
+      binCount,
+      colorScheme,
+      normalized,
+      opacity,
+      xAxisLabel,
+      yAxisLabel,
+    } = this.props;
+
+    const keys = data.map(d => d.key);
+    const colorScale = scaleOrdinal({
+      domain: keys,
+      range: keys.map(key => getColorFromScheme(key, colorScheme)),
+    });
+
+    return (
+      <div className={`histogram-chart ${className}`}>
+        <div className="legend-container">
+          <LegendOrdinal
+            scale={colorScale}
+            direction="row"
+            shape="rect"
 
 Review comment:
   Hah. nice. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to