Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i put more details into GeoChart #319

Closed
glavaniulian opened this issue Feb 29, 2020 · 2 comments
Closed

How can i put more details into GeoChart #319

glavaniulian opened this issue Feb 29, 2020 · 2 comments

Comments

@glavaniulian
Copy link

glavaniulian commented Feb 29, 2020

What Version?

Run composer show khill/lavacharts if you don't know
Version 3.1

Issue

Please describe the issue.

Hi, I'm trying to do a geo chart with LavaCharts, and I wanted to add more columns.
Like I would like to have Country, Users, Description, Etc. (another column from the database).
I did some code but when I refresh my page appears without the 'Country' label/text

the blade view, here you can see how my data/columns from database are, missing Country, and the description doesn't have a column, it just appears as a label.

Controller Code (chart creation code)

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Khill\Lavacharts\Lavacharts;
use App\Visitor;
class VisitorController extends Controller
{
    public function index(){
        $lava = new Lavacharts;

        $data = Visitor::select( "country as -1","description as 0","users as 1")->get()->toArray();
       
        

        $popularity= $lava->DataTable()
                    ->addStringColumn("Country")    
                    ->addStringColumn("Description")  
                    ->addNumberColumn("Users    ")      
                    ->addRows($data);

        $lava->GeoChart("Popularity", $popularity);

        return view("visitor",["lava"=>$lava]);
    }
}

(Controller)

Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Visitor extends Model
{
    protected $fillable=['country','description','users'];
}

(Model)


blade: 
`
<div  id="visitor" style="width:80%;margin:0 auto;"></div>
<?=$lava->render("GeoChart","Popularity","visitor");?>
`
web.php:
` Route::get('/visitor', 'VisitorController@index')->name('visitor');`






If i do something like this :

  $popularity = $lava->DataTable();

            $popularity->addStringColumn('Country')
                ->addNumberColumn('Popularity')
                ->addStringColumn('Desc')
                ->addRow(array('Germany', 200,'asdad'))
                ->addRow(array('United States', 300,'asdad'))
                ->addRow(array('Brazil', 400,'asdad'))
                ->addRow(array('Canada', 500,'asdad'))
                ->addRow(array('France', 600,'asdad'))
                ->addRow(array('RU', 700,'asdad'));

The error is: Incompatible data table: Error: Table contains more columns than expected (Expecting 2 columns)×
@kevinkhill
Copy link
Owner

Since we use google charts underneath, does this shine any light?

You should be able to add a third column for the tooltip just like in their example.

@kevinkhill
Copy link
Owner

closing due to inactivity. Please open a new issue if needed 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants