Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Type doughnut & options #19

Open
peresz opened this issue Jul 26, 2016 · 9 comments
Open

Type doughnut & options #19

peresz opened this issue Jul 26, 2016 · 9 comments
Labels

Comments

@peresz
Copy link

peresz commented Jul 26, 2016

After upgrade chartjs to latest version I have problem with defining width and height of chart.

$chart = ChartJs::widget([ 'type' => 'doughnut', 'options' => [ 'id' => 'cstat', 'cutoutPercentage' => 25, 'legend' => [ 'display' => false], 'height' => 150, 'width' => 150 ], 'data' => $dt, ]);

I see that options: cutoutPercentage, height, width not works. Is there any problems or I have to do it in other way?

@peresz
Copy link
Author

peresz commented Jul 26, 2016

I've found solution, here result:

$chart = ChartJs::widget([
        'type' => 'doughnut',
        'options' => [
                'id' => 'cstat',
                'width' => 155,
                'height' => 155,
        ],
        '**clientOptions**' => [
                'responsive' => false,
                'legend' => [ 'display'=> false ],
                'cutoutPercentage' => 45,
                'animation' => [
                        'animateRotate' => false,
                        'animateScale' => true,
                        'duration' => 369,
                ],
        ],
        'data' => $dt,
]);

@tonydspaniard
Copy link
Member

Thanks @peresz

@razoramon
Copy link

razoramon commented Mar 17, 2017

Thanks for the great code 2amigos and all.
I was not able to find a suitable sample in the docs so here is mine :

<?= ChartJs::widget([
    'type' => 'line',
    'data' => [
        'labels' => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        'datasets' => [
            [
                'label' => 'level',
                'data' => [0, 1, 2, 3, 4, 6, 5, 12 , 17, 50, 100],
            ]
        ],
    ],
    'options' => [
        'height' => 200,
        'width' => 500,
    ],
    'clientOptions' => [
        'title' => [
            'display' => true,
            'text' => 'Chart from the absolute beginner: definitive edition (remastered)'            
        ],
        'scales' => [
                'yAxes' => [
                    [
                        'scaleLabel' => [
                            'display' => 'true',
                            'labelString' => 'level'
                        ]
                    ]
                ],
                'xAxes' => [
                    [
                        'scaleLabel' => [
                            'display' => 'true',
                            'labelString' => 'time spent'
                        ]
                    ]
                ]
        ],
    ]
]);?>

I cannot stress enough to take very close attention to brackets and which array to put in the options: clientOptions[] or options[].

Thank you for the cool widget. Keep up the good work !

@tonydspaniard
Copy link
Member

@razoramon Thanks... I'll update the widget soon and its docs.

@shashanbk
Copy link

shashanbk commented Dec 7, 2017

Hi I am stuck here can you please help me out ??

<?php echo ChartJs::widget([
    'type' => 'pie',
    'data' => [
        'labels' => ["test","test1","test2","Test3"],
        
        
        'datasets' => [
            [
                'label' => 'level',
                'data' => [10,20,30,40],
                'backgroundColor' => "blue",
                
            ],
        ],
    ],
    'options' => [
        'height' => 200,
        'width' => 500,
    ],
  
]);?>

Here how can i set separate color for every parts test, test1, test2, test3 respectively green,yellow,blue and red ??

@razoramon
Copy link

Hey there,

'backgroundColor' => ['blue', 'red', 'yellow', 'green'],

I must admit that is not so evident.

Hope this helps.

@shashanbk
Copy link

shashanbk commented Dec 8, 2017 via email

@compugator2
Copy link

Is there a way to show the values of bar graph bars directly on the chart? I need to do this for printout purposes.

@cosoftmoh
Copy link

`'datasets' => [
[
'label' => 'level',
'data' =>$recurance_reservation ,
'backgroundColor' => ['blue', 'red', 'yellow', 'green','Brown','DarkMagenta','GreenYellow','Violet','DodgerBlue','Tomato','Orange','MediumSeaGreen','SlateBlue','DarkViolet ','DarkSlateGrey','blak'],

        ],
    ],`

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

No branches or pull requests

6 participants