kevinkhill/lavacharts

Only Text script appears on view

iamkumo26 opened this issue · 5 comments

What Version?

versions : * 3.1.11

Issue

Chart doesn't work, only the text script of Lava.js appears on view.

Controller Code (chart creation code)

    public function chart(){


$population = \Lava::DataTable()->setDateTimeFormat('Y');

$population->addDateColumn('Year')
           ->addNumberColumn('Number of People')
           ->addRow(['2006', 623452])
           ->addRow(['2007', 685034])
           ->addRow(['2008', 716845])
           ->addRow(['2009', 757254])
           ->addRow(['2010', 778034])
           ->addRow(['2011', 792353])
           ->addRow(['2012', 839657])
           ->addRow(['2013', 842367])
           ->addRow(['2014', 873490]);

    $areaChart = \Lava::AreaChart('Population', $population, [
    'title' => 'Population Growth',
    'legend' => [
        'position' => 'in'
    ]
]);
       \Lava::getScriptManager()->bypassLavaJsOutput();
        
        return view('pages.chart');
    }

View Code

<div id="pop_div" ></div>
{{\Lava::render('AreaChart', 'Population', 'pop_div')}}

image

If I remember correctly, you need to use {!! \Lava::render() !!} which is for raw output. Using {{ ... }} filters the output to be "safe"

I followed {!! \Lava::render() !!}} , the text in view is gone but now it displays nothing sir. No chart displaying.

Sorry, I don't know if I was clear enough, you still need your chart info, just change the {{ to {!! and the }} to !!}

Like this:
{!! \Lava::render('AreaChart', 'Population', 'pop_div') !!}

I already did that sir, it doesn't display anything.

closing due to staleness, please create a new issue if you are having trouble.