2.2.53 • Published 1 year ago

@steedos-ui/builder-viz-lib v2.2.53

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
1 year ago

@redash/viz

Version

@redash/viz is a library containing the visualizations used by Redash.

Installation

Required libraries:

  • react (>=16.8.0)
  • react-dom (>=16.8.0)
  • antd (>=4.0.0)

Using npm:

npm install @redash/viz

Using yarn:

yarn add @redash/viz

Usage

Basic Usage

You can check our live example or follow the code below:

import React, { useState } from "react";
import { Renderer, Editor } from "@redash/viz";

const exampleData = {
  columns: [
    { type: null, name: "Country" },
    { type: null, name: "Amount" },
  ],
  rows: [
    { Amount: 37.620000000000005, Country: "Argentina" },
    { Amount: 37.620000000000005, Country: "Australia" },
    { Amount: 42.62, Country: "Austria" },
    { Amount: 37.62, Country: "Belgium" },
    { Amount: 190.09999999999997, Country: "Brazil" },
    { Amount: 303.9599999999999, Country: "Canada" },
    { Amount: 46.62, Country: "Chile" },
    { Amount: 90.24000000000001, Country: "Czech Republic" },
    { Amount: 37.620000000000005, Country: "Denmark" },
    { Amount: 41.620000000000005, Country: "Finland" },
    { Amount: 195.09999999999994, Country: "France" },
  ],
};

function Example() {
  const [options, setOptions] = useState({ countRows: true });

  return (
    <div>
      <Editor
        type="COUNTER"
        visualizationName="Example Visualization"
        options={options}
        data={exampleData}
        onChange={setOptions}
      />
      <Renderer type="COUNTER" visualizationName="Example Visualization" options={options} data={exampleData} />
    </div>
  );
}

Available Types

  • Chart: CHART
  • Cohort: COHORT
  • Counter: COUNTER
  • Details View: DETAILS
  • Funnel: FUNNEL
  • Map (Choropleth): CHOROPLETH
  • Map (Markers): MAP
  • Pivot Table: PIVOT
  • Sankey: SANKEY
  • Sunburst Sequence: SUNBURST_SEQUENCE
  • Table: TABLE
  • Word Cloud: WORD_CLOUD

Column Types

Types used for the columns property in the data object. Currently used to determine the default column view for the Table Visualization. This field is not mandatory and can receive a null value.

Example:

const data = {
  columns: [
    { type: "string", name: "Country" },
    { type: "float", name: "Amount" },
  ],
  rows: [],
};

Available types:

  • integer
  • float
  • boolean
  • string
  • datetime
  • date

Customizable Settings

OptionDescriptionTypeDefault
dateFormatDate Formatstring"DD/MM/YYYY"
dateTimeFormatDateTime Formatstring"DD/MM/YYYY HH:mm"
integerFormatInteger Formatstring"0,0"
floatFormatFloat Formatstring"0,0.00"
booleanValuesBoolean namesArray [string, string] (correspond to false and true values)["false", "true"]
tableCellMaxJSONSizeMax json size that will be parsed and rendered in a Table Cellinteger50000
allowCustomJSVisualizationWhether to allow the Custom chart typebooleanfalse
hidePlotlyModeBarWhether to hide the Plotly Mode Bar on chartsbooleanfalse
choroplethAvailableMapsConfigure the JSONs used for Choropleth maps (Note: Choropleth won't work without this setting)Object (see example below){}
HelpTriggerComponentComponent used to render helper links on the EditorReact component with title and href propsRenders a tooltip with a link

Example:

import React from "react";
import { Renderer, Editor, updateVisualizationsSettings } from "@redash/viz";

import countriesDataUrl from "@redash/viz/lib/visualizations/choropleth/maps/countries.geo.json";
import subdivJapanDataUrl from "@redash/viz/lib/visualizations/choropleth/maps/japan.prefectures.geo.json";

function wrapComponentWithSettings(WrappedComponent) {
  return function VisualizationComponent(props) {
    updateVisualizationsSettings({
      choroplethAvailableMaps: {
        countries: {
          name: "Countries",
          url: countriesDataUrl,
        },
        subdiv_japan: {
          name: "Japan/Prefectures",
          url: subdivJapanDataUrl,
        },
      },
      dateFormat: "YYYY/MM/DD",
      booleanValues: ["False", "True"],
      hidePlotlyModeBar: true,
    });

    return <WrappedComponent {...props} />;
  };
}

export const ConfiguredRenderer = wrapComponentWithSettings(Renderer);
export const ConfiguredEditor = wrapComponentWithSettings(Editor);

Specific File Imports

There is a transpiled only build aimed for specific file imports.

Note: Currently requires Less.

Usage:

import React from "react";
import JsonViewInteractive from "@redash/viz/lib/components/json-view-interactive/JsonViewInteractive";

const example = { list: ["value1", "value2", "value3"], obj: { prop: "value" } };

export default function App() {
  return <JsonViewInteractive value={example} />;
}

License

BSD-2-Clause.

2.2.53

1 year ago

2.2.51

1 year ago

2.2.52

1 year ago

2.2.50

1 year ago

2.2.48

2 years ago

2.2.49

1 year ago

2.2.46

2 years ago

2.2.47

2 years ago

2.2.44

2 years ago

2.2.45

2 years ago

2.2.43

2 years ago

2.2.28

2 years ago

2.2.29

2 years ago

2.2.26

2 years ago

2.2.27

2 years ago

2.2.24

2 years ago

2.2.22

2 years ago

2.2.23

2 years ago

1.0.33

2 years ago

2.2.21

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

2.2.39

2 years ago

2.2.37

2 years ago

2.2.38

2 years ago

2.2.35

2 years ago

2.2.36

2 years ago

2.2.33

2 years ago

2.2.34

2 years ago

2.2.31

2 years ago

2.2.32

2 years ago

2.2.30

2 years ago

2.2.42

2 years ago

2.2.40

2 years ago

2.2.41

2 years ago

2.2.17

2 years ago

2.2.18

2 years ago

2.2.15

2 years ago

2.2.3

2 years ago

2.2.16

2 years ago

2.2.2

2 years ago

2.2.13

2 years ago

2.2.5

2 years ago

2.2.14

2 years ago

2.2.4

2 years ago

2.2.11

2 years ago

2.2.7

2 years ago

2.2.12

2 years ago

2.2.6

2 years ago

2.2.10

2 years ago

2.2.19

2 years ago

2.2.20

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

2.2.9

2 years ago

2.2.8

2 years ago

1.1.29

2 years ago

1.1.28

2 years ago

2.2.1

2 years ago

1.1.30

2 years ago

1.1.34

2 years ago

1.1.33

2 years ago

1.1.32

2 years ago

1.1.31

2 years ago

1.1.38

2 years ago

1.1.37

2 years ago

1.1.36

2 years ago

1.1.35

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.1.39

2 years ago

1.0.27

2 years ago

1.1.41

2 years ago

1.1.40

2 years ago

1.1.45

2 years ago

1.1.44

2 years ago

1.1.43

2 years ago

1.1.49

2 years ago

1.1.48

2 years ago

1.1.47

2 years ago

1.1.46

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.1.27

2 years ago

1.1.26

2 years ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.6

2 years ago

1.1.2

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.16

2 years ago

1.1.13

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.9

2 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago