Giter VIP home page Giter VIP logo

mukadi-chartjs-builder's People

Contributors

mbo2olivier avatar psyray avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

psyray justera

mukadi-chartjs-builder's Issues

'stacked : true' option not available?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.