Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ChartComparison): Chart Comparison Group #6

Open
devfreddy opened this issue Nov 25, 2019 · 1 comment
Open

feat(ChartComparison): Chart Comparison Group #6

devfreddy opened this issue Nov 25, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@devfreddy
Copy link
Contributor

devfreddy commented Nov 25, 2019

This is a series of Charts that are adjusting their output based on a common input. Think of this like the ChartGroup component but with an input.

@tangollama tangollama added the enhancement New feature or request label Dec 4, 2019
@devfreddy devfreddy changed the title Chart Comparison Group feat(ChartComparison): Chart Comparison Group Jan 27, 2020
@devfreddy
Copy link
Contributor Author

First pass at an implementation for this:

Component

import React from 'react';
import PropTypes from 'prop-types';

import { Grid, GridItem } from 'nr1';

/*
 * Example Usage:
 * 
 * <ChartComparison
 *   chart={ScatterChart}
 *   compareOver="hour"
 *   timeRange={{ begin_time: 1580156528000, end_time: 1580156528000, duration: 0 }}
 *   accountId={1}
 *   query={SELECT count(*) FROM `Synthetics` TIMESERIES AUTO FACET jobType}
 * />
 */

export default class ChartComparison extends React.Component {

  static propTypes = {

    /*
     * An NR1 (or other) Chart component that accepts props "accountId" and "query"
     */
    chart: PropTypes.Component,

    /*
     * NRQL compatible timeRange interval:
     * 'minute'
     * 'hour'
     * 'day'
     * 'week'
     * 'month'
     * 'year' ???
     */
    compareOver: PropTypes.string,

    /*
     * TimeRange
     */
    timeRange: PropTypes.shapeOf({
      begin_time: PropTypes.number,
      end_time: PropTypes.number,
      duration: PropTypes.number
    }),


    /*
     * An NR1 accountId to be used with the Chart component
     */
    accountId: PropTypes.string,

    /*
     * The NRQL query you want us to manage the timeRange on
     * Exclude the SINCE clause
     * 
     * TO DO - Strip any SINCE clause out of this for the user
     */
    query: PropTypes.string
  }

  constructor(props) {
    super(props);
  }

  render () {
    const { chart, compareOver, accountId, query } = this.props;
    
    // TO DO:

    // const charts = [];
    
    // Generate array of charts needed
      // Calculate number of charts
      // (end_time - begin_time) / (compareOver converted to milliseconds)

      // range(0...numberOfCharts).map
      // const nrqlWithTimeRange = baseNrql + timeRangeToNrql(timeRange with begin_time and end_time to match first comparison chart)

    
    return (
      <div class="my-cool-wrapper-class">
        <Grid>
          {/* For each item in above array of charts */}
            <GridItem>
              {<chart accountId={accountId} query={query}></chart>}
            </GridItem>
        </Grid>
      </div>
    )
  }
}

Sample Usage

  <ChartComparison
    chart={ScatterChart}
    compareOver="hour"
    timeRange={{ begin_time: 1580156528000, end_time: 1580156528000, duration: 0 }}
    accountId={1}
    query={SELECT count(*) FROM `Synthetics` TIMESERIES AUTO FACET jobType}
  />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants