1.2.3 • Published 4 years ago

@datadog/vis-core v1.2.3

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

@datadog/vis-core

This package offers:

  • The core DataFrame tabular data structure used by other @datadog/vis-* libraries. Features type inference.
  • Datadog styles (color palettes, colors).
  • No external dependencies.

It is under active development, and subject to breaking changes.

Install

yarn add @datadog/vis-core

Basic Usage

import { DataFrame } from "@datadog/vis-core";

const now = Date.now();
const oneHourAgo = now - 3600 * 1000;
const twoHoursAgo = now - 7200 * 1000;

// Scalar columns can contain numbers or nulls.
const columnConfig = [
  {
    id: "timestamp",
    kind: "scalar",
    values: [now, oneHourAgo, twoHoursAgo, now, oneHourAgo, twoHoursAgo],
    meta: {},
  },
  {
    id: "value",
    kind: "scalar",
    values: [0, 60, 80, 10, 20, 30],
    meta: {},
  },
  {
    id: "key",
    kind: "string",
    values: ["Alpha", "Alpha", "Alpha", "Beta", "Beta", "Beta"],
    meta: {},
  },
];

const dataFrame = DataFrame.fromColumns(columnConfig);

To read values back out:

const rows = dataFrame.getRows();
const values = dataFrame.getColumnValues("timestamp");

Advanced Usage (Typescript)

The DataFrame typescript generic optionally accepts an array or tuple type of Columns.

Using these types is not required. However, using them may improve the quality of the type-hinting provided by your editor.

  • Column Kinds
    • Primitives
      • Boolean: true / false
      • String
      • Float32: Typed arrays
    • Compound
      • Scalar: number | null
      • Object: Any javascript object

Each Column type also accepts a generic for ColumnMetadata as a second argument.

For example:

import type {
  DataFrame,
  StringColumn,
  ScalarColumn,
  ObjectColumn,
} from "@datadog/vis-core";

type PermittedColumns =
  | StringColumn<string, { source: "Wikipedia" }>
  | ScalarColumn<string, any> // no metadata
  | ObjectColumn<
      string,
      { type: "unknown"; source: "external" },
      { min: number }
    >;

interface TableMeta {
  source: "public";
  [key: string]: unknown;
}

type CustomDataFrame = DataFrame<PermittedColumns[], TableMeta>;

const columnConfig = [
  {
    id: "stats",
    kind: "object" as const,
    values: [{ min: 0 }, { min: 0 }, { min: 0 }, { min: 0 }],
    meta: { type: "unknown" as const, source: "external" as const },
  },
  {
    id: "value",
    kind: "scalar" as const,
    values: [0, 80, 10, 30],
    meta: {},
  },
  {
    id: "key",
    kind: "string" as const,
    values: ["Alpha", "Alpha", "Beta", "Beta"],
    meta: { source: "Wikipedia" as const },
  },
];

const dataFrame: CustomDataFrame = DataFrame.fromColumns(columnConfig, {
  source: "public",
});

The full documentation page is under review.

1.2.4-next.0

4 years ago

1.2.3-next.13

4 years ago

1.2.3

4 years ago

1.2.3-next.10

4 years ago

1.2.3-next.11

4 years ago

1.2.3-next.12

4 years ago

1.2.3-next.9

4 years ago

1.2.3-next.8

4 years ago

1.2.3-next.6

4 years ago

1.2.3-next.7

4 years ago

1.2.3-next.5

4 years ago

1.2.3-next.4

4 years ago

1.2.3-next.3

4 years ago

1.2.3-next.2

4 years ago

1.2.3-next.1

4 years ago

1.2.3-next.0

4 years ago

1.2.2

4 years ago

1.2.2-next.2

4 years ago

1.2.2-next.5

4 years ago

1.2.2-next.4

4 years ago

1.2.2-next.3

4 years ago

1.2.2-next.1

4 years ago

1.2.1

4 years ago

1.2.1-next.2

4 years ago

1.2.1-next.3

4 years ago

1.2.2-next.0

4 years ago

1.2.1-next.1

4 years ago

1.2.0

4 years ago

1.2.1-next.0

4 years ago

1.2.0-next.6

4 years ago

1.2.0-next.7

4 years ago

2.0.0-next.2

4 years ago

2.0.0-next.1

4 years ago

1.2.0-next.5

4 years ago

1.2.0-next.2

4 years ago

1.2.0-next.1

4 years ago

1.2.0-next.4

4 years ago

1.2.0-next.3

4 years ago

2.0.0-next.0

4 years ago

1.2.0-next.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-alpha.1

4 years ago

0.1.4-5

4 years ago

0.1.4-4

4 years ago

0.1.4-3

4 years ago

0.1.4-1

4 years ago

0.1.4-0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago