# @redash/viz
![Version](https://img.shields.io/npm/v/@redash/viz)
`@redash/viz` is a library containing the visualizations used by [Redash](https://redash.io).
## Installation
Required libraries:
- react (`>=16.8.0`)
- react-dom (`>=16.8.0`)
- antd (`>=4.0.0`)
Using npm:
```bash
npm install @redash/viz
```
Using yarn:
```bash
yarn add @redash/viz
```
## Usage
### Basic Usage
You can check [our live example](https://codesandbox.io/s/redashviz-v9odv) or follow the code below:
```jsx
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:
```js
const data = {
columns: [
{ type: "string", name: "Country" },
{ type: "float", name: "Amount" },
],
rows: [],
};
```
Available types:
- `integer`
- `float`
- `boolean`
- `string`
- `datetime`
- `date`
### Customizable Settings
| Option | Description | Type | Default |
| -------------------------- | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| dateFormat | Date Format | `string` | `"DD/MM/YYYY"` |
| dateTimeFormat | DateTime Format | `string` | `"DD/MM/YYYY HH:mm"` |
| integerFormat | Integer Format | `string` | `"0,0"` |
| floatFormat | Float Format | `string` | `"0,0.00"` |
| booleanValues | Boolean names | `Array [string, string]` (correspond to false and true values) | `["false", "true"]` |
| tableCellMaxJSONSize | Max json size that will be parsed and rendered in a Table Cell | `integer` | `50000` |
| allowCustomJSVisualization | Whether to allow the `Custom` chart type | `boolean` | `false` |
| hidePlotlyModeBar | Whether to hide the Plotly Mode Bar on charts | `boolean` | `false` |
| choroplethAvailableMaps | Configure the JSONs used for Choropleth maps (Note: Choropleth won't work without this setting) | `Object` (see example below) | `{}` |
| HelpTriggerComponent | Component used to render helper links on the Editor | React component with `title` and `href` props | Renders a [tooltip with a link](https://github.com/getredash/redash/blob/fc246aafc445bdfc3ad2b82560141ef51f8753a9/viz-lib/src/visualizations/visualizationsSettings.js#L6-L33) |
Example:
```jsx
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 Fi
没有合适的资源?快使用搜索试试~ 我知道了~
Redash: 连接到任何数据源,轻松可视化和分享你的数据-python源码
共1213个文件
py:250个
js:182个
jsx:181个
需积分: 43 0 下载量 130 浏览量
2021-06-18
18:41:16
上传
评论
收藏 3.72MB ZIP 举报
温馨提示
Redash: 连接到任何数据源,轻松可视化和分享你的数据 Redash 是我们对以更适合我们的文化和使用模式的方式释放公司内部数据的看法。 在 Redash 之前,我们尝试使用传统的 BI 套件并发现了一组臃肿、技术上有挑战且缓慢的工具/流程。 我们正在寻找一种更像黑客的方式来查看数据,所以我们建立了一个。 Redash 旨在允许快速轻松地访问数十亿条记录,我们使用 Amazon Redshift(“说”PostgreSQL 的“PB 级数据仓库”)处理和收集这些记录。 如今,Redash 支持查询多个数据库,包括:Redshift、Google BigQuery、PostgreSQL、MySQL、Graphite、Presto、Google Spreadsheets、Cloudera Impala、Hive 和自定义脚本。 Redash 由两部分组成: 查询编辑器:考虑使用 JS Fiddle 进行 SQL 查询。 通过共享数据集和生成它的查询,您可以以开放的方式在组织中共享数据。 通过这种方式,每个人不仅可以对结果数据集进行同行评审,还可以对生成它的过程进行同行评审
资源详情
资源评论
资源推荐
收起资源包目录
Redash: 连接到任何数据源,轻松可视化和分享你的数据-python源码 (1213个子文件)
.babelrc 583B
.babelrc 355B
bundle-extensions 4KB
setup.cfg 88B
worker.conf 760B
.coveragerc 109B
redshift-ca-bundle.crt 8KB
login.css 1KB
dashboard-list.css 533B
ScheduleDialog.css 506B
queries-list.css 313B
Dockerfile.cypress 222B
docker-entrypoint 3KB
docker_build 558B
Dockerfile 3KB
.dockerignore 174B
.editorconfig 204B
Roboto-Thin-webfont.eot 21KB
Roboto-Medium-webfont.eot 21KB
Roboto-Regular-webfont.eot 21KB
Roboto-Bold-webfont.eot 20KB
Roboto-Light-webfont.eot 20KB
redash-icons.eot 2KB
.eslintignore 40B
.gitignore 261B
.gitignore 210B
.gitignore 11B
.gitignore 5B
.gitkeep 0B
layout.html 11KB
login.html 2KB
invite.html 2KB
invite.html 2KB
setup.html 2KB
failures.html 2KB
reset.html 2KB
unsupported.html 1KB
verify.html 1KB
index.html 1KB
multi_org.html 1KB
signed_out.html 1KB
reset.html 891B
forgot.html 845B
reset_disabled.html 579B
verify.html 499B
error.html 428B
tail.html 0B
signed_out_tail.html 0B
MANIFEST.in 55B
alembic.ini 778B
pytest.ini 58B
parameter_spec.js 19KB
query-result.js 13KB
query.js 10KB
useDashboard.js 9KB
dashboard.js 9KB
ScheduleDialog.test.js 8KB
widget.js 8KB
webpack.config.js 8KB
widget_spec.js 7KB
DateRangeParameter.js 7KB
useDatabricksSchema.js 7KB
sharing_spec.js 6KB
counter_spec.js 6KB
sankey_sunburst_spec.js 5KB
pivot_spec.js 5KB
ItemsSource.js 5KB
parameter_spec.js 5KB
word_cloud_spec.js 5KB
share_embed_spec.js 5KB
index.js 4KB
utils.js 4KB
textbox_spec.js 4KB
table_spec.js 4KB
dynamicFormHelper.js 4KB
dashboard_spec.js 4KB
useQueryExecute.js 4KB
choropleth_spec.js 4KB
filters_spec.js 4KB
grid_compliant_widgets_spec.js 4KB
chart_spec.js 4KB
cypress.js 4KB
map_spec.js 4KB
view_alert_spec.js 3KB
user.js 3KB
commands.js 3KB
useEditModeHandler.js 3KB
chart.js 3KB
ace.js 3KB
auth.js 3KB
filters_spec.js 3KB
proptypes.js 3KB
Parameter.js 3KB
DateRangeParameter.test.js 3KB
AutoHeightController.js 3KB
funnel_spec.js 3KB
ItemsFetcher.js 3KB
cohort_spec.js 3KB
DateParameter.test.js 3KB
location.js 2KB
共 1213 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
温暖如故
- 粉丝: 22
- 资源: 4642
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0