Skip to content

Commit 4311388

Browse files
committed
init
0 parents  commit 4311388

24 files changed

+7071
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
phpunit.phar
3+
/vendor
4+
composer.phar
5+
composer.lock
6+
*.project
7+
.idea/

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Jens cyd622
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
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, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Use Echarts in laravel-admin
2+
======
3+
4+
## Screenshot
5+
6+
![ATUBAe.md.jpg](https://s2.ax1x.com/2019/04/10/ATUBAe.jpg)
7+
## Installation
8+
9+
```bash
10+
composer require cyd622/laravel-admin-ext-echarts
11+
12+
php artisan vendor:publish --tag=echarts
13+
```
14+
15+
## Configuration
16+
17+
Open `config/echarts.php`, set configurations .
18+
19+
```php
20+
21+
[
22+
'view' => 'echarts::index',
23+
'water_mark_text' => 'Cyd622@Laravel-Admin',
24+
'theme' => 'shine',
25+
];
26+
27+
```
28+
29+
> * `view` set the view
30+
> * `water_mark_text` set the watermark. if value is `null` or `''` will not use watermark
31+
> * `theme` set the echarts theme
32+
33+
## Usage
34+
35+
Add following codes in your controller :
36+
```php
37+
public function index(Content $content)
38+
{
39+
$json = '[{"count_date":"03-28","fans_num":5906,"article_num":363,"forward_num":27928,"comment_num":9123,"like_num":35632},{"count_date":"03-29","fans_num":9565,"article_num":361,"forward_num":16755,"comment_num":7193,"like_num":36540}]';
40+
41+
$jsonArr = json_decode($json, 1);
42+
// bindData
43+
$head = [
44+
'count_date' => '日期',
45+
'fans_num' => '粉丝',
46+
'comment_num' => '评论',
47+
'article_num' => '文章',
48+
'forward_num' => '转发',
49+
'like_num' => '点赞',
50+
];
51+
$echarts = (new Echarts('柱状图', '数据来自新浪云大数据平台'))
52+
->setData($jsonArr)
53+
->bindLegend($head);
54+
55+
return $content
56+
->header('Echarts demo')
57+
->description('百度echarts图表展示')
58+
->body(new Box('折线图', $echarts));
59+
60+
}
61+
```
62+
63+
64+
For more usage, please refer to the official [documentation](https://www.echartsjs.com/tutorial.html) of echartsjs.
65+
66+
67+
License
68+
------------
69+
Licensed under [The MIT License (MIT)](LICENSE).

composer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "cyd622/laravel-admin-ext-echarts",
3+
"description": "Use Echarts in laravel-admin",
4+
"type": "library",
5+
"keywords": ["laravel-admin", "extension", "echarts"],
6+
"homepage": "https://github.com/cyd622/laravel-admin-ext-echarts",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "cyd622",
11+
"email": "luffywang622@gmail.com"
12+
}
13+
],
14+
"require": {
15+
"php": ">=7.0.0",
16+
"encore/laravel-admin": "~1.6"
17+
},
18+
"require-dev": {
19+
"phpunit/phpunit": "~6.0"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"Encore\\Admin\\Widgets\\Echarts\\": "src/"
24+
}
25+
},
26+
"extra": {
27+
"laravel": {
28+
"providers": [
29+
"Encore\\Admin\\Widgets\\Echarts\\EchartsServiceProvider"
30+
]
31+
32+
}
33+
}
34+
}

config/config.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
return [
4+
'view' => 'echarts::index',
5+
'water_mark_text' => 'Cyd622@Laravel-Admin',
6+
'theme' => 'shine',
7+
];

resources/assets/draw.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
let echartTheme = null;
2+
let waterMarkCanvas = null;
3+
4+
function drawWaterMark(waterMarkText) {
5+
let waterMarkCanvas = document.createElement('canvas');
6+
let ctx = waterMarkCanvas.getContext('2d');
7+
waterMarkCanvas.width = 220;
8+
waterMarkCanvas.height = 200;
9+
ctx.textAlign = 'center';
10+
ctx.textBaseline = 'middle';
11+
ctx.globalAlpha = 0.07;
12+
ctx.font = '20px Microsoft Yahei';
13+
ctx.translate(130, 90);
14+
ctx.rotate(-Math.PI / 4);
15+
ctx.fillText(waterMarkText, 0, 0);
16+
return waterMarkCanvas;
17+
}
18+
19+
function drawEcharts(domId, option) {
20+
21+
if (waterMarkCanvas) {
22+
option.backgroundColor = {
23+
type: 'pattern',
24+
image: waterMarkCanvas,
25+
repeat: 'repeat'
26+
};
27+
}
28+
if (option.dataZoom) {
29+
option.grid.bottom = '18%';
30+
}
31+
let dom = document.getElementById(domId);
32+
let myChart = echarts.init(dom, echartTheme);
33+
myChart.showLoading();
34+
setTimeout(function () {
35+
myChart.hideLoading();
36+
myChart.setOption(option, true);
37+
}, 200);
38+
}

resources/assets/echarts.min.js

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)