无法使用Laravel 5.5中的ConsoleTV图表包从数据库填充数据集

时间:2019-06-24 02:11:21

标签: javascript php laravel charts package

为什么我不能从数据库中填充数据集?我可以渲染图表,但没有显示数据。但是,当我在laravel中使用“ dd”命令时,它将向我显示数据数组。帮助将不胜感激。谢谢。

这是我现在的输出https://imgur.com/a/eyCVxSn

这是我的控制人

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Illuminate\Support\Facades\DB;


use Charts;
use App\Graph;

class GraphController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

        $chart = Charts::database(Graph::get()->find(1),'line','highcharts')
                 ->title('Tokens')
                 ->ElementLabel('Coins Sold')
                 ->Responsive(true)
                 ->data(Graph::all())

                ;

            //dd($chart);



          return view('coin.news', ['chart' => $chart]);



    }
}

我的Graph.php模型

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Auth;
use Cache;
use Charts;


class Graph extends Model
{
    //

    protected $connection = 'mysql2';
    protected $table = 'ico_stages';



}



我的graph.blade.php




@section('graph')

  {!! $chart->render() !!}

@endsection

我的app.blade.php

Header files...


 {!! Charts::assets() !!}

Content....

Graph Section...

Footers....

web.php

//Landing Page
Route::get('/coin', 'GraphController@index');

2 个答案:

答案 0 :(得分:0)

你能试试这个吗

return view('coin.news', ['chart' => $chart])->render();

代替

return view('coin.news', ['chart' => $chart]);

答案 1 :(得分:0)

尝试

@interface KeyWindow : NSPanel
 @end

@implementation KeyWindow


- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
{
    self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag];

    if ( self )
    {
        [self setOpaque:NO];
        [self setBackgroundColor:[NSColor clearColor]];
        [self setMovableByWindowBackground:TRUE];
        [self setStyleMask:NSBorderlessWindowMask];
        [self setHasShadow:YES];
    }

    return self;
}

- (void) setContentView:(NSView *)aView
{
    aView.wantsLayer            = YES;
    aView.layer.frame           = aView.frame;
    aView.layer.cornerRadius    = 10.0;
    aView.layer.masksToBounds   = YES;

    [super setContentView:aView];


    [super setContentView:aView];


}

- (BOOL)canBecomeKeyWindow {
    return YES;
}


@end