williaster commented on a change in pull request #5775: [SIP-5] Refactor Time 
Series Table
URL: 
https://github.com/apache/incubator-superset/pull/5775#discussion_r214225713
 
 

 ##########
 File path: superset/assets/src/visualizations/TimeTable/TimeTable.jsx
 ##########
 @@ -0,0 +1,327 @@
+import ReactDOM from 'react-dom';
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Table, Thead, Th, Tr, Td } from 'reactable';
+import d3 from 'd3';
+import Mustache from 'mustache';
+
+import MetricOption from '../../components/MetricOption';
+import { formatDateThunk } from '../../modules/dates';
+import { d3format } from '../../modules/utils';
+import InfoTooltipWithTrigger from '../../components/InfoTooltipWithTrigger';
+import FormattedNumber from './FormattedNumber';
+import SparklineCell from './SparklineCell';
+import './TimeTable.css';
+
+const ACCESSIBLE_COLOR_BOUNDS = ['#ca0020', '#0571b0'];
+
+function colorFromBounds(value, bounds, colorBounds = ACCESSIBLE_COLOR_BOUNDS) 
{
+  if (bounds) {
+    const [min, max] = bounds;
+    const [minColor, maxColor] = colorBounds;
+    if (min !== null && max !== null) {
+      const colorScale = d3.scale.linear()
+        .domain([min, (max + min) / 2, max])
+        .range([minColor, 'grey', maxColor]);
+      return colorScale(value);
+    } else if (min !== null) {
+      return value >= min ? maxColor : minColor;
+    } else if (max !== null) {
+      return value < max ? maxColor : minColor;
+    }
+  }
+  return null;
+}
+
+const propTypes = {
+  className: PropTypes.string,
+  height: PropTypes.number,
+  // Example
+  // {'2018-04-14 00:00:00': { 'SUM(metric_value)': 80031779.40047 }}
+  data: PropTypes.objectOf(PropTypes.objectOf(PropTypes.number)).isRequired,
+  columnConfigs: PropTypes.arrayOf(PropTypes.shape({
+    colType: PropTypes.string,
+    comparisonType: PropTypes.string,
+    d3format: PropTypes.string,
+    key: PropTypes.string,
+    label: PropTypes.string,
+    timeLag: PropTypes.number,
+  })).isRequired,
+  rows: PropTypes.arrayOf(PropTypes.oneOfType([
+    PropTypes.shape({
+      label: PropTypes.string,
+    }),
+    PropTypes.shape({
+      metric_name: PropTypes.string,
+    }),
+  ])).isRequired,
+  rowType: PropTypes.oneOf(['column', 'metric']).isRequired,
+  url: PropTypes.string,
+};
+const defaultProps = {
+  className: '',
+  height: undefined,
+  url: '',
+};
+
+class TimeTable extends React.PureComponent {
+  renderLeftCell(row) {
+    const { rowType, url } = this.props;
+    // const context = { ...fd, metric };
 
 Review comment:
   remove?

----------------------------------------------------------------
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