Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

Index

Functions

formatChange

  • formatChange(v1: number, v2: number, format: string): string
  • Parameters

    • v1: number
    • v2: number
    • format: string

    Returns string

formatNumber

  • formatNumber(value: number, format: string): string
  • Parameters

    • value: number
    • format: string

    Returns string

formatTime

  • formatTime(value: number): string
  • Parameters

    • value: number

    Returns string

formatTimeChange

  • formatTimeChange(v1: number, v2: number): string
  • Parameters

    • v1: number
    • v2: number

    Returns string

formatValue

  • formatValue(value: number): string
  • Parameters

    • value: number

    Returns string

formatValueChange

  • formatValueChange(v1: number, v2: number): string
  • Parameters

    • v1: number
    • v2: number

    Returns string

handleZoom

  • Called when the user uses the scroll wheel (or scroll gesture) to zoom in or out. Zooms in/out at the location of the mouse when the scroll wheel or gesture was applied.

    Parameters

    • transform: ZoomTransform

      The d3 zoom transformation information

    • x: number

      The x-position of the mouse when the scroll wheel or gesture is used

    • plotDimensions: Dimensions

      The current dimensions of the plot

    • containerWidth: number

      The container width

    • margin: Margin

      The plot margins

    • xAxis: ContinuousNumericAxis

      The linear x-axis

    • timeRange: ContinuousAxisRange

      The time-range of the current x-axis

    Returns Zoom | undefined

    The zoom factor and updated time-range

Const minMaxOf

  • minMaxOf<T>(accessor: (v: T) => number): (data: T[][], currentMinMax: [number, number]) => [number, number]
  • Calculates the (min, max) of all the values (from the accessor) in the data matrix, clamped by the global (currentMin, currentMax).

    Curried function that accepts an accessor used to grab the value from the data point, and array of (x, y) values (each (x, y) value is represented as [number, number] tuple), and a global, current min and max values. The global, current min and max clamp the calculated min and max values.

    example

    // function that calculates the min-max of the y-values generated by calling the minMaxOf and handing it the // accessor function that grabs the y-value from the datum const minMaxTimeSeriesY: (data: Array, currentMinMax: [number, number]) => [number, number] = minMaxOf((datum: [number, number]): number => datum[1])

    Type parameters

    • T

    Parameters

    • accessor: (v: T) => number

      Access function that accepts a datum and returns the value which to use in the min-max calc

        • (v: T): number
        • Parameters

          • v: T

          Returns number

    Returns (data: T[][], currentMinMax: [number, number]) => [number, number]

    A function that accepts data (represented as a matrix of (x, y) pairs, where each row is a data series), a global currentMin and currentMax, which clamp the calculated results. The function return a tuple holding the min as the first value and the max as the second value.

      • (data: T[][], currentMinMax: [number, number]): [number, number]
      • Parameters

        • data: T[][]
        • currentMinMax: [number, number]

        Returns [number, number]

Const minMaxYFor

  • minMaxYFor(data: [number, number][][], currentMinMax: [number, number]): [number, number]
  • Sets up the min-max function to extract the y-value of the time-series.

    Defines a function that accepts an array of time-series (matrixish) and returns the min and max y-value for all the values in all the series.

    see

    minMaxOf

    Parameters

    • data: [number, number][][]
    • currentMinMax: [number, number]

    Returns [number, number]

Const mouseInPlotAreaFor

  • mouseInPlotAreaFor(x: number, y: number, margin: Margin, dimensions: Dimensions): boolean
  • Calculates whether the mouse is in the plot-area

    Parameters

    • x: number

      The x-coordinate of the mouse's position

    • y: number

      The y-coordinate of the mouse's position

    • margin: Margin

      The plot margins

    • dimensions: Dimensions

      The the overall dimensions (plot dimensions plus margin)

    Returns boolean

    true if the mouse is in the plot area; false if the mouse is not in the plot area

Const noop

  • noop(): void
  • No operation function for use when a default function is needed

    Returns void

Const textWidthOf

  • textWidthOf(elem: Selection<SVGTextElement, any, HTMLElement, any>): number
  • Calculates the width of an SVG text element, based on its bounding box

    Parameters

    • elem: Selection<SVGTextElement, any, HTMLElement, any>

      The SVG text element

    Returns number

    The width in pixels, or 0 if SVG text element has not children

Generated using TypeDoc