Skip to content

Commit 95a3413

Browse files
committed
first init
0 parents  commit 95a3413

File tree

19 files changed

+518
-0
lines changed

19 files changed

+518
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.idea
2+
/vendor
3+
/node_modules
4+
package-lock.json
5+
composer.phar
6+
composer.lock
7+
phpunit.xml
8+
.phpunit.result.cache
9+
.DS_Store
10+
Thumbs.db

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 George Daneke
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 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,
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 THE
21+
SOFTWARE.

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Nova Threemap Chart Card
2+
3+
4+
This package allows you to add three-map fields to your resource details page and dashboards in [Nova](https://nova.laravel.com).
5+
6+
It basically takes a field with a decimal value between 0 and 1 and shows it as a percentage progress bar.
7+
8+
To edit a field, we recommend using the standard Number (\Laravel\Nova\Fields\Number) field.
9+
10+
<img src="https://github.com/flatroy/nova-progressbar-field/blob/main/img/img.png" alt="example">
11+
12+
#### DISCLAIMER:
13+
14+
This package is still work in progress. Feel free to help improve it.
15+
16+
- [Requirements](#requirements)
17+
- [Installation](#installation)
18+
- [Basic Usage](#basic-usage)
19+
- [Advanced Options](#advanced-options)
20+
21+
---
22+
23+
## Requirements
24+
25+
- [Laravel v9.0.\*](https://laravel.com/docs/9.0)
26+
- [Laravel Nova v4.\*](https://nova.laravel.com/docs/4.0/)
27+
28+
---
29+
30+
## Installation
31+
32+
Just run:
33+
34+
```bash
35+
composer require flatroy/nova-treemap-chart-card
36+
```
37+
38+
After this the setup will be complete, you can use the components listed here.
39+
40+
---
41+
42+
## Basic Usage
43+
44+
```php
45+
// in App\Nova\User
46+
...
47+
use Flatroy\FieldProgressbar\FieldProgressbar;
48+
use Laravel\Nova\Fields\Number;
49+
...
50+
51+
/**
52+
* Get the fields displayed by the resource.
53+
*
54+
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
55+
* @return array
56+
*/
57+
public function fields(NovaRequest $request)
58+
{
59+
$data = [
60+
['x' => 'Design', 'y' => 0.051],
61+
['x' => 'Accounting', 'y' => 0.050],
62+
['x' => 'Data Science', 'y' => 0.048],
63+
['x' => 'Marketing', 'y' => 0.046],
64+
['x' => 'Quality Assurance', 'y' => 0.046],
65+
['x' => 'R&D', 'y' => 0.046],
66+
];
67+
68+
return [
69+
...
70+
(new NovaTreemapChartCard())
71+
->title('Some custom title')
72+
->series($data)
73+
->onlyOnDetail(),
74+
// or you can use like that:
75+
(new NovaTreemapChartCard())
76+
->title('Some other custom title')
77+
->series($this->model()?->find($request->resourceId)?->chartData)
78+
->onlyOnDetail(),
79+
// or you can suggest how to do it better?
80+
...
81+
];
82+
}
83+
84+
85+
// if you want to put logic inside model - add this inside model:
86+
87+
namespace App\Models;
88+
...
89+
class User extends Model
90+
{
91+
...
92+
protected function getChartDataAttribute()
93+
{
94+
return [
95+
['x' => 'Design', 'y' => 0.051],
96+
['x' => 'Accounting', 'y' => 0.050],
97+
['x' => 'Data Science', 'y' => 0.048],
98+
['x' => 'Marketing', 'y' => 0.046],
99+
['x' => 'Quality Assurance', 'y' => 0.046],
100+
['x' => 'R&D', 'y' => 0.046],
101+
];
102+
}
103+
...
104+
}
105+
```
106+
107+
Feel free to come with suggestions for improvements.

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "flatroy/nova-treemap-chart-card",
3+
"description": "A Laravel Nova card to show Treemap charts",
4+
"keywords": [
5+
"laravel",
6+
"nova",
7+
"treemap",
8+
"chart",
9+
"card",
10+
"apexcharts"
11+
],
12+
13+
"license": "MIT",
14+
"authors": [
15+
{
16+
"name": "George Daneke",
17+
"email": "[email protected]",
18+
"role": "Developer"
19+
}
20+
],
21+
"require": {
22+
"php": "^7.4|^8.0"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"Flatroy\\NovaTreemapChartCard\\": "src/"
27+
}
28+
},
29+
"extra": {
30+
"laravel": {
31+
"providers": [
32+
"Flatroy\\NovaTreemapChartCard\\CardServiceProvider"
33+
]
34+
}
35+
},
36+
"config": {
37+
"sort-packages": true
38+
},
39+
"minimum-stability": "dev",
40+
"prefer-stable": true
41+
}

dist/css/card.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

dist/js/card.js

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

dist/js/card.js.LICENSE.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*!
2+
* ApexCharts v3.35.3
3+
* (c) 2018-2022 ApexCharts
4+
* Released under the MIT License.
5+
*/
6+
7+
/*! svg.draggable.js - v2.2.2 - 2019-01-08
8+
* https://github.com/svgdotjs/svg.draggable.js
9+
* Copyright (c) 2019 Wout Fierens; Licensed MIT */
10+
11+
/*! svg.filter.js - v2.0.2 - 2016-02-24
12+
* https://github.com/wout/svg.filter.js
13+
* Copyright (c) 2016 Wout Fierens; Licensed MIT */

dist/mix-manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"/js/card.js": "/js/card.js",
3+
"/css/card.css": "/css/card.css"
4+
}

img/img.png

7.15 KB
Loading

nova.mix.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const mix = require('laravel-mix');
2+
const webpack = require('webpack');
3+
const path = require('path');
4+
5+
class NovaExtension {
6+
name() {
7+
return 'nova-extension';
8+
}
9+
10+
register(name) {
11+
this.name = name;
12+
}
13+
14+
webpackConfig(webpackConfig) {
15+
webpackConfig.externals = {
16+
vue: 'Vue',
17+
};
18+
19+
webpackConfig.resolve.alias = {
20+
...(webpackConfig.resolve.alias || {}),
21+
'laravel-nova': path.join(__dirname, '../../vendor/laravel/nova/resources/js/mixins/packages.js'),
22+
};
23+
24+
webpackConfig.output = {
25+
uniqueName: this.name,
26+
};
27+
}
28+
}
29+
30+
mix.extend('nova', new NovaExtension());

0 commit comments

Comments
 (0)