├── src
├── .eslintrc
├── components
│ ├── decoration5
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration10
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration8
│ │ ├── style.less
│ │ └── index.js
│ ├── digitalFlop
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration1
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration3
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration6
│ │ ├── style.less
│ │ └── index.js
│ ├── conicalColumnChart
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration2
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration7
│ │ ├── style.less
│ │ └── index.js
│ ├── fullScreenContainer
│ │ ├── style.less
│ │ └── index.js
│ ├── charts
│ │ ├── style.less
│ │ └── index.js
│ ├── flylineChartEnhanced
│ │ └── style.less
│ ├── loading
│ │ ├── style.less
│ │ └── index.js
│ ├── flylineChart
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration9
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration11
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration12
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox8
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox9
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox12
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox13
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox2
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox6
│ │ ├── style.less
│ │ └── index.js
│ ├── percentPond
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox11
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox3
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox1
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox7
│ │ ├── style.less
│ │ └── index.js
│ ├── waterLevelPond
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox10
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox5
│ │ ├── style.less
│ │ └── index.js
│ ├── activeRingChart
│ │ ├── style.less
│ │ └── index.js
│ ├── scrollBoard
│ │ ├── style.less
│ │ └── index.js
│ ├── decoration4
│ │ ├── style.less
│ │ └── index.js
│ ├── borderBox4
│ │ ├── style.less
│ │ └── index.js
│ ├── scrollRankingBoard
│ │ ├── style.less
│ │ └── index.js
│ └── capsuleChart
│ │ ├── style.less
│ │ └── index.js
├── test.js
├── use
│ └── autoResize.js
├── index.js
└── util
│ └── index.js
├── icon.png
├── QQGroup.png
├── demoImg
├── manage-desk.jpg
├── electronic-file.jpg
└── construction-data.jpg
├── .vscode
└── settings.json
├── .babelrc
├── .editorconfig
├── .github
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ ├── new_component_request.md
│ └── bug_report.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── .eslintrc
├── LICENSE
├── umdExample.html
├── rollup.config.js
├── package.json
├── README.md
├── README_EN.md
└── CHANGELOG.md
/src/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "jest": true
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataV-Team/DataV-React/HEAD/icon.png
--------------------------------------------------------------------------------
/QQGroup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataV-Team/DataV-React/HEAD/QQGroup.png
--------------------------------------------------------------------------------
/src/components/decoration5/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-5 {
2 | width: 100%;
3 | height: 100%;
4 | }
--------------------------------------------------------------------------------
/demoImg/manage-desk.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataV-Team/DataV-React/HEAD/demoImg/manage-desk.jpg
--------------------------------------------------------------------------------
/demoImg/electronic-file.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataV-Team/DataV-React/HEAD/demoImg/electronic-file.jpg
--------------------------------------------------------------------------------
/demoImg/construction-data.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataV-Team/DataV-React/HEAD/demoImg/construction-data.jpg
--------------------------------------------------------------------------------
/src/components/decoration10/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-10 {
2 | width: 100%;
3 | height: 100%;
4 | display: flex;
5 | }
--------------------------------------------------------------------------------
/src/components/decoration8/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-8 {
2 | display: flex;
3 | width: 100%;
4 | height: 100%;
5 | }
--------------------------------------------------------------------------------
/src/components/digitalFlop/style.less:
--------------------------------------------------------------------------------
1 | .dv-digital-flop {
2 | canvas {
3 | width: 100%;
4 | height: 100%;
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "eslint.run": "onSave",
3 | "editor.codeActionsOnSave": {
4 | "source.fixAll.eslint": true
5 | }
6 | }
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", {
4 | "modules": false
5 | }],
6 | "stage-0",
7 | "react"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/src/components/decoration1/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-1 {
2 | width: 100%;
3 | height: 100%;
4 |
5 | svg {
6 | transform-origin: left top;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/components/decoration3/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-3 {
2 | width: 100%;
3 | height: 100%;
4 |
5 | svg {
6 | transform-origin: left top;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/components/decoration6/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-6 {
2 | width: 100%;
3 | height: 100%;
4 |
5 | svg {
6 | transform-origin: left top;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/components/conicalColumnChart/style.less:
--------------------------------------------------------------------------------
1 | .dv-conical-column-chart {
2 | width: 100%;
3 | height: 100%;
4 |
5 | text {
6 | text-anchor: middle;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/components/decoration2/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-2 {
2 | display: flex;
3 | width: 100%;
4 | height: 100%;
5 | justify-content: center;
6 | align-items: center;
7 | }
--------------------------------------------------------------------------------
/src/components/decoration7/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-7 {
2 | display: flex;
3 | width: 100%;
4 | height: 100%;
5 | justify-content: center;
6 | align-items: center;
7 | }
--------------------------------------------------------------------------------
/src/test.js:
--------------------------------------------------------------------------------
1 | import ExampleComponent from './'
2 |
3 | describe('ExampleComponent', () => {
4 | it('is truthy', () => {
5 | expect(ExampleComponent).toBeTruthy()
6 | })
7 | })
8 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/src/components/fullScreenContainer/style.less:
--------------------------------------------------------------------------------
1 | #dv-full-screen-container {
2 | position: fixed;
3 | top: 0px;
4 | left: 0px;
5 | overflow: hidden;
6 | transform-origin: left top;
7 | z-index: 999;
8 | }
--------------------------------------------------------------------------------
/src/components/charts/style.less:
--------------------------------------------------------------------------------
1 | .dv-charts-container {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .charts-canvas-container {
7 | width: 100%;
8 | height: 100%;
9 | }
10 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: 新特性建议
4 | ---
5 |
6 |
7 |
8 | ## Feature request
9 |
10 | #### 这个特性解决了什么问题?
11 |
12 | #### 这个特性的实现形式?
13 |
14 | #### 是否愿意为此特性提交PR?
15 |
--------------------------------------------------------------------------------
/src/components/flylineChartEnhanced/style.less:
--------------------------------------------------------------------------------
1 | .dv-flyline-chart-enhanced {
2 | display: flex;
3 | flex-direction: column;
4 | background-size: 100% 100%;
5 |
6 | text {
7 | text-anchor: middle;
8 | dominant-baseline: middle;
9 | }
10 | }
--------------------------------------------------------------------------------
/src/components/loading/style.less:
--------------------------------------------------------------------------------
1 | .dv-loading {
2 | width: 100%;
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | justify-content: center;
7 | align-items: center;
8 |
9 | .loading-tip {
10 | font-size: 15px;
11 | }
12 | }
--------------------------------------------------------------------------------
/src/components/flylineChart/style.less:
--------------------------------------------------------------------------------
1 | .dv-flyline-chart {
2 | display: flex;
3 | flex-direction: column;
4 | background-size: 100% 100%;
5 |
6 | polyline {
7 | transition: all 0.3s;
8 | }
9 |
10 | text {
11 | text-anchor: middle;
12 | dominant-baseline: middle;
13 | }
14 | }
--------------------------------------------------------------------------------
/src/components/decoration9/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-9 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | display: flex;
6 | align-items: center;
7 | justify-content: center;
8 |
9 | svg {
10 | position: absolute;
11 | left: 0px;
12 | top: 0px;
13 | transform-origin: left top;
14 | }
15 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/new_component_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Component request
3 | about: 新组件建议
4 | ---
5 |
6 |
7 |
8 |
9 | ## Component request
10 |
11 | #### 新组件的类型?
12 |
13 | * [ ] 边框
14 | * [ ] 装饰
15 | * [ ] 图表
16 | * [ ] 其他
17 |
18 | #### 这个组件的功能描述 (边框及装饰类,请提供样图)?
19 |
20 | #### 是否愿意为此组件提交PR?
21 |
--------------------------------------------------------------------------------
/src/components/decoration11/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-11 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | display: flex;
6 |
7 | .decoration-content {
8 | position: absolute;
9 | top: 0px;
10 | left: 0px;
11 | width: 100%;
12 | height: 100%;
13 | display: flex;
14 | align-items: center;
15 | justify-content: center;
16 | }
17 | }
--------------------------------------------------------------------------------
/src/components/decoration12/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-12 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | display: flex;
6 |
7 | .decoration-content {
8 | position: absolute;
9 | top: 0px;
10 | left: 0px;
11 | width: 100%;
12 | height: 100%;
13 | display: flex;
14 | align-items: center;
15 | justify-content: center;
16 | }
17 | }
--------------------------------------------------------------------------------
/src/components/borderBox8/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-8 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | width: 100%;
9 | height: 100%;
10 | left: 0px;
11 | top: 0px;
12 | }
13 |
14 | .border-box-content {
15 | position: relative;
16 | width: 100%;
17 | height: 100%;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/components/borderBox9/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-9 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | width: 100%;
9 | height: 100%;
10 | left: 0px;
11 | top: 0px;
12 | }
13 |
14 | .border-box-content {
15 | position: relative;
16 | width: 100%;
17 | height: 100%;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/components/borderBox12/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-12 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | width: 100%;
9 | height: 100%;
10 | top: 0px;
11 | left: 0px;
12 | }
13 |
14 | .border-box-content {
15 | position: relative;
16 | width: 100%;
17 | height: 100%;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/components/borderBox13/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-13 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | width: 100%;
9 | height: 100%;
10 | top: 0px;
11 | left: 0px;
12 | }
13 |
14 | .border-box-content {
15 | position: relative;
16 | width: 100%;
17 | height: 100%;
18 | }
19 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # See https://help.github.com/ignore-files/ for more about ignoring files.
3 |
4 | # dependencies
5 | node_modules
6 |
7 | # builds
8 | build
9 | .rpt2_cache
10 | deploy/config.js
11 | lib
12 | es
13 | umd
14 |
15 | # misc
16 | .DS_Store
17 | .env
18 | .env.local
19 | .env.development.local
20 | .env.test.local
21 | .env.production.local
22 |
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 | yarn.lock
27 |
28 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": ["standard", "standard-react"],
4 | "env": {
5 | "es6": true
6 | },
7 | "plugins": ["react"],
8 | "parserOptions": {
9 | "sourceType": "module"
10 | },
11 | "rules": {
12 | // don't force es6 functions to include space before paren
13 | "space-before-function-paren": 0,
14 |
15 | // allow specifying true explicitly for boolean props
16 | "react/jsx-boolean-value": 0
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/components/borderBox2/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-2 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | width: 100%;
9 | height: 100%;
10 | top: 0px;
11 | left: 0px;
12 |
13 | & > polyline {
14 | fill: none;
15 | stroke-width: 1;
16 | }
17 | }
18 |
19 | .border-box-content {
20 | position: relative;
21 | width: 100%;
22 | height: 100%;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/components/borderBox6/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-6 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | top: 0px;
9 | left: 0px;
10 | width: 100%;
11 | height: 100%;
12 |
13 | & > polyline {
14 | fill: none;
15 | stroke-width: 1;
16 | }
17 | }
18 |
19 | .border-box-content {
20 | position: relative;
21 | width: 100%;
22 | height: 100%;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/components/percentPond/style.less:
--------------------------------------------------------------------------------
1 | .dv-percent-pond {
2 | position: relative;
3 | display: flex;
4 | flex-direction: column;
5 |
6 | svg {
7 | position: absolute;
8 | left: 0px;
9 | top: 0px;
10 | width: 100%;
11 | height: 100%;
12 | }
13 |
14 | polyline {
15 | transition: all 0.3s;
16 | }
17 |
18 | text {
19 | font-size: 25px;
20 | font-weight: bold;
21 | text-anchor: middle;
22 | dominant-baseline: middle;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/components/borderBox11/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-11 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | width: 100%;
9 | height: 100%;
10 | top: 0px;
11 | left: 0px;
12 |
13 | & > polyline {
14 | fill: none;
15 | stroke-width: 1;
16 | }
17 | }
18 |
19 | .border-box-content {
20 | position: relative;
21 | width: 100%;
22 | height: 100%;
23 | }
24 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: 提交Bug反馈
4 | ---
5 |
6 |
7 |
8 |
9 |
10 | ## Bug report
11 |
12 | #### 出现Bug的组件?
13 |
14 | #### 组件配置数据?
15 |
16 |
17 | #### 控制台错误输出?
18 |
19 |
20 | #### 期望情况?
21 |
22 | #### 实际情况?
23 |
24 | #### 其他相关信息
25 |
26 | - DataV版本
27 | - 浏览器版本
28 | - 其他
29 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | **该PR的类型是?** (至少选择一个)
4 |
5 | - [ ] Bug修复
6 | - [ ] 新特性
7 | - [ ] 新组件
8 |
9 | **该PR是否向下兼容?** (选择任一)
10 |
11 | - [ ] 是
12 | - [ ] 否
13 |
14 | 如果为否,请描述冲突情况:
15 |
16 | **涉及到的ISSUE:**
17 |
18 | - [ ] 该PR如果涉及到某个ISSUE, 请在PR标题中描述出来 (例如. `fix #xxx[,#xxx]`, "xxx"为ISSUE序号)
19 |
20 | **是否在Chrome浏览器下进行过测试?**
21 |
22 | - [ ] 是
23 | - [ ] 否
24 |
25 | 如果这是一个**新特性**或**新组件**相关的PR,请提供如下信息
26 |
27 | - [ ] 添加该特性或组件的原因
28 | - [ ] 文档应该修改哪些信息
29 | - [ ] 测试相关
30 |
31 | 提交**新特性**或**新组件**前请先发起一个相关的ISSUE请求
32 |
33 | **其他信息:**
34 |
--------------------------------------------------------------------------------
/src/components/borderBox3/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-3 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | width: 100%;
9 | height: 100%;
10 | top: 0px;
11 | left: 0px;
12 |
13 | & > polyline {
14 | fill: none;
15 | }
16 | }
17 |
18 | .dv-bb3-line1 {
19 | stroke-width: 3;
20 | }
21 |
22 | .dv-bb3-line2 {
23 | stroke-width: 1;
24 | }
25 |
26 | .border-box-content {
27 | position: relative;
28 | width: 100%;
29 | height: 100%;
30 | }
31 | }
--------------------------------------------------------------------------------
/src/components/borderBox1/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-1 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .border {
7 | position: absolute;
8 | display: block;
9 | }
10 |
11 | .right-top {
12 | right: 0px;
13 | transform: rotateY(180deg);
14 | }
15 |
16 | .left-bottom {
17 | bottom: 0px;
18 | transform: rotateX(180deg);
19 | }
20 |
21 | .right-bottom {
22 | right: 0px;
23 | bottom: 0px;
24 | transform: rotateX(180deg) rotateY(180deg);
25 | }
26 |
27 | .border-box-content {
28 | position: relative;
29 | width: 100%;
30 | height: 100%;
31 | }
32 | }
--------------------------------------------------------------------------------
/src/components/borderBox7/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-7 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-border-svg-container {
7 | position: absolute;
8 | top: 0px;
9 | left: 0px;
10 | width: 100%;
11 | height: 100%;
12 |
13 | & > polyline {
14 | fill: none;
15 | stroke-linecap: round;
16 | }
17 | }
18 |
19 | .dv-bb7-line-width-2 {
20 | stroke-width: 2;
21 | }
22 |
23 | .dv-bb7-line-width-5 {
24 | stroke-width: 5;
25 | }
26 |
27 | .border-box-content {
28 | position: relative;
29 | width: 100%;
30 | height: 100%;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/components/waterLevelPond/style.less:
--------------------------------------------------------------------------------
1 | .dv-water-pond-level {
2 | position: relative;
3 |
4 | svg {
5 | position: absolute;
6 | width: 100%;
7 | height: 100%;
8 | top: 0px;
9 | left: 0px;
10 | }
11 |
12 | text {
13 | font-size: 25px;
14 | font-weight: bold;
15 | text-anchor: middle;
16 | dominant-baseline: middle;
17 | }
18 |
19 | ellipse,
20 | rect {
21 | fill: none;
22 | stroke-width: 3;
23 | }
24 |
25 | canvas {
26 | margin-top: 8px;
27 | margin-left: 8px;
28 | width: calc(~"100% - 16px");
29 | height: calc(~"100% - 16px");
30 | box-sizing: border-box;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/components/borderBox10/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-10 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | border-radius: 6px;
6 |
7 | .dv-border-svg-container {
8 | position: absolute;
9 | display: block;
10 | }
11 |
12 | .right-top {
13 | right: 0px;
14 | transform: rotateY(180deg);
15 | }
16 |
17 | .left-bottom {
18 | bottom: 0px;
19 | transform: rotateX(180deg);
20 | }
21 |
22 | .right-bottom {
23 | right: 0px;
24 | bottom: 0px;
25 | transform: rotateX(180deg) rotateY(180deg);
26 | }
27 |
28 | .border-box-content {
29 | position: relative;
30 | width: 100%;
31 | height: 100%;
32 | }
33 | }
--------------------------------------------------------------------------------
/src/components/borderBox5/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-5 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-reverse {
7 | transform: rotate(180deg);
8 | }
9 |
10 | .dv-border-svg-container {
11 | position: absolute;
12 | top: 0px;
13 | left: 0px;
14 | width: 100%;
15 | height: 100%;
16 |
17 | & > polyline {
18 | fill: none;
19 | }
20 | }
21 |
22 | .dv-bb5-line-1, .dv-bb5-line-2 {
23 | stroke-width: 1;
24 | }
25 |
26 | .dv-bb5-line-3, .dv-bb5-line-6 {
27 | stroke-width: 5;
28 | }
29 |
30 | .dv-bb5-line-4, .dv-bb5-line-5 {
31 | stroke-width: 2;
32 | }
33 |
34 | .border-box-content {
35 | position: relative;
36 | width: 100%;
37 | height: 100%;
38 | }
39 | }
--------------------------------------------------------------------------------
/src/components/activeRingChart/style.less:
--------------------------------------------------------------------------------
1 | .dv-active-ring-chart {
2 | position: relative;
3 |
4 | .active-ring-chart-container {
5 | width: 100%;
6 | height: 100%;
7 | }
8 |
9 | .active-ring-info {
10 | position: absolute;
11 | width: 100%;
12 | height: 100%;
13 | left: 0px;
14 | top: 0px;
15 | display: flex;
16 | flex-direction: column;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | .dv-digital-flop {
21 | width: 100px;
22 | height: 30px;
23 | }
24 |
25 | .active-ring-name {
26 | width: 100px;
27 | height: 30px;
28 | color: #fff;
29 | text-align: center;
30 | vertical-align: middle;
31 | text-overflow: ellipsis;
32 | overflow: hidden;
33 | white-space: nowrap;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/components/scrollBoard/style.less:
--------------------------------------------------------------------------------
1 | .dv-scroll-board {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | color: #fff;
6 |
7 | .text {
8 | padding: 0 10px;
9 | box-sizing: border-box;
10 | white-space: nowrap;
11 | overflow: hidden;
12 | text-overflow: ellipsis;
13 | }
14 |
15 | .header {
16 | display: flex;
17 | flex-direction: row;
18 | font-size: 15px;
19 |
20 | .header-item {
21 | .text;
22 | transition: all 0.3s;
23 | }
24 | }
25 |
26 | .rows {
27 | overflow: hidden;
28 |
29 | .row-item {
30 | display: flex;
31 | font-size: 14px;
32 | transition: all 0.3s;
33 | }
34 |
35 | .ceil {
36 | .text;
37 | }
38 |
39 | .index {
40 | border-radius: 3px;
41 | padding: 0px 3px;
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/src/components/decoration4/style.less:
--------------------------------------------------------------------------------
1 | .dv-decoration-4 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .container {
7 | display: flex;
8 | overflow: hidden;
9 | position: absolute;
10 | flex: 1;
11 | }
12 |
13 | .normal {
14 | animation: ani-height ease-in-out infinite;
15 | left: 50%;
16 | margin-left: -2px;
17 | }
18 |
19 | .reverse {
20 | animation: ani-width ease-in-out infinite;
21 | top: 50%;
22 | margin-top: -2px;
23 | }
24 |
25 | @keyframes ani-height {
26 | 0% {
27 | height: 0%;
28 | }
29 |
30 | 70% {
31 | height: 100%;
32 | }
33 |
34 | 100% {
35 | height: 100%;
36 | }
37 | }
38 |
39 | @keyframes ani-width {
40 | 0% {
41 | width: 0%;
42 | }
43 |
44 | 70% {
45 | width: 100%;
46 | }
47 |
48 | 100% {
49 | width: 100%;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/components/fullScreenContainer/index.js:
--------------------------------------------------------------------------------
1 | import React, { useLayoutEffect, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import useAutoResize from '../../use/autoResize'
6 |
7 | import './style.less'
8 |
9 | const FullScreenContainer = forwardRef(({ children, className, style }, ref) => {
10 | const { domRef } = useAutoResize(ref)
11 |
12 | useLayoutEffect(() => {
13 | const { width, height } = window.screen
14 |
15 | Object.assign(domRef.current.style, {
16 | width: `${width}px`,
17 | height: `${height}px`
18 | })
19 |
20 | domRef.current.style.transform = `scale(${document.body.clientWidth /
21 | width})`
22 | })
23 |
24 | return (
25 |
31 | {children}
32 |
33 | )
34 | })
35 |
36 | FullScreenContainer.propTypes = {
37 | children: PropTypes.node,
38 | className: PropTypes.string,
39 | style: PropTypes.object
40 | }
41 |
42 | export default FullScreenContainer
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019-present, DataV-Team
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/src/components/borderBox4/style.less:
--------------------------------------------------------------------------------
1 | .dv-border-box-4 {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 |
6 | .dv-reverse {
7 | transform: rotate(180deg);
8 | }
9 |
10 | .dv-border-svg-container {
11 | position: absolute;
12 | width: 100%;
13 | height: 100%;
14 | top: 0px;
15 | left: 0px;
16 |
17 | & > polyline {
18 | fill: none;
19 | }
20 | }
21 |
22 | .sw1 {
23 | stroke-width: 1;
24 | }
25 |
26 | .sw3 {
27 | stroke-width: 3px;
28 | stroke-linecap: round;
29 | }
30 |
31 | .dv-bb4-line-1 {
32 | .sw1;
33 | }
34 |
35 | .dv-bb4-line-2 {
36 | .sw1;
37 | }
38 |
39 | .dv-bb4-line-3 {
40 | .sw3;
41 | }
42 |
43 | .dv-bb4-line-4 {
44 | .sw3;
45 | }
46 |
47 | .dv-bb4-line-5 {
48 | .sw1;
49 | }
50 |
51 | .dv-bb4-line-6 {
52 | .sw1;
53 | }
54 |
55 | .dv-bb4-line-7 {
56 | .sw1;
57 | }
58 |
59 | .dv-bb4-line-8 {
60 | .sw3;
61 | }
62 |
63 | .dv-bb4-line-9 {
64 | .sw3;
65 | stroke-dasharray: 100 250;
66 | }
67 |
68 | .dv-bb4-line-10 {
69 | .sw1;
70 | stroke-dasharray: 80 270;
71 | }
72 |
73 | .border-box-content {
74 | position: relative;
75 | width: 100%;
76 | height: 100%;
77 | }
78 | }
--------------------------------------------------------------------------------
/src/components/charts/index.js:
--------------------------------------------------------------------------------
1 | import React, { useRef, useEffect, useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import Chart from '@jiaminghi/charts'
8 |
9 | import useAutoResize from '../../use/autoResize'
10 |
11 | import './style.less'
12 |
13 | const Charts = forwardRef(({ option = {}, className, style }, ref) => {
14 | const { width, height, domRef } = useAutoResize(ref)
15 |
16 | const chartRef = useRef(null)
17 |
18 | const chartInstanceofRef = useRef(null)
19 |
20 | useEffect(() => {
21 | chartInstanceofRef.current ||
22 | (chartInstanceofRef.current = new Chart(chartRef.current))
23 |
24 | chartInstanceofRef.current.setOption(option || {}, true)
25 | }, [option])
26 |
27 | useEffect(() => {
28 | chartInstanceofRef.current.resize()
29 | }, [width, height])
30 |
31 | const classNames = useMemo(
32 | () => classnames('dv-charts-container', className),
33 | [className]
34 | )
35 |
36 | return (
37 |
40 | )
41 | })
42 |
43 | Charts.propTypes = {
44 | option: PropTypes.object,
45 | className: PropTypes.string,
46 | style: PropTypes.object
47 | }
48 |
49 | export default Charts
50 |
--------------------------------------------------------------------------------
/umdExample.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | DataV
5 |
9 |
13 |
14 |
15 |
19 |
20 |
21 |
25 |
44 |
45 |
46 |
47 |
48 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/components/scrollRankingBoard/style.less:
--------------------------------------------------------------------------------
1 | @color: #1370fb;
2 |
3 | .dv-scroll-ranking-board {
4 | width: 100%;
5 | height: 100%;
6 | color: #fff;
7 | overflow: hidden;
8 |
9 | .row-item {
10 | transition: all 0.3s;
11 | display: flex;
12 | flex-direction: column;
13 | justify-content: center;
14 | overflow: hidden;
15 | }
16 |
17 | .ranking-info {
18 | display: flex;
19 | width: 100%;
20 | font-size: 13px;
21 |
22 | .rank {
23 | width: 40px;
24 | color: @color;
25 | }
26 |
27 | .info-name {
28 | flex: 1;
29 | }
30 | }
31 |
32 | .ranking-column {
33 | border-bottom: 2px solid fade(@color, 50);
34 | margin-top: 5px;
35 |
36 | .inside-column {
37 | position: relative;
38 | height: 6px;
39 | background-color: @color;
40 | margin-bottom: 2px;
41 | border-radius: 1px;
42 | overflow: hidden;
43 | }
44 |
45 | .shine {
46 | position: absolute;
47 | left: 0%;
48 | top: 2px;
49 | height: 2px;
50 | width: 50px;
51 | transform: translateX(-100%);
52 | background: radial-gradient(rgb(40, 248, 255) 5%, transparent 80%);
53 | animation: shine 3s ease-in-out infinite alternate;
54 | }
55 | }
56 | }
57 |
58 | @keyframes shine {
59 | 80% {
60 | left: 0%;
61 | transform: translateX(-100%);
62 | }
63 |
64 | 100% {
65 | left: 100%;
66 | transform: translateX(0%);
67 | }
68 | }
--------------------------------------------------------------------------------
/src/use/autoResize.js:
--------------------------------------------------------------------------------
1 | import { useState, useCallback, useEffect, useRef, useImperativeHandle } from 'react'
2 | import { debounce, observerDomResize } from '../util/index'
3 |
4 | export default function useAutoResize(ref) {
5 | const [state, setState] = useState({ width: 0, height: 0 })
6 |
7 | const domRef = useRef(null)
8 |
9 | const setWH = useCallback(() => {
10 | const { clientWidth, clientHeight } = domRef.current || { clientWidth: 0, clientHeight: 0 }
11 |
12 | setState({ width: clientWidth, height: clientHeight })
13 |
14 | if (!domRef.current) {
15 | console.warn('DataV: Failed to get dom node, component rendering may be abnormal!')
16 | } else if (!clientWidth || !clientHeight) {
17 | console.warn('DataV: Component width or height is 0px, rendering abnormality may occur!')
18 | }
19 | }, [])
20 |
21 | useImperativeHandle(ref, () => ({ setWH }), [])
22 |
23 | useEffect(() => {
24 | const debounceSetWHFun = debounce(setWH, 100)
25 |
26 | debounceSetWHFun()
27 |
28 | const domObserver = observerDomResize(domRef.current, debounceSetWHFun)
29 |
30 | window.addEventListener('resize', debounceSetWHFun)
31 |
32 | return () => {
33 | window.removeEventListener('resize', debounceSetWHFun)
34 |
35 | if (!domObserver) {
36 | return
37 | }
38 |
39 | domObserver.disconnect()
40 | domObserver.takeRecords()
41 | }
42 | }, [])
43 |
44 | return { ...state, domRef, setWH }
45 | }
46 |
--------------------------------------------------------------------------------
/src/components/capsuleChart/style.less:
--------------------------------------------------------------------------------
1 | .dv-capsule-chart {
2 | position: relative;
3 | display: flex;
4 | flex-direction: row;
5 | box-sizing: border-box;
6 | padding: 10px;
7 | color: #fff;
8 |
9 | .label-column {
10 | display: flex;
11 | flex-direction: column;
12 | justify-content: space-between;
13 | box-sizing: border-box;
14 | padding-right: 10px;
15 | text-align: right;
16 | font-size: 12px;
17 |
18 | div {
19 | height: 20px;
20 | line-height: 20px;
21 | }
22 | }
23 |
24 | .capsule-container {
25 | flex: 1;
26 | display: flex;
27 | flex-direction: column;
28 | justify-content: space-between;
29 | }
30 |
31 | .capsule-item {
32 | box-shadow: 0 0 3px #999;
33 | height: 10px;
34 | margin: 5px 0px;
35 | border-radius: 5px;
36 |
37 | .capsule-item-column {
38 | position: relative;
39 | height: 8px;
40 | margin-top: 1px;
41 | border-radius: 5px;
42 | transition: all 0.3s;
43 | display: flex;
44 | justify-content: flex-end;
45 | align-items: center;
46 |
47 | .capsule-item-value {
48 | font-size: 12px;
49 | transform: translateX(100%);
50 | }
51 | }
52 | }
53 |
54 | .unit-label {
55 | height: 20px;
56 | font-size: 12px;
57 | position: relative;
58 | display: flex;
59 | justify-content: space-between;
60 | align-items: center;
61 | }
62 |
63 | .unit-text {
64 | text-align: right;
65 | display: flex;
66 | align-items: flex-end;
67 | font-size: 12px;
68 | line-height: 20px;
69 | margin-left: 10px;
70 | }
71 | }
--------------------------------------------------------------------------------
/src/components/decoration7/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util'
8 |
9 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
10 |
11 | import './style.less'
12 |
13 | const defaultColor = ['#1dc1f5', '#1dc1f5']
14 |
15 | const Decoration = ({ children, className, style, color = [] }) => {
16 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
17 |
18 | const classNames = useMemo(() => classnames('dv-decoration-7', className), [
19 | className
20 | ])
21 |
22 | return (
23 |
24 |
38 | {children}
39 |
53 |
54 | )
55 | }
56 |
57 | Decoration.propTypes = {
58 | children: PropTypes.node,
59 | className: PropTypes.string,
60 | style: PropTypes.object,
61 | color: PropTypes.array
62 | }
63 |
64 | export default Decoration
65 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import babel from 'rollup-plugin-babel'
2 | import commonjs from 'rollup-plugin-commonjs'
3 | import external from 'rollup-plugin-peer-deps-external'
4 | import postcss from 'rollup-plugin-postcss'
5 | import resolve from 'rollup-plugin-node-resolve'
6 | import replace from 'rollup-plugin-replace'
7 | import { uglify } from 'rollup-plugin-uglify'
8 | import url from 'rollup-plugin-url'
9 | import svgr from '@svgr/rollup'
10 |
11 | // 通过 mode 接口拿到 src/components 下的所有文件夹名作为打包后的模块
12 | const fs = require('fs')
13 | const path = require('path')
14 | const componentDir = 'src/components'
15 | const cModuleNames = fs.readdirSync(path.resolve(componentDir))
16 | const cModuleMap = cModuleNames.reduce((prev, name) => {
17 | prev[name] = `${componentDir}/${name}/index.js`
18 |
19 | return prev
20 | }, {})
21 |
22 | const plugins = [
23 | external(),
24 | postcss(),
25 | url(),
26 | svgr(),
27 | babel({
28 | exclude: 'node_modules/**',
29 | plugins: ['external-helpers']
30 | }),
31 | resolve(),
32 | commonjs()
33 | ]
34 |
35 | export default [
36 | {
37 | input: {
38 | index: 'src/index.js',
39 | ...cModuleMap
40 | },
41 | output: [
42 | {
43 | dir: 'lib',
44 | entryFileNames: '[name]/index.js',
45 | format: 'cjs',
46 | sourcemap: true
47 | },
48 | {
49 | dir: 'es',
50 | entryFileNames: '[name]/index.js',
51 | format: 'es',
52 | sourcemap: true
53 | }
54 | ],
55 | plugins,
56 | experimentalCodeSplitting: true
57 | },
58 | {
59 | input: 'src/index.js',
60 | output: {
61 | format: 'umd',
62 | file: 'umd/datav.js',
63 | name: 'datav'
64 | },
65 | plugins: [...plugins, replace({ 'process.env.NODE_ENV': '"development"' })]
66 | },
67 | {
68 | input: 'src/index.js',
69 | output: {
70 | format: 'umd',
71 | file: 'umd/datav.min.js',
72 | name: 'datav'
73 | },
74 | plugins: [
75 | ...plugins,
76 | replace({ 'process.env.NODE_ENV': '"production"' }),
77 | uglify()
78 | ]
79 | }
80 | ]
81 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@jiaminghi/data-view-react",
3 | "version": "1.2.5",
4 | "description": "React Large screen data display component library",
5 | "author": "Duan Yu <949267840@qq.com>",
6 | "license": "MIT",
7 | "repository": "DataV-Team/DataV-React",
8 | "main": "lib/index/index.js",
9 | "module": "es/index/index.js",
10 | "unpkg": "umd/datav.js",
11 | "engines": {
12 | "node": ">=8",
13 | "npm": ">=5"
14 | },
15 | "scripts": {
16 | "test": "cross-env CI=1 react-scripts test --env=jsdom",
17 | "test:watch": "react-scripts test --env=jsdom",
18 | "build": "rollup -c",
19 | "start": "rollup -c -w",
20 | "prepare": "yarn run build"
21 | },
22 | "dependencies": {
23 | "@jiaminghi/charts": "^0.2"
24 | },
25 | "peerDependencies": {
26 | "react": "^16.8.0",
27 | "react-dom": "^16.8.0"
28 | },
29 | "devDependencies": {
30 | "@svgr/rollup": "^2.4.1",
31 | "babel-core": "^6.26.3",
32 | "babel-eslint": "^8.2.5",
33 | "babel-plugin-external-helpers": "^6.22.0",
34 | "babel-preset-env": "^1.7.0",
35 | "babel-preset-react": "^6.24.1",
36 | "babel-preset-stage-0": "^6.24.1",
37 | "classnames": "^2.2.6",
38 | "cross-env": "^5.1.4",
39 | "eslint": "^5.0.1",
40 | "eslint-config-standard": "^11.0.0",
41 | "eslint-config-standard-react": "^6.0.0",
42 | "eslint-plugin-import": "^2.13.0",
43 | "eslint-plugin-node": "^7.0.1",
44 | "eslint-plugin-promise": "^4.0.0",
45 | "eslint-plugin-react": "^7.10.0",
46 | "eslint-plugin-standard": "^3.1.0",
47 | "less": "^3.10.3",
48 | "prop-types": "^15.7.2",
49 | "react": "^16.8.6",
50 | "react-dom": "^16.8.6",
51 | "react-scripts": "^1.1.4",
52 | "rollup": "^1.21.4",
53 | "rollup-plugin-babel": "^3.0.7",
54 | "rollup-plugin-commonjs": "^9.1.3",
55 | "rollup-plugin-node-resolve": "^3.3.0",
56 | "rollup-plugin-peer-deps-external": "^2.2.0",
57 | "rollup-plugin-postcss": "^1.6.2",
58 | "rollup-plugin-replace": "^2.2.0",
59 | "rollup-plugin-uglify": "^6.0.3",
60 | "rollup-plugin-url": "^1.4.0"
61 | },
62 | "files": [
63 | "src",
64 | "lib",
65 | "es",
66 | "umd"
67 | ]
68 | }
69 |
--------------------------------------------------------------------------------
/src/components/loading/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import './style.less'
8 |
9 | const Loading = ({ children, className, style }) => {
10 | const classNames = useMemo(() => classnames('dv-loading', className), [
11 | className
12 | ])
13 |
14 | return (
15 |
16 |
67 |
{children}
68 |
69 | )
70 | }
71 |
72 | Loading.propTypes = {
73 | children: PropTypes.node,
74 | className: PropTypes.string,
75 | style: PropTypes.object
76 | }
77 |
78 | export default Loading
79 |
--------------------------------------------------------------------------------
/src/components/borderBox2/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['#fff', 'rgba(255, 255, 255, 0.6)']
15 |
16 | const BorderBox = forwardRef(({ children, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
20 |
21 | const classNames = useMemo(() => classnames('dv-border-box-2', className), [
22 | className
23 | ])
24 |
25 | return (
26 |
27 |
46 |
{children}
47 |
48 | )
49 | })
50 |
51 | BorderBox.propTypes = {
52 | children: PropTypes.node,
53 | className: PropTypes.string,
54 | style: PropTypes.object,
55 | color: PropTypes.array,
56 | backgroundColor: PropTypes.string
57 | }
58 |
59 | export default BorderBox
60 |
--------------------------------------------------------------------------------
/src/components/borderBox10/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const border = ['left-top', 'right-top', 'left-bottom', 'right-bottom']
15 | const defaultColor = ['#1d48c4', '#d3e1f8']
16 |
17 | const BorderBox = forwardRef(({ children, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
18 | const { width, height, domRef } = useAutoResize(ref)
19 |
20 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
21 |
22 | const classNames = useMemo(() => classnames('dv-border-box-10', className), [
23 | className
24 | ])
25 |
26 | const styles = useMemo(() => ({
27 | boxShadow: `inset 0 0 25px 3px ${mergedColor[0]}`,
28 | ...style
29 | }), [style, mergedColor])
30 |
31 | return (
32 |
33 |
39 |
40 | {border.map(borderName => (
41 |
52 | ))}
53 |
{children}
54 |
55 | )
56 | })
57 |
58 | BorderBox.propTypes = {
59 | children: PropTypes.node,
60 | className: PropTypes.string,
61 | style: PropTypes.object,
62 | color: PropTypes.array,
63 | backgroundColor: PropTypes.string
64 | }
65 |
66 | export default BorderBox
67 |
--------------------------------------------------------------------------------
/src/components/decoration8/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util'
8 |
9 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
10 |
11 | import useAutoResize from '../../use/autoResize'
12 |
13 | import './style.less'
14 |
15 | const defaultColor = ['#3f96a5', '#3f96a5']
16 |
17 | const Decoration = forwardRef(({ reverse = false, className, style, color = [] }, ref) => {
18 | const { width, height, domRef } = useAutoResize(ref)
19 |
20 | const xPos = pos => (!reverse ? pos : width - pos)
21 |
22 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
23 |
24 | const [pointsOne, pointsTwo, pointsThree] = useMemo(
25 | () => [
26 | `${xPos(0)}, 0 ${xPos(30)}, ${height / 2}`,
27 | `${xPos(20)}, 0 ${xPos(50)}, ${height / 2} ${xPos(width)}, ${height / 2}`,
28 | `${xPos(0)}, ${height - 3}, ${xPos(200)}, ${height - 3}`
29 | ],
30 | [reverse, width, height]
31 | )
32 |
33 | const classNames = useMemo(() => classnames('dv-decoration-8', className), [
34 | className
35 | ])
36 |
37 | return (
38 |
39 |
61 |
62 | )
63 | })
64 |
65 | Decoration.propTypes = {
66 | reverse: PropTypes.bool,
67 | className: PropTypes.string,
68 | style: PropTypes.object,
69 | color: PropTypes.array
70 | }
71 |
72 | // 指定 props 的默认值:
73 | Decoration.defaultProps = {
74 | reverse: false
75 | }
76 |
77 | export default Decoration
78 |
--------------------------------------------------------------------------------
/src/components/decoration4/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['rgba(255, 255, 255, 0.3)', 'rgba(255, 255, 255, 0.3)']
15 |
16 | const Decoration = forwardRef(({ reverse = false, dur = 3, className, style, color = [] }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
20 |
21 | const classNames = useMemo(() => classnames('dv-decoration-4', className), [
22 | className
23 | ])
24 |
25 | return (
26 |
51 | )
52 | })
53 |
54 | Decoration.propTypes = {
55 | dur: PropTypes.number,
56 | reverse: PropTypes.bool,
57 | className: PropTypes.string,
58 | style: PropTypes.object,
59 | color: PropTypes.array
60 | }
61 |
62 | // 指定 props 的默认值:
63 | Decoration.defaultProps = {
64 | reverse: false,
65 | dur: 3
66 | }
67 |
68 | export default Decoration
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [ENGLISH](./README_EN.md)
2 |
3 |
4 |
5 |
6 | DataV-React
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | ## DataV-React 是干什么的?
17 |
18 | - DataV-React 是一个基于**React**的数据可视化组件库(当然也有[Vue 版本](https://github.com/DataV-Team/DataV))
19 | - 提供用于提升页面视觉效果的**SVG**边框和装饰
20 | - 提供常用的**图表**如折线图等
21 | - 飞线图/轮播表等其他组件
22 |
23 | ### 注意事项
24 |
25 | **使用了 React Hooks, 简化了许多内部工作。您需要 React 版本 16.8.0 及以上**
26 |
27 | ### npm 安装
28 |
29 | ```shell
30 | $ npm install @jiaminghi/data-view-react
31 | ```
32 |
33 | ### 使用
34 |
35 | ```js
36 | import * as datav from "@jiaminghi/data-view-react";
37 |
38 | datav.BorderBox1;
39 |
40 | // 或者
41 | import { BorderBox1 } from "@jiaminghi/data-view-react";
42 |
43 | // 按需引入
44 | import BorderBox1 from "@jiaminghi/data-view-react/es/borderBox1";
45 | ```
46 |
47 | 详细文档及示例请移步[HomePage](http://datav-react.jiaminghi.com).
48 |
49 | ### UMD 版
50 |
51 | `UMD`版可直接使用`script`标签引入,引入后通过**datav**命名空间使用对应的组件,引入`data-view-react`前请确保已引入`react 和 react-dom`。
52 |
53 | [UMD 版使用示例](./umdExample.html)
54 |
55 | ### TODO
56 |
57 | * **地图组件**
58 | * **TS**重构组件库底层依赖
59 |
60 | ### 致谢
61 |
62 | 组件库的开发基于个人学习和兴趣,由于技术水平及经验的限制,组件尚有许多不完善之处,如有 BUG 可及时提交[issue](https://github.com/DataV-Team/DataV-React/issues/new?template=bug_report.md)或添加反馈群进行反馈,也欢迎提供指正和建议,感谢各位的支持。
63 |
64 | ### 反馈
65 |
66 | 
67 |
68 | ### Demo
69 |
70 | Demo 页面使用了全屏组件,请 F11 全屏后查看。
71 |
72 | - [施工养护综合数据](http://datav-react.jiaminghi.com/demo/construction-data/index.html)
73 |
74 | 
75 |
76 | - [机电运维管理台](http://datav-react.jiaminghi.com/demo/manage-desk/index.html)
77 |
78 | 
79 |
80 | - [机电设备电子档案](http://datav-react.jiaminghi.com/demo/electronic-file/index.html)
81 |
82 | 
83 |
--------------------------------------------------------------------------------
/src/components/borderBox13/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['#6586ec', '#2cf7fe']
15 |
16 | const BorderBox = forwardRef(({ children, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
20 |
21 | const classNames = useMemo(() => classnames('dv-border-box-13', className), [
22 | className
23 | ])
24 |
25 | return (
26 |
27 |
60 |
61 | {children}
62 |
63 |
64 | )
65 | })
66 |
67 | BorderBox.propTypes = {
68 | children: PropTypes.node,
69 | className: PropTypes.string,
70 | style: PropTypes.object,
71 | color: PropTypes.array,
72 | backgroundColor: PropTypes.string
73 | }
74 |
75 | export default BorderBox
76 |
--------------------------------------------------------------------------------
/src/components/borderBox3/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['#2862b7', '#2862b7']
15 |
16 | const BorderBox = forwardRef(({ children, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
20 |
21 | const classNames = useMemo(() => classnames('dv-border-box-3', className), [
22 | className
23 | ])
24 |
25 | return (
26 |
27 |
56 |
57 |
{children}
58 |
59 | )
60 | })
61 |
62 | BorderBox.propTypes = {
63 | children: PropTypes.node,
64 | className: PropTypes.string,
65 | style: PropTypes.object,
66 | color: PropTypes.array,
67 | backgroundColor: PropTypes.string
68 | }
69 |
70 | export default BorderBox
71 |
--------------------------------------------------------------------------------
/src/components/decoration2/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['#3faacb', '#fff']
15 |
16 | const Decoration = forwardRef(({ reverse = false, dur = 6, className, style, color = [] }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | function calcSVGData() {
20 | return reverse
21 | ? { w: 1, h: height, x: width / 2, y: 0 }
22 | : { w: width, h: 1, x: 0, y: height / 2 }
23 | }
24 |
25 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
26 |
27 | const { x, y, w, h } = useMemo(calcSVGData, [reverse, width, height])
28 |
29 | const classNames = useMemo(() => classnames('dv-decoration-2', className), [
30 | className
31 | ])
32 |
33 | return (
34 |
35 |
62 |
63 | )
64 | })
65 |
66 | Decoration.propTypes = {
67 | dur: PropTypes.number,
68 | reverse: PropTypes.bool,
69 | className: PropTypes.string,
70 | style: PropTypes.object,
71 | color: PropTypes.array
72 | }
73 |
74 | // 指定 props 的默认值:
75 | Decoration.defaultProps = {
76 | reverse: false,
77 | dur: 6
78 | }
79 |
80 | export default Decoration
81 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * IMPORT COMPONENTS
3 | */
4 | export { default as FullScreenContainer } from './components/fullScreenContainer'
5 | export { default as Loading } from './components/loading'
6 |
7 | // border box
8 | export { default as BorderBox1 } from './components/borderBox1'
9 | export { default as BorderBox2 } from './components/borderBox2'
10 | export { default as BorderBox3 } from './components/borderBox3'
11 | export { default as BorderBox4 } from './components/borderBox4'
12 | export { default as BorderBox5 } from './components/borderBox5'
13 | export { default as BorderBox6 } from './components/borderBox6'
14 | export { default as BorderBox7 } from './components/borderBox7'
15 | export { default as BorderBox8 } from './components/borderBox8'
16 | export { default as BorderBox9 } from './components/borderBox9'
17 | export { default as BorderBox10 } from './components/borderBox10'
18 | export { default as BorderBox11 } from './components/borderBox11'
19 | export { default as BorderBox12 } from './components/borderBox12'
20 | export { default as BorderBox13 } from './components/borderBox13'
21 |
22 | // decoration
23 | export { default as Decoration1 } from './components/decoration1'
24 | export { default as Decoration2 } from './components/decoration2'
25 | export { default as Decoration3 } from './components/decoration3'
26 | export { default as Decoration4 } from './components/decoration4'
27 | export { default as Decoration5 } from './components/decoration5'
28 | export { default as Decoration6 } from './components/decoration6'
29 | export { default as Decoration7 } from './components/decoration7'
30 | export { default as Decoration8 } from './components/decoration8'
31 | export { default as Decoration9 } from './components/decoration9'
32 | export { default as Decoration10 } from './components/decoration10'
33 | export { default as Decoration11 } from './components/decoration11'
34 | export { default as Decoration12 } from './components/decoration12'
35 |
36 | // charts
37 | export { default as Charts } from './components/charts'
38 |
39 | export { default as ActiveRingChart } from './components/activeRingChart'
40 | export { default as CapsuleChart } from './components/capsuleChart'
41 | export { default as WaterLevelPond } from './components/waterLevelPond'
42 | export { default as PercentPond } from './components/percentPond'
43 | export { default as FlylineChart } from './components/flylineChart'
44 | export { default as FlylineChartEnhanced } from './components/flylineChartEnhanced'
45 | export { default as ConicalColumnChart } from './components/conicalColumnChart'
46 | export { default as DigitalFlop } from './components/digitalFlop'
47 | export { default as ScrollBoard } from './components/scrollBoard'
48 | export { default as ScrollRankingBoard } from './components/scrollRankingBoard'
49 |
50 | export { default as useAutoResize } from './use/autoResize'
51 |
52 | export { co } from './util'
53 |
--------------------------------------------------------------------------------
/src/components/decoration3/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['#7acaec', 'transparent']
15 |
16 | const pointSideLength = 7
17 |
18 | const svgWH = [300, 35]
19 |
20 | const rowNum = 2
21 |
22 | const rowPoints = 25
23 |
24 | const halfPointSideLength = pointSideLength / 2
25 |
26 | function getPoints() {
27 | const [w, h] = svgWH
28 |
29 | const horizontalGap = w / (rowPoints + 1)
30 | const verticalGap = h / (rowNum + 1)
31 |
32 | let points = new Array(rowNum)
33 | .fill(0)
34 | .map((foo, i) =>
35 | new Array(rowPoints)
36 | .fill(0)
37 | .map((foo, j) => [horizontalGap * (j + 1), verticalGap * (i + 1)])
38 | )
39 |
40 | return points.reduce((all, item) => [...all, ...item], [])
41 | }
42 |
43 | const Decoration = forwardRef(({ className, style, color = [] }, ref) => {
44 | const { width, height, domRef } = useAutoResize(ref)
45 |
46 | function calcSVGData() {
47 | return {
48 | points: getPoints(),
49 | svgScale: [width / svgWH[0], height / svgWH[1]]
50 | }
51 | }
52 |
53 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
54 |
55 | const { svgScale, points } = useMemo(calcSVGData, [width, height])
56 |
57 | const classNames = useMemo(() => classnames('dv-decoration-3', className), [
58 | className
59 | ])
60 |
61 | return (
62 |
63 |
89 |
90 | )
91 | })
92 |
93 | Decoration.propTypes = {
94 | className: PropTypes.string,
95 | style: PropTypes.object,
96 | color: PropTypes.array
97 | }
98 |
99 | export default Decoration
100 |
--------------------------------------------------------------------------------
/src/components/borderBox6/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['rgba(255, 255, 255, 0.35)', 'gray']
15 |
16 | const BorderBox = forwardRef(({ children, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
20 |
21 | const classNames = useMemo(() => classnames('dv-border-box-6', className), [
22 | className
23 | ])
24 |
25 | return (
26 |
27 |
54 |
55 |
{children}
56 |
57 | )
58 | })
59 |
60 | BorderBox.propTypes = {
61 | children: PropTypes.node,
62 | className: PropTypes.string,
63 | style: PropTypes.object,
64 | color: PropTypes.array,
65 | backgroundColor: PropTypes.string
66 | }
67 |
68 | export default BorderBox
69 |
--------------------------------------------------------------------------------
/src/components/decoration11/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 | import { fade } from '@jiaminghi/color'
10 |
11 | import useAutoResize from '../../use/autoResize'
12 |
13 | import './style.less'
14 |
15 | const defaultColor = ['#1a98fc', '#2cf7fe']
16 |
17 | const BorderBox = forwardRef(({ children, className, style, color = [] }, ref) => {
18 | const { width, height, domRef } = useAutoResize(ref)
19 |
20 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
21 |
22 | const classNames = useMemo(() => classnames('dv-decoration-11', className), [
23 | className
24 | ])
25 |
26 | return (
27 |
28 |
74 |
75 |
76 | {children}
77 |
78 |
79 | )
80 | })
81 |
82 | BorderBox.propTypes = {
83 | children: PropTypes.node,
84 | className: PropTypes.string,
85 | style: PropTypes.object,
86 | color: PropTypes.array
87 | }
88 |
89 | export default BorderBox
90 |
--------------------------------------------------------------------------------
/README_EN.md:
--------------------------------------------------------------------------------
1 | [中文](./README.md)
2 |
3 |
4 |
5 |
6 | DataV-React
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | ## What is DataV-React?
17 |
18 | - DataV-React is a data **visualization** components library based on **React**(Of course there are also[Vue version](https://github.com/DataV-Team/DataV)).
19 | - Provide cool **SVG** borders and decorations.
20 | - Provide common **charts** such as line chart, etc..
21 | - flying line chart, carousel table and etc.
22 |
23 | ### Precautions
24 |
25 | **Using React Hooks simplifies many internal work. You need React version 16.8.0 and above**
26 |
27 | ### Install with npm
28 |
29 | ```shell
30 | $ npm install @jiaminghi/data-view-react
31 | ```
32 |
33 | ### use
34 |
35 | ```js
36 | import * as datav from "@jiaminghi/data-view-react";
37 |
38 | datav.BorderBox1;
39 |
40 | // or
41 | import { BorderBox1 } from "@jiaminghi/data-view-react";
42 |
43 | // Introduced on demand
44 | import BorderBox1 from "@jiaminghi/data-view-react/es/borderBox1";
45 | ```
46 |
47 | Detailed documents and examples can be viewed on the [HomePage](http://datav-react.jiaminghi.com).
48 |
49 | ### UMD version
50 |
51 | The `UMD` version can be directly imported using the `script` tag. After the introduction, the corresponding component is used through the **datav** namespace. Before introducing `data-view-react`, please ensure that `react and react-dom are introduced.
52 |
53 | [UMD version usage example](./umdExample.html)
54 |
55 | ### TODO
56 |
57 | * **Map Component**
58 | * Refactor underlying dependencies using **TS**.
59 |
60 | ### Acknowledgement
61 |
62 | The development of the component library is based on personal learning and interest. Due to technical level and experience limitations, there are still many imperfections in the components. If there are errors, you can submit [issue](https://github.com/DataV-Team/DataV-React/issues/new?template=bug_report.md) in time or add feedback groups for feedback. Welcome to provide corrections and suggestions. Thank you for your support.
63 |
64 | ### Feedback
65 |
66 | 
67 |
68 | ### Demo
69 |
70 | The Demo page uses the full-screen component, please view it after F11 full screen.
71 |
72 | - [Construction Data](http://datav-react.jiaminghi.com/demo/construction-data/index.html)
73 |
74 | 
75 |
76 | - [Manage-Desk](http://datav-react.jiaminghi.com/demo/manage-desk/index.html)
77 |
78 | 
79 |
80 | - [Electronic-File](http://datav-react.jiaminghi.com/demo/electronic-file/index.html)
81 |
82 | 
83 |
--------------------------------------------------------------------------------
/src/components/borderBox5/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['rgba(255, 255, 255, 0.35)', 'rgba(255, 255, 255, 0.20)']
15 |
16 | const BorderBox = forwardRef(({ children, reverse = false, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
20 |
21 | const classNames = useMemo(() => classnames('dv-border-box-5', className), [
22 | className
23 | ])
24 |
25 | return (
26 |
27 |
68 |
69 |
{children}
70 |
71 | )
72 | })
73 |
74 | BorderBox.propTypes = {
75 | children: PropTypes.node,
76 | reverse: PropTypes.bool,
77 | className: PropTypes.string,
78 | style: PropTypes.object,
79 | color: PropTypes.array,
80 | backgroundColor: PropTypes.string
81 | }
82 |
83 | // 指定 props 的默认值:
84 | BorderBox.defaultProps = {
85 | reverse: false,
86 | backgroundColor: 'transparent'
87 | }
88 |
89 | export default BorderBox
90 |
--------------------------------------------------------------------------------
/src/components/borderBox7/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['rgba(128,128,128,0.3)', 'rgba(128,128,128,0.5)']
15 |
16 | const BorderBox = forwardRef(({ children, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
20 |
21 | const classNames = useMemo(() => classnames('dv-border-box-7', className), [
22 | className
23 | ])
24 |
25 | const styles = useMemo(() => ({
26 | boxShadow: `inset 0 0 40px ${mergedColor[0]}`,
27 | border: `1px solid ${mergedColor[0]}`,
28 | backgroundColor,
29 | ...style
30 | }), [style, mergedColor, backgroundColor])
31 |
32 | return (
33 |
34 |
70 |
71 |
{children}
72 |
73 | )
74 | })
75 |
76 | BorderBox.propTypes = {
77 | children: PropTypes.node,
78 | className: PropTypes.string,
79 | style: PropTypes.object,
80 | color: PropTypes.array,
81 | backgroundColor: PropTypes.string
82 | }
83 |
84 | export default BorderBox
85 |
--------------------------------------------------------------------------------
/src/util/index.js:
--------------------------------------------------------------------------------
1 | export function randomExtend(minNum, maxNum) {
2 | if (arguments.length === 1) {
3 | return parseInt(Math.random() * minNum + 1, 10)
4 | } else {
5 | return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
6 | }
7 | }
8 |
9 | /**
10 | * @description 将函数转成防抖动函数
11 | * @param {Function} 需要转成防抖动函数的函数
12 | * @param {number} 延迟时间(毫秒数)
13 | * @param {boolean} 是否执行第一次
14 | * @return {undefined} 无返回值
15 | */
16 | export function debounce(fn, delay = 600, runFirstFn = true) {
17 | let timer = null
18 |
19 | return function(...rest) {
20 | // 清除定时器
21 | clearTimeout(timer)
22 | if (runFirstFn) {
23 | fn.apply(this, rest)
24 | runFirstFn = false
25 | return
26 | }
27 |
28 | // 设置定时器
29 | timer = setTimeout(fn.bind(this, ...rest), delay)
30 | }
31 | }
32 |
33 | export function observerDomResize(dom, callback) {
34 | const MutationObserver =
35 | window.MutationObserver ||
36 | window.WebKitMutationObserver ||
37 | window.MozMutationObserver
38 |
39 | const observer = new MutationObserver(callback)
40 |
41 | observer.observe(dom, {
42 | attributes: true,
43 | attributeFilter: ['style'],
44 | attributeOldValue: true
45 | })
46 |
47 | return observer
48 | }
49 |
50 | export function getPointDistance(pointOne, pointTwo) {
51 | const minusX = Math.abs(pointOne[0] - pointTwo[0])
52 |
53 | const minusY = Math.abs(pointOne[1] - pointTwo[1])
54 |
55 | return Math.sqrt(minusX * minusX + minusY * minusY)
56 | }
57 |
58 | export function co(gen) {
59 | let destroyed = false
60 |
61 | // 处理 return 之后 resume 的问题
62 | let stop = false
63 |
64 | let val = null
65 |
66 | if (typeof gen === 'function') gen = gen()
67 |
68 | if (!gen || typeof gen.next !== 'function') return () => ({})
69 |
70 | Promise.resolve().then(() => {
71 | destroyed || next(gen.next())
72 | })
73 |
74 | return {
75 | end () {
76 | destroyed = true
77 |
78 | Promise.resolve().then(() => {
79 | gen.return()
80 |
81 | gen = null
82 | })
83 | },
84 | pause () {
85 | if (!destroyed) { stop = true }
86 | },
87 | resume () {
88 | const oldVal = val
89 |
90 | if (!destroyed && stop) {
91 | stop = false
92 |
93 | Promise.resolve(val).then(function () {
94 | if (!destroyed && !stop && oldVal === val) { next(gen.next()) }
95 | })
96 | }
97 | }
98 | }
99 |
100 | function next(ret) {
101 | if (ret.done) return ret.value
102 |
103 | val = ret.value
104 |
105 | return Promise.resolve(ret.value).then(() => {
106 | (!destroyed && !stop) && next(gen.next())
107 | })
108 | }
109 | }
110 |
111 | export function uuid (hasHyphen) {
112 | return (hasHyphen ? 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' : 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx').replace(/[xy]/g, function (c) {
113 | const r = Math.random() * 16 | 0
114 | const v = c === 'x' ? r : (r & 0x3 | 0x8)
115 | return v.toString(16)
116 | })
117 | }
118 |
--------------------------------------------------------------------------------
/src/components/borderBox4/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const defaultColor = ['red', 'rgba(0,0,255,0.8)']
15 |
16 | const BorderBox = forwardRef(({ children, reverse = false, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
17 | const { width, height, domRef } = useAutoResize(ref)
18 |
19 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
20 |
21 | const classNames = useMemo(() => classnames('dv-border-box-4', className), [
22 | className
23 | ])
24 |
25 | return (
26 |
27 |
73 |
74 |
{children}
75 |
76 | )
77 | })
78 |
79 | BorderBox.propTypes = {
80 | children: PropTypes.node,
81 | reverse: PropTypes.bool,
82 | className: PropTypes.string,
83 | style: PropTypes.object,
84 | color: PropTypes.array,
85 | backgroundColor: PropTypes.string
86 | }
87 |
88 | // 指定 props 的默认值:
89 | BorderBox.defaultProps = {
90 | reverse: false,
91 | backgroundColor: 'transparent'
92 | }
93 |
94 | export default BorderBox
95 |
--------------------------------------------------------------------------------
/src/components/borderBox8/index.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import { uuid } from '../../util'
13 |
14 | import './style.less'
15 |
16 | const defaultColor = ['#235fa7', '#4fd2dd']
17 |
18 | const BorderBox = forwardRef((
19 | {
20 | children,
21 | className,
22 | style,
23 | color = [],
24 | dur = 3,
25 | backgroundColor = 'transparent',
26 | reverse = false
27 | },
28 | ref
29 | ) => {
30 | const { width, height, domRef } = useAutoResize(ref)
31 |
32 | const [{ path, gradient, mask }] = useState(() => {
33 | const id = uuid()
34 |
35 | return {
36 | path: `border-box-8-path-${id}`,
37 | gradient: `border-box-8-gradient-${id}`,
38 | mask: `border-box-8-mask-${id}`
39 | }
40 | })
41 |
42 | const pathD = useMemo(() =>
43 | reverse
44 | ? `M 2.5, 2.5 L 2.5, ${height - 2.5} L ${width - 2.5}, ${height - 2.5} L ${width - 2.5}, 2.5 L 2.5, 2.5`
45 | : `M2.5, 2.5 L${width - 2.5}, 2.5 L${width - 2.5}, ${height - 2.5} L2.5, ${height - 2.5} L2.5, 2.5`
46 | , [width, height, reverse])
47 |
48 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
49 |
50 | const length = useMemo(() => (width + height - 5) * 2, [width, height])
51 |
52 | const classNames = useMemo(() => classnames('dv-border-box-8', className), [
53 | className
54 | ])
55 |
56 | return (
57 |
58 |
92 |
93 |
{children}
94 |
95 | )
96 | })
97 |
98 | BorderBox.propTypes = {
99 | children: PropTypes.node,
100 | className: PropTypes.string,
101 | style: PropTypes.object,
102 | color: PropTypes.array,
103 | dur: PropTypes.number,
104 | backgroundColor: PropTypes.string,
105 | reverse: PropTypes.bool
106 | }
107 |
108 | export default BorderBox
109 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 1.2.5-alpha (2020-11-15)
2 |
3 | ### New
4 |
5 | - **decoration12:** New decoration(Radar scan).
6 |
7 | ### Optmization
8 |
9 | - **ScrollBoard:** Reduce redundant node rendering.
10 | - **ScrollRankingBoard:** Reduce redundant node rendering.
11 | - **ScrollRankingBoard:** Add value formatter.
12 | - **BorderBox:** Canonical class name.
13 | - **useAutoResize(hooks):** Add exception prompt.
14 | - **Decoration** add `dur` configuration.
15 | - **ActiveRingChart** add `digitalFlopUnit` configuration.
16 |
17 | # 1.2.4-alpha (2020-7-25)
18 |
19 | ### Bug 修复
20 |
21 | - **scrollBoard:** hover Error [(#9)](https://github.com/DataV-Team/DataV-React/issues/9).
22 |
23 | # 1.2.2-alpha (2020-7-04)
24 |
25 | ### Bug 修复
26 |
27 | - **ScrollRankingBoard:** 计算规则调整 [(#101)](https://github.com/DataV-Team/DataV/pull/101).
28 | - **scrollBoard:** key 生成策略调整 [(#8)](https://github.com/DataV-Team/DataV-React/issues/8).
29 | - **uuid:** uuid 生成策略调整 [(#108)](https://github.com/DataV-Team/DataV/issues/108).
30 |
31 | ### Perfect
32 |
33 | - **DigitalFlop:** 添加 `formatter` 配置.
34 |
35 | # 1.2.0-alpha (2020-6-14)
36 |
37 | ### Perfect
38 |
39 | - **BorderBox:** 添加 `backgroundColor` prop.
40 | - **BorderBox8:** 添加 `reverse` prop.
41 | - **DigitalFlop:** 添加 `rowGap` 配置.
42 | - **ScrollBoard:** 添加 `hoverPause` 配置.
43 | - **CapsuleChart:** 添加 `showValue` 配置.
44 | - **ActiveRightChart:** 添加 `showOriginValue` 配置.
45 |
46 | - **uuid:** 使用 `uuid` 生成唯一 id.
47 |
48 | # 1.1.7-alpha (2020-04-10)
49 |
50 | ### BUG 修复
51 |
52 | - **WaterLevelPond:** 组件切换到后台陷入死循环.
53 | - **CapsuleChart:** 胶囊图数值错误.
54 |
55 | ### Perfect
56 |
57 | - **Component:** 内部使用 useImperativeHandle 的组件默认经过 forwardRef 返回.
58 |
59 | # 1.1.3-alpha (2020-01-17)
60 |
61 | ### BUG 修复
62 |
63 | - **ActiveRingChart:** `parseInt` 精度损失.
64 |
65 | # 1.1.2-alpha (2020-01-10)
66 |
67 | ### Perfect
68 |
69 | - **AtiveRingChart:** 添加 digitalFlopToFixed 配置项.
70 |
71 | # 1.1.1-alpha (2020-01-08)
72 |
73 | ### New
74 |
75 | - **FlylineChartEnhanced:** Enhanced flylineChart .
76 |
77 | # 1.0.10-alpha (2019-12-27)
78 |
79 | ### Perfect
80 |
81 | - **ScrollRankingBoard:** 配置项 sort 控制是否自动排序.
82 | - **ScrollRankingBoard:** 通过 dangerouslySetInnerHTML 渲染 name 数据.
83 |
84 | # 1.0.8-alpha (2019-12-17)
85 |
86 | ### Feature
87 |
88 | - **BorderBox & Decoration:** **Configurable** color.
89 |
90 | ```html
91 |
92 |
93 |
94 | ```
95 |
96 | - **ScrollBoard:** 配置 header index.
97 |
98 | ### New
99 |
100 | - **borderBox11**
101 | - **borderBox12**
102 | - **borderBox13**
103 | - **decoration11**
104 |
105 | # 1.0.7-alpha (2019-10-25)
106 |
107 | ### Perfect
108 |
109 | - **co:** 优化 Generator 异常.
110 | - **export:** 导出 co, useAutoResize.
111 |
112 | # 1.0.5-alpha (2019-10-24)
113 |
114 | ### Perfect
115 |
116 | - **Charts:** 优化内存泄漏.
117 | - **DigitalFlop:** 优化内存泄漏.
118 |
119 | # 1.0.4-alpha (2019-10-24)
120 |
121 | ### Bug 修复
122 |
123 | - **ActiveRingChart:** 优化内存泄漏.
124 |
125 | # 1.0.2-alpha (2019-09-27)
126 |
127 | ### Bug 修复
128 |
129 | - **co:** Generator 自动执行异常.
130 |
131 | ### 优化组件
132 |
133 | - **ActiveRingChart**
134 | - **DigitalFlop**
135 | - **FullScreenContainer**
136 | - **PercentPond**
137 | - **ScrollBoard**
138 | - **ScrollBankingBoard**
139 | - **WaterLevelPond**
140 |
141 | # 1.0.1-alpha (2019-09-24)
142 |
143 | ### Bug 修复
144 |
145 | - **ActiveRingChart:** 由于数据值为 0 而导致计算异常.
146 |
147 | # 1.0.0-alpha (2019-09-23)
148 |
149 | ### 初始化代码
150 |
151 | - **Vue to React:** 转换 **Vue** 组件 为 **React** 组件.
152 |
--------------------------------------------------------------------------------
/src/components/decoration5/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { getPolylineLength, deepMerge } from '@jiaminghi/charts/lib/util'
8 |
9 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
10 |
11 | import useAutoResize from '../../use/autoResize'
12 |
13 | import './style.less'
14 |
15 | const defaultColor = ['#3f96a5', '#3f96a5']
16 |
17 | const Decoration = forwardRef(({ className, dur = 1.2, style, color = [] }, ref) => {
18 | const { width, height, domRef } = useAutoResize(ref)
19 |
20 | function calcSVGData() {
21 | let line1Points = [
22 | [0, height * 0.2],
23 | [width * 0.18, height * 0.2],
24 | [width * 0.2, height * 0.4],
25 | [width * 0.25, height * 0.4],
26 | [width * 0.27, height * 0.6],
27 | [width * 0.72, height * 0.6],
28 | [width * 0.75, height * 0.4],
29 | [width * 0.8, height * 0.4],
30 | [width * 0.82, height * 0.2],
31 | [width, height * 0.2]
32 | ]
33 |
34 | let line2Points = [[width * 0.3, height * 0.8], [width * 0.7, height * 0.8]]
35 |
36 | const line1Length = getPolylineLength(line1Points)
37 | const line2Length = getPolylineLength(line2Points)
38 |
39 | line1Points = line1Points.map(point => point.join(',')).join(' ')
40 | line2Points = line2Points.map(point => point.join(',')).join(' ')
41 |
42 | return { line1Points, line2Points, line1Length, line2Length }
43 | }
44 |
45 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
46 |
47 | const { line1Points, line2Points, line1Length, line2Length } = useMemo(
48 | calcSVGData,
49 | [width, height]
50 | )
51 |
52 | const classNames = useMemo(() => classnames('dv-decoration-5', className), [
53 | className
54 | ])
55 |
56 | return (
57 |
58 |
98 |
99 | )
100 | })
101 |
102 | Decoration.propTypes = {
103 | dur: PropTypes.number,
104 | className: PropTypes.string,
105 | style: PropTypes.object,
106 | color: PropTypes.array
107 | }
108 |
109 | export default Decoration
110 |
--------------------------------------------------------------------------------
/src/components/borderBox1/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
9 |
10 | import useAutoResize from '../../use/autoResize'
11 |
12 | import './style.less'
13 |
14 | const border = ['left-top', 'right-top', 'left-bottom', 'right-bottom']
15 | const defaultColor = ['#4fd2dd', '#235fa7']
16 |
17 | const BorderBox = forwardRef(({ children, className, style, color = [], backgroundColor = 'transparent' }, ref) => {
18 | const { width, height, domRef } = useAutoResize(ref)
19 |
20 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
21 |
22 | const classNames = useMemo(() => classnames('dv-border-box-1', className), [
23 | className
24 | ])
25 |
26 | return (
27 |
28 |
38 |
39 | {border.map(borderName => (
40 |
83 | ))}
84 |
85 |
{children}
86 |
87 | )
88 | })
89 |
90 | BorderBox.propTypes = {
91 | children: PropTypes.node,
92 | className: PropTypes.string,
93 | style: PropTypes.object,
94 | color: PropTypes.array,
95 | backgroundColor: PropTypes.string
96 | }
97 |
98 | export default BorderBox
99 |
--------------------------------------------------------------------------------
/src/components/decoration6/index.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, forwardRef } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util'
8 |
9 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
10 |
11 | import useAutoResize from '../../use/autoResize'
12 |
13 | import { randomExtend } from '../../util'
14 |
15 | import './style.less'
16 |
17 | const defaultColor = ['#7acaec', '#7acaec']
18 |
19 | const svgWH = [300, 35]
20 |
21 | const rowNum = 1
22 | const rowPoints = 40
23 |
24 | const rectWidth = 7
25 | const halfRectWidth = rectWidth / 2
26 |
27 | function getPoints() {
28 | const [w, h] = svgWH
29 |
30 | const horizontalGap = w / (rowPoints + 1)
31 | const verticalGap = h / (rowNum + 1)
32 |
33 | let points = new Array(rowNum)
34 | .fill(0)
35 | .map((foo, i) =>
36 | new Array(rowPoints)
37 | .fill(0)
38 | .map((foo, j) => [horizontalGap * (j + 1), verticalGap * (i + 1)])
39 | )
40 |
41 | return points.reduce((all, item) => [...all, ...item], [])
42 | }
43 |
44 | function getData() {
45 | const [, h] = svgWH
46 |
47 | const heights = new Array(rowNum * rowPoints)
48 | .fill(0)
49 | .map(foo =>
50 | Math.random() > 0.8
51 | ? randomExtend(0.7 * h, h)
52 | : randomExtend(0.2 * h, 0.5 * h)
53 | )
54 |
55 | const minHeights = new Array(rowNum * rowPoints)
56 | .fill(0)
57 | .map((foo, i) => heights[i] * Math.random())
58 |
59 | const randoms = new Array(rowNum * rowPoints)
60 | .fill(0)
61 | .map(foo => Math.random() + 1.5)
62 |
63 | return { heights, minHeights, randoms }
64 | }
65 |
66 | const Decoration = forwardRef(({ className, style, color = [] }, ref) => {
67 | const { width, height, domRef } = useAutoResize(ref)
68 |
69 | function calcSVGData() {
70 | return {
71 | ...getData(),
72 | points: getPoints(),
73 | svgScale: [width / svgWH[0], height / svgWH[1]]
74 | }
75 | }
76 |
77 | const mergedColor = useMemo(() => deepMerge(deepClone(defaultColor, true), color || []), [color])
78 |
79 | const { points, heights, minHeights, randoms, svgScale } = useMemo(
80 | calcSVGData,
81 | [width, height]
82 | )
83 |
84 | const classNames = useMemo(() => classnames('dv-decoration-6', className), [
85 | [className]
86 | ])
87 |
88 | return (
89 |
90 |
128 |
129 | )
130 | })
131 |
132 | Decoration.propTypes = {
133 | className: PropTypes.string,
134 | style: PropTypes.object,
135 | color: PropTypes.array
136 | }
137 |
138 | export default Decoration
139 |
--------------------------------------------------------------------------------
/src/components/capsuleChart/index.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState, useMemo } from 'react'
2 |
3 | import PropTypes from 'prop-types'
4 |
5 | import classnames from 'classnames'
6 |
7 | import { deepMerge } from '@jiaminghi/charts/lib/util/index'
8 |
9 | import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
10 |
11 | import './style.less'
12 |
13 | const defaultConfig = {
14 | /**
15 | * @description Capsule chart data
16 | * @type {Array