【问题标题】:Cant populate dataset from database using ConsoleTV's chart package in laravel 5.5无法使用 laravel 5.5 中的 ConsoleTVs 图表包从数据库中填充数据集
【发布时间】:2019-11-05 19:41:45
【问题描述】:

为什么我不能从我的数据库中填充数据集?我可以渲染图表,但没有显示数据。但是当我在 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');

【问题讨论】:

  • 回答任何人?请帮忙..非常需要它

标签: javascript php laravel charts package


【解决方案1】:

你可以试试这个

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

而不是

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

【讨论】:

  • 它给我一个错误先生.. 调用未定义的方法 App\Graph::filter()
  • 您的模型有错误吗?你能试试这个return view('coin.news', compact('chart'));
  • 先生,仍然没有数据显示。
  • 还想帮忙吗?
【解决方案2】:

试试

return view('coin.news', compact('chart'));

【讨论】:

  • 它给了我这个错误先生:未定义的变量:图表
  • 你能分享 coin.news 刀片吗?您尝试呈现 html 的位置。
  • 先生您是什么意思?
  • 根据您的代码,您将数据发送到新闻文件,该文件会将数据呈现为图形文件,因此您可以共享新闻刀片文件吗?。
  • 请解释该代码的作用,以及为什么您认为它可以解决问题。简单地说“试试这个”并不能帮助 OP 从你的答案中学习
猜你喜欢
  • 2014-10-23
  • 2022-08-19
  • 2021-06-30
  • 1970-01-01
  • 2018-10-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多