Coder Social home page Coder Social logo

nr1-component-movingaverage's Introduction

Example Code header

Moving Average Component Demo

What is It?

This demo nerdpack shows how you can use the <MovingAverage> component within your own project.

Screenshot

Setup

Add the component folder MovingAverage to your own project and import it:

import MovingAverage from '../../components/MovingAverage';

You can now use the component either declaratively or imperatively. To run the demo make sure you set the account ID to your account ID.

Declarative example

<NrqlQuery
    accountId={1}
    query="SELECT count(*) from Transaction timeseries"
    >
    {({ data }) => {
        return (
            <MovingAverage data={data}>
                {({ adjustedData }) => {
                    return <LineChart data={adjustedData}/>);
                }}
            </MovingAverage>
        );
    }}
</NrqlQuery>

Imperative example

<NrqlQuery
    accountId={1}
    query="SELECT count(*) from Transaction timeseries"
    >
    {({ data }) => {
        const processedData = MovingAverage.processData({data: data});
        return (
            <LineChart data={processedData}/>
        );
    }}
</NrqlQuery>

Configurable Options

You can specify the following options either as properties or as attributes of an object:

  • data: The data in chart data format (the default from <NrqlQuery>)
  • window: Size of moving average window as a % of the total chart time frame. Default: 5% if omitted.
  • buckets: Size of moving average window in buckets (overrides window if present).
  • suffix: The suffix to add to the time series label. Can be empty string. Default: "(moving average)"
  • excludeOriginal: If present and truthy then the original data series are dropped from the data leaving only the moving average data.

nr1-component-movingaverage's People

Contributors

jsbnr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.