Skip to content

Commit

Permalink
first init
Browse files Browse the repository at this point in the history
  • Loading branch information
Flatroy committed Jul 19, 2022
0 parents commit 95a3413
Show file tree
Hide file tree
Showing 19 changed files with 518 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.idea
/vendor
/node_modules
package-lock.json
composer.phar
composer.lock
phpunit.xml
.phpunit.result.cache
.DS_Store
Thumbs.db
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 George Daneke

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
107 changes: 107 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Nova Threemap Chart Card


This package allows you to add three-map fields to your resource details page and dashboards in [Nova](https://nova.laravel.com).

It basically takes a field with a decimal value between 0 and 1 and shows it as a percentage progress bar.

To edit a field, we recommend using the standard Number (\Laravel\Nova\Fields\Number) field.

<img src="https://github.com/flatroy/nova-progressbar-field/blob/main/img/img.png" alt="example">

#### DISCLAIMER:

This package is still work in progress. Feel free to help improve it.

- [Requirements](#requirements)
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Advanced Options](#advanced-options)

---

## Requirements

- [Laravel v9.0.\*](https://laravel.com/docs/9.0)
- [Laravel Nova v4.\*](https://nova.laravel.com/docs/4.0/)

---

## Installation

Just run:

```bash
composer require flatroy/nova-treemap-chart-card
```

After this the setup will be complete, you can use the components listed here.

---

## Basic Usage

```php
// in App\Nova\User
...
use Flatroy\FieldProgressbar\FieldProgressbar;
use Laravel\Nova\Fields\Number;
...

/**
* Get the fields displayed by the resource.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array
*/
public function fields(NovaRequest $request)
{
$data = [
['x' => 'Design', 'y' => 0.051],
['x' => 'Accounting', 'y' => 0.050],
['x' => 'Data Science', 'y' => 0.048],
['x' => 'Marketing', 'y' => 0.046],
['x' => 'Quality Assurance', 'y' => 0.046],
['x' => 'R&D', 'y' => 0.046],
];

return [
...
(new NovaTreemapChartCard())
->title('Some custom title')
->series($data)
->onlyOnDetail(),
// or you can use like that:
(new NovaTreemapChartCard())
->title('Some other custom title')
->series($this->model()?->find($request->resourceId)?->chartData)
->onlyOnDetail(),
// or you can suggest how to do it better?
...
];
}


// if you want to put logic inside model - add this inside model:

namespace App\Models;
...
class User extends Model
{
...
protected function getChartDataAttribute()
{
return [
['x' => 'Design', 'y' => 0.051],
['x' => 'Accounting', 'y' => 0.050],
['x' => 'Data Science', 'y' => 0.048],
['x' => 'Marketing', 'y' => 0.046],
['x' => 'Quality Assurance', 'y' => 0.046],
['x' => 'R&D', 'y' => 0.046],
];
}
...
}
```

Feel free to come with suggestions for improvements.
41 changes: 41 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "flatroy/nova-treemap-chart-card",
"description": "A Laravel Nova card to show Treemap charts",
"keywords": [
"laravel",
"nova",
"treemap",
"chart",
"card",
"apexcharts"
],

"license": "MIT",
"authors": [
{
"name": "George Daneke",
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
"php": "^7.4|^8.0"
},
"autoload": {
"psr-4": {
"Flatroy\\NovaTreemapChartCard\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Flatroy\\NovaTreemapChartCard\\CardServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
1 change: 1 addition & 0 deletions dist/css/card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions dist/js/card.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions dist/js/card.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*!
* ApexCharts v3.35.3
* (c) 2018-2022 ApexCharts
* Released under the MIT License.
*/

/*! svg.draggable.js - v2.2.2 - 2019-01-08
* https://github.com/svgdotjs/svg.draggable.js
* Copyright (c) 2019 Wout Fierens; Licensed MIT */

/*! svg.filter.js - v2.0.2 - 2016-02-24
* https://github.com/wout/svg.filter.js
* Copyright (c) 2016 Wout Fierens; Licensed MIT */
4 changes: 4 additions & 0 deletions dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"/js/card.js": "/js/card.js",
"/css/card.css": "/css/card.css"
}
Binary file added img/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions nova.mix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const mix = require('laravel-mix');
const webpack = require('webpack');
const path = require('path');

class NovaExtension {
name() {
return 'nova-extension';
}

register(name) {
this.name = name;
}

webpackConfig(webpackConfig) {
webpackConfig.externals = {
vue: 'Vue',
};

webpackConfig.resolve.alias = {
...(webpackConfig.resolve.alias || {}),
'laravel-nova': path.join(__dirname, '../../vendor/laravel/nova/resources/js/mixins/packages.js'),
};

webpackConfig.output = {
uniqueName: this.name,
};
}
}

mix.extend('nova', new NovaExtension());
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"nova:install": "npm --prefix='../../vendor/laravel/nova' ci"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.2.22",
"laravel-mix": "^6.0.41",
"postcss": "^8.3.11",
"vue-loader": "^16.8.3"
},
"dependencies": {
"apexcharts": "^3.35.3",
"vue3-apexcharts": "^1.4.1"
}
}
1 change: 1 addition & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
1 change: 1 addition & 0 deletions resources/css/card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Nova Card CSS */
5 changes: 5 additions & 0 deletions resources/js/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Card from './components/Card';

Nova.booting((app, store) => {
app.component('nova-treemap-chart-card', Card);
});
Loading

0 comments on commit 95a3413

Please sign in to comment.