An open API service indexing awesome lists of open source software.

https://github.com/cannercms/vega-canner-components

Canner components for vega
https://github.com/cannercms/vega-canner-components

Last synced: about 2 months ago
JSON representation

Canner components for vega

Awesome Lists containing this project

README

          

# vega-canner-components [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/) [![Storybook](https://github.com/storybooks/press/blob/master/badges/storybook.svg)](https://canner.github.io/victory-canner-components/)

This repository provide chart components for developers to assemble CMS interface using [Canner CMS](https://www.canner.io/).

## Usage in [Canner](https://www.canner.io)

You have to use `` tag to use charts in Canner. [Learn more](https://www.canner.io/docs/schema-page-tags#lt-component-gt)

```jsx

```

**Chart example**

```jsx

```

## Demo

https://canner.github.io/vega-canner-components/?selectedKind=Basic%20Charts&selectedStory=Line%20Chart&full=0&addons=1&stories=1&panelRight=0

## Common Props

All charts support common props as below

- `keyName`: A unique key.
- `ui`: Chart type. `line`, `bar`, `pie` or `scatter`
- `transformData`: Get the value from fetched data, this could allow you to transform your data.
- `spec`: Overwrite the default `specs` in charts. Learn more from [Vega Specification](https://vega.github.io/vega/docs/specification/).
- `graphql`: The graphql string to fetch the data
- `uiParams`: For more detailed UI settings

Other than common props, every charts have additional settings for each chart, and is listed in each section below.

## Line chart [![npm-image](https://badge.fury.io/js/%40canner%2Fvega-chart-line.svg)](https://www.npmjs.com/package/@canner/vega-chart-line)

```
npm i --save @canner/vega-chart-line
```

**_uiParams:_**


Name
Types
Description


interpolate
string // default linear
"basis" | "cardinal" | "catmull-rom" | "linear" | "monotone" | "natural" | "step" | "step-after" | "step-before"


x

{

field: string,
scale?: string, // default linear
title?: string
}

scale


y
{

field: string,
scale?: string, // default linear
title?: string
}

scale


width
number | string // default 100%
number or percent string


height
number | string // default 100%
number or percent string


fill
string // default #1890ff
color

## Bar chart [![npm-image](https://badge.fury.io/js/%40canner%2Fvega-chart-bar.svg)](https://www.npmjs.com/package/@canner/vega-chart-bar)

```
npm i --save @canner/vega-chart-bar
```

**_uiParams:_**


Name
Types
Description


x

{

field: string,
scale?: string, // default linear
title?: string
}

scale


y
{

field: string,
scale?: string, // default linear
title?: string
}

scale


width
number | string // default 100%
number or percent string


height
number | string // default 100%
number or percent string


fill
string // default #1890ff
color

## Pie chart [![npm-image](https://badge.fury.io/js/%40canner%2Fvega-chart-pie.svg)](https://www.npmjs.com/package/@canner/vega-chart-pie)

```
npm i --save @canner/vega-chart-pie
```

**_uiParams:_**


Name
Types
Description


field
string



width
number | string // default 100%
number or percent string


height
number | string // default 100%
number or percent string


color

{

range?: string, // default category20
field?: string // default id
}

range


sort
boolean // default false
optional

## Scatter chart [![npm-image](https://badge.fury.io/js/%40canner%2Fvega-chart-scatter.svg)](https://www.npmjs.com/package/@canner/vega-chart-scatter)

```
npm i --save @canner/vega-chart-scatter
```

**_uiParams:_**


Name
Types
Description


x

{

field: string,
scale?: string, // default linear
title?: string
}

scale


y
{

field: string,
scale?: string, // default linear
title?: string
}

scale


width
number | string // default 100%
number or percent string


height
number | string // default 100%
number or percent string


text
{
field: string
}

The text of field will be shown once the hover event is fired


fill
string // default #1890ff
color

## Develop

```
# install lerna in npm
$ npm i -g lerna

$ lerna bootstrap
$ npm run build
# or watch for rebuilding
$ npm run build:watch

# run demo
$ npm run storybook
```

## Test

```
$ lerna run test
```

## Deploy

```
$ npm run deploy-storybook
```