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

'stacked : true' option not available? #4

Open
BarbaraGonthier opened this issue Jan 21, 2021 · 0 comments
Open

'stacked : true' option not available? #4

BarbaraGonthier opened this issue Jan 21, 2021 · 0 comments

Comments

@BarbaraGonthier
Copy link

Hi there,
I've been trying to stack datas on the same bar in a bar chart but keep failing, has anyone ever tryed this option?
Below is my code in my controller:

    $queryTotalPerSeason = $subscriptionRepository->getQueryForTotalPerSeason();

    $totalBuilder
        ->query($queryTotalPerSeason)
        ->addDataSet('totalFemale', 'Femmes', [
            "backgroundColor" => self::TOTAL_PALETTE_F,
        ])
        ->addDataSet('totalMale', 'Hommes', [
            "backgroundColor" => self::TOTAL_PALETTE_H,
        ])

        ->labels('seasonName');
    $totalChart = $totalBuilder->buildChart('total-chart', Chart::BAR);
    $totalChart->pushOptions([
        'scales' => ([
            'xAxes' => ([
                'stacked' => 'true'
            ]),
            'yAxes' => ([
                'stacked' => 'true'
            ]),
        ])
    ]);

Here is my query:
public function getQueryForTotalPerSeason(): string
{
return "SELECT case when subscriber.gender= 'H' then count(subscription.subscriber) else 0 end AS totalMale,
case when subscriber.gender= 'F' then count(subscription.subscriber) else 0 end AS totalFemale,
season.name AS seasonName
FROM App\Entity\Subscription subscription
JOIN App\Entity\Season season
WITH season.id=subscription.season
JOIN App\Entity\Subscriber subscriber
WITH subscriber.id=subscription.subscriber
GROUP BY seasonName, subscriber.gender";
}

I have tryed to 'stacked : true' only on xAxes, only on yAxes, on both , I also tryed to add stack in the addDataSet:
->addDataSet('totalFemale', 'Femmes', [
"backgroundColor" => self::TOTAL_PALETTE_F,
"stack" => "0"
])
But nothing seems to work, I keep having 2 bars side to side, with a duplicate seasonName under each of them.
May this option not be available in this library?
Many thanks for your help

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

1 participant