Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Laravel 5.5无法使用ConsoleTV';s图表包_Javascript_Php_Mysql_Laravel_Dynamic - Fatal编程技术网

Javascript Laravel 5.5无法使用ConsoleTV';s图表包

Javascript Laravel 5.5无法使用ConsoleTV';s图表包,javascript,php,mysql,laravel,dynamic,Javascript,Php,Mysql,Laravel,Dynamic,为什么我不能从我的数据库生成数据?我可以渲染图表,但没有显示数据。但当我转储数据时,它会显示数据的数组。我们将不胜感激。谢谢。此处的图表输出: PS:我想在我的第二个数据库中获取数据。这就是为什么模型中有“mysql2” GraphController.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\User; use Illuminate\Support\Facades\DB

为什么我不能从我的数据库生成数据?我可以渲染图表,但没有显示数据。但当我转储数据时,它会显示数据的数组。我们将不胜感激。谢谢。此处的图表输出:

PS:我想在我的第二个数据库中获取数据。这就是为什么模型中有“mysql2”

GraphController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Illuminate\Support\Facades\DB;
use View;
use App\News;
use Charts;
use App\Graph;

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



        $graph = Charts::database(Graph::find(1),'line','highcharts')
        ->title('Tokens')
        ->ElementLabel('Coins Sold')
        ->Responsive(true)
        ->dimensions(1000,500)
        ->data(Graph::find(1));

        dd($graph);

        $news = News::all();


        // //dd($news);
        return View::make('coin.news', compact('graph','news'));
    }
}
app.blade.php




@section('graph')



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



@endsection
stylesheets....

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

@yield('graph')

news...

scripts...

当我使用dd($graph)时,它显示了这一点。我还可以看到要在图表中呈现的数据

Database {#299 ▼
  +data: Graph {#306 ▼
    #connection: "mysql2"
    #table: "ico_stages"
    #primaryKey: "id"
    #keyType: "int"
    +incrementing: true
    #with: []
    #withCount: []
    #perPage: 15
    +exists: true
    +wasRecentlyCreated: false
    #attributes: array:18 [▼
      "id" => 1
      "name" => "Stage 1"
      "start_date" => "2019-05-11 21:29:00"
      "end_date" => "2019-11-30 21:29:00"
      "total_tokens" => 10000000
      "base_price" => 2.0
      "min_purchase" => 100
      "max_purchase" => 10000
      "soft_cap" => 0
      "hard_cap" => 0
      "display_mode" => "normal"
      "private" => 0
      "user_panel_display" => 0
      "sales_token" => 1496.0
      "sales_amount" => 2720.0
      "status" => "active"
      "created_at" => "2019-05-12 05:29:57"
      "updated_at" => "2019-06-19 06:02:55"
    ]
    #original: array:18 [▼
      "id" => 1
      "name" => "Stage 1"
      "start_date" => "2019-05-11 21:29:00"
      "end_date" => "2019-11-30 21:29:00"
      "total_tokens" => 10000000
      "base_price" => 2.0
      "min_purchase" => 100
      "max_purchase" => 10000
      "soft_cap" => 0
      "hard_cap" => 0
      "display_mode" => "normal"
      "private" => 0
      "user_panel_display" => 0
      "sales_token" => 1496.0
      "sales_amount" => 2720.0
      "status" => "active"
      "created_at" => "2019-05-12 05:29:57"
      "updated_at" => "2019-06-19 06:02:55"
    ]
    #changes: []
    #casts: []
    #dates: []
    #dateFormat: null
    #appends: []
    #dispatchesEvents: []
    #observables: []
    #relations: []
    #touches: []
    +timestamps: true
    #hidden: []
    #visible: []
    #fillable: []
    #guarded: array:1 [▶]
  }
  +date_column: "created_at"
  +date_format: "l dS M, Y"
  +month_format: "F, Y"
  +hour_format: "D, M j, Y g A"
  +language: "en"
  +preaggregated: false
  +aggregate_column: null
  +aggregate_type: null
  +value_data: []
  +id: null
  +customId: null
  +type: "line"
  +library: "highcharts"
  +title: "Tokens"
  +element_label: "Coins Sold"
  +labels: []
  +values: []
  +colors: []
  +responsive: true
  +gauge_style: "left"
  +view: null
  +region: "world"
  #suffix: ""
  +container: ""
  +credits: false
  +loader: true
  +loader_duration: 500
  +loader_color: "#000000"
  +background_color: "inherit"
  +template: "material"
  +one_color: false
  +legend: true
  +x_axis_title: false
  +y_axis_title: null
  +script: ""
  +html: ""
  +export: null
  +"height": 500
  +"width": 1000
}

在图形模板中呈现数据的步骤

$graph = view('graph')->with('graph', $graph); 
以及将渲染数据返回到新闻

return view('coin.news', compact('graph','news'));
最终代码

    $graph = Charts::database(Graph::find(1),'line','highcharts')
    ->title('Tokens')
    ->ElementLabel('Coins Sold')
    ->Responsive(true)
    ->dimensions(1000,500)
    ->data(Graph::find(1));



    $news = News::all();

    $graph = view('graph')->with('graph', $graph); 

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

它向我抛出了一个错误sir=>ErrorException(E_error)调用string上的成员函数render(),它工作了吗?如果是,请分享答案或标记答案,请参见。是的,对我有效。我想出来了,下面的答案?
    $graph = Charts::database(Graph::find(1),'line','highcharts')
    ->title('Tokens')
    ->ElementLabel('Coins Sold')
    ->Responsive(true)
    ->dimensions(1000,500)
    ->data(Graph::find(1));



    $news = News::all();

    $graph = view('graph')->with('graph', $graph); 

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