forked from antvis/AVA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
8,176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
src | ||
tsconfig.json | ||
webpack.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,283 @@ | ||
# API Reference | ||
|
||
*Functions* | ||
|
||
---- | ||
|
||
## `CKBJson([lang='en-US'], [completed=false])` | ||
|
||
> Creates a **Chart Knowledge Base** in `JSON` format. | ||
### Arguments | ||
|
||
- **lang** - Language of the CKB content. | ||
- `optional` | ||
- `type`: *Language* extends string | ||
- `default`: 'en-US' | ||
- `options`: | ||
- 'en-US' | ||
- 'zh-CN' | ||
|
||
- **completed** - To include incompleted charts or not. | ||
- `optional` | ||
- `type`: *boolean* | ||
- `default`: false | ||
|
||
### Returns | ||
|
||
*ChartKnowledgeBaseJSON* extends object | ||
|
||
```json | ||
{ | ||
single_line_chart: { | ||
id: 'single_line_chart', | ||
name: 'Single Line Chart', | ||
alias: ['Line', 'Line Chart', 'Basic Line Chart'], | ||
family: ['LineCharts'], | ||
def: | ||
'A single line chart is a chart that uses one line with segments to show changes in data in a ordinal dimension.', | ||
purpose: ['Trend'], | ||
coord: ['Cartesian2D'], | ||
category: ['Statistic'], | ||
shape: ['Lines'], | ||
dataPres: [ | ||
{ minQty: 1, maxQty: 1, fieldConditions: ['Time', 'Ordinal'] }, | ||
{ minQty: 1, maxQty: 1, fieldConditions: ['Interval'] }, | ||
], | ||
channel: ['Position', 'Direction'], | ||
}, | ||
|
||
... | ||
} | ||
``` | ||
|
||
### Examples | ||
|
||
```js | ||
import { CKBJson } from '@antv/knowledge'; | ||
|
||
|
||
// Knowledage base for all charts in English. | ||
const knowledgeBase = CKBJson(); | ||
|
||
// Knowledage base for all charts in Chinese. | ||
const zhKB = CKBJson('zh-CN'); | ||
|
||
// Knowledage base for completed charts in English. | ||
const completedKB = CKBJson(undefined, true); | ||
|
||
// Knowledage base for completed charts in Chinese. | ||
const zhCompletedKB = CKBJson('zh-CN', true); | ||
``` | ||
|
||
## `addChart(chartKnowledge, trans)` | ||
|
||
> Adds a custom chart to the base. | ||
### Arguments | ||
|
||
- **chartKnowledge** - Chart Knowledge object for the custom chart. | ||
- `required` | ||
- `type`: *ChartKnowledge* extends object | ||
|
||
- **trans** - To include incompleted charts or not. | ||
- `required` | ||
- `type`: *Record<Language, TransKnowledgeProps>* | ||
|
||
### Returns | ||
|
||
*void* | ||
|
||
### Examples | ||
|
||
```ts | ||
const liquid_diagram = { | ||
id: 'liquid_diagram', | ||
name: 'Liquid Diagram', | ||
alias: ['Liquid Chart'], | ||
family: ['Others'], | ||
def: 'A liquid diagram is a infographic for presenting progress.', | ||
purpose: ['Comparison'], | ||
coord: [], | ||
category: ['Diagram'], | ||
shape: ['Lines'], | ||
dataPres: [{ minQty: 1, maxQty: 1, fieldConditions: ['Interval'] }], | ||
channel: ['Position'], | ||
}; | ||
|
||
const liquid_diagram_trans = { | ||
name: '水波图', | ||
alias: ['水波球', '进度球'], | ||
def: '水波图是一种用球形容器和其中的水平线位置来表示进度的示意图。', | ||
}; | ||
|
||
addChart( | ||
liquid_diagram as ChartKnowledge, | ||
{ 'zh-CN': liquid_diagram_trans } as Record<Language, TransKnowledgeProps> | ||
); | ||
``` | ||
|
||
## `CKBOptions([lang='en-US'])` | ||
|
||
> Returns all possible options for each property of Chart Knowledge. | ||
### Arguments | ||
|
||
- **lang** - Language of property options. | ||
- `optional` | ||
- `type`: *Language* extends string | ||
- `default`: 'en-US' | ||
- `options`: | ||
- 'en-US' | ||
- 'zh-CN' | ||
|
||
### Returns | ||
|
||
*object* - contains the following keys: | ||
|
||
#### `CKBOptions().family` | ||
|
||
> Types of chart similarity or so called *Chart Family*. | ||
- LineCharts | ||
- ColumnCharts | ||
- BarCharts | ||
- PieCharts | ||
- AreaCharts | ||
- ScatterCharts | ||
- FunnelCharts | ||
- HeatmapCharts | ||
- RadarCharts | ||
- Others | ||
|
||
#### `CKBOptions().category` | ||
|
||
> Types of higher level of chart taxonomy or so called *Graphic Category*. | ||
- Statistic | ||
- Diagram | ||
- Graph | ||
- Map | ||
|
||
#### `CKBOptions().purpose` | ||
|
||
> Types of purpose for which the visualization is used. | ||
- Comparison | ||
- Trend | ||
- Distribution | ||
- Rank | ||
- Proportion | ||
- Composition | ||
|
||
#### `CKBOptions().coord` | ||
|
||
> Types of *Coordinate Systems*. | ||
- NumberLine | ||
- Cartesian2D | ||
- SymmetricCartesian | ||
- Cartesian3D | ||
- Polar | ||
- NodeLink | ||
- Radar | ||
|
||
#### `CKBOptions().shape` | ||
|
||
> Shapes of the skeleton of visualization. | ||
- Lines | ||
- Bars | ||
- Round | ||
- Square | ||
- Area | ||
- Scatter | ||
- Symmetric | ||
|
||
#### `CKBOptions().channel` | ||
|
||
> *Visual Channels*. | ||
- Position | ||
- Length | ||
- Color | ||
- Area | ||
- Angle | ||
- ArcLength | ||
- Direction | ||
- Size | ||
|
||
#### `CKBOptions().lom` | ||
|
||
> *Level of Measurement*. | ||
- Nominal | ||
- Ordinal | ||
- Interval | ||
- Discrete | ||
- Continuous | ||
- Time | ||
|
||
### Examples | ||
|
||
```js | ||
import { CKBOptions } from '@antv/knowledge'; | ||
|
||
const options1 = CKBOptions(); | ||
const options2 = CKBOptions('zh-CN'); | ||
|
||
const allCategories = options1.category; | ||
// ['Statistic', 'Diagram', 'Graph', 'Map'] | ||
``` | ||
|
||
*Types & Interfaces* | ||
|
||
---- | ||
|
||
```js | ||
import { ChartKnowledge, DataPrerequisite } from '@antv/knowledge'; | ||
``` | ||
|
||
## `ChartKnowledge` | ||
|
||
```ts | ||
interface ChartKnowledge { | ||
id: ChartID; | ||
name: string; | ||
alias: string[]; | ||
family?: Family[]; | ||
def?: string; | ||
purpose?: Purpose[]; | ||
coord?: CoordinateSystem[]; | ||
category?: GraphicCategory[]; | ||
shape?: Shape[]; | ||
dataPres?: DataPrerequisite[]; | ||
channel?: Channel[]; | ||
} | ||
``` | ||
|
||
## `DataPrerequisite` | ||
|
||
```ts | ||
interface DataPrerequisite { | ||
minQty: number; | ||
maxQty: number | '*'; | ||
fieldConditions: LevelOfMeasurement[]; | ||
} | ||
``` | ||
|
||
## `Language` | ||
|
||
```ts | ||
type Language = 'en-US' | 'zh-CN'; | ||
``` | ||
|
||
## `TransKnowledgeProps` | ||
|
||
```ts | ||
interface TransKnowledgeProps { | ||
name: string; | ||
alias: string[]; | ||
def: string; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# CHANGELOG | ||
|
||
## 0.1.3 (2020-02-14) | ||
|
||
- AVA/CKB first draft released. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 AntV team | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do { so, subject } to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.