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

Trendlines with ColumnChart doesn't work. #333

Open
DeeSouza opened this issue Jan 10, 2021 · 3 comments
Open

Trendlines with ColumnChart doesn't work. #333

DeeSouza opened this issue Jan 10, 2021 · 3 comments

Comments

@DeeSouza
Copy link

DeeSouza commented Jan 10, 2021

What Version?

3.1

Issue

Trendlines with ColumnChart doens't work.

Controller Code (chart creation code)

$lavaChart = Lava::ColumnChart($idChart, $datatable, [
    'title' => $title,
    'height' => 500,
    'chartArea' => [
    	'top' => 35,
    	'bottom' => 100,
    	'height' => '100%',
    ],
    'vAxis' => [
    	'format' => '0'
    ],
    'titlePosition' => 'none',
    'legend' => [
        'position' => 'bottom'
    ],
    'trendlines' => [ 
    	0 => [
	    'type' => 'exponential',
            'color' => 'green',
            'pointsVisible' => true,
            'pointSize' => 3,
            'lineWidth' => 10
        ] 
    ]
]);

View Code

$datatable = Lava::DataTable();
$datatable->addStringColumn('Total');
$datatable->addNumberColumn('Label');

foreach($records as $key => $item){
     $datatable->addRow([$key, $item]);
}

image

@kevinkhill
Copy link
Owner

did you mean?

$datatable = Lava::DataTable();
$datatable->addStringColumn('Label'); // this
$datatable->addNumberColumn('Total'); // and this

foreach($records as $key => $item){
     $datatable->addRow([$key, $item]);
}

@kevinkhill
Copy link
Owner

actually.... I hacked together your example and it seems that maybe the serialization of the options is losing the 0 index...

In:

[
    'title' => $title,
    'height' => 500,
    'chartArea' => [
    	'top' => 35,
    	'bottom' => 100,
    	'height' => '100%',
    ],
    'vAxis' => [
    	'format' => '0'
    ],
    'titlePosition' => 'none',
    'legend' => [
        'position' => 'bottom'
    ],
    'trendlines' => [ 
    	0 => [
	    'type' => 'exponential',
            'color' => 'green',
            'pointsVisible' => true,
            'pointSize' => 3,
            'lineWidth' => 10
        ] 
    ]
]

Out:

{
    "title": "Title!",
    "height": 500,
    "chartArea": {
        "top": 35,
        "bottom": 100,
        "height": "100%"
    },
    "vAxis": {
        "format": "0"
    },
    "titlePosition": "none",
    "legend": {
        "position": "bottom"
    },
    "trendlines": [
        {
            "type": "exponential",
            "color": "green",
            "pointsVisible": true,
            "pointSize": 3,
            "lineWidth": 10
        }
    ]
}

@kevinkhill kevinkhill changed the title Trendlines with ColumnChart doens't work. Trendlines with ColumnChart doesn't work. Aug 21, 2021
@kevinkhill
Copy link
Owner

I think you need to have the X axis as a date/datetime column and use the second for the data. I was able to create a trendline loosely based on what you gave me...
image
image

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