jQWidgets Forums

jQuery UI Widgets Forums Chart Show sum in Chart with multiple series

This topic contains 5 replies, has 3 voices, and was last updated by  kantorg 9 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Show sum in Chart with multiple series #7599

    Robin Kluth
    Member

    Hi 🙂

    I have a stackedcolumn chart with 4 series.
    I can see the direct value if I hover one, but how to show the sum of all in one column?

    Thanks!

    Show sum in Chart with multiple series #7646

    Dimitar
    Participant

    Hello Commifreak,

    Unfortunately, it is not possible to show the sum of all values in a stacked column.

    Best Regards,
    Dimitar

    jqWidgets team
    http://www.jqwidgets.com/

    Show sum in Chart with multiple series #7655

    Robin Kluth
    Member

    Thanks for your reply.

    But this could be a nice feature for future versions 🙂

    Thanks for your help!

    Show sum in Chart with multiple series #79238

    kantorg
    Participant

    Hi Dimitar!

    3 years past, is it still not possible??

    Thanks in advance!

    Show sum in Chart with multiple series #79254

    Dimitar
    Participant

    Hi kantorg,

    Here is the solution we can offer you at the moment:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script>
        <script type="text/javascript" src="../../../jqwidgets/jqxdraw.js"></script>
        <script type="text/javascript" src="../../../jqwidgets/jqxchart.core.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                // prepare chart data as an array
                var sampleData = [
                        { Day: 'Monday', Running: 30, Swimming: 0, Cycling: 25 },
                        { Day: 'Tuesday', Running: 25, Swimming: 25, Cycling: 0 },
                        { Day: 'Wednesday', Running: 30, Swimming: 0, Cycling: 25 },
                        { Day: 'Thursday', Running: 35, Swimming: 25, Cycling: 45 },
                        { Day: 'Friday', Running: 0, Swimming: 20, Cycling: 25 },
                        { Day: 'Saturday', Running: 30, Swimming: 0, Cycling: 30 },
                        { Day: 'Sunday', Running: 60, Swimming: 45, Cycling: 0 }
                    ];
    
                // prepare jqxChart settings
                var settings = {
                    title: "Fitness & exercise weekly scorecard",
                    description: "Time spent in vigorous exercise by activity",
                    enableAnimations: true,
                    showLegend: true,
                    padding: { left: 5, top: 5, right: 5, bottom: 5 },
                    titlePadding: { left: 90, top: 0, right: 0, bottom: 10 },
                    source: sampleData,
                    xAxis:
                        {
                            dataField: 'Day',
                            unitInterval: 1,
                            axisSize: 'auto',
                            tickMarks: {
                                visible: true,
                                interval: 1,
                                color: '#BCBCBC'
                            },
                            gridLines: {
                                visible: true,
                                interval: 1,
                                color: '#BCBCBC'
                            },
                            labels: { visible: true,
                                formatFunction: function (value, index) {
                                    var currentDayData = sampleData[index],
                                        total = currentDayData.Running + currentDayData.Swimming + currentDayData.Cycling;
                                    return value + '<br> (Total: ' + total + ')';
                                }
                            }
                        },
                    valueAxis:
                    {
                        unitInterval: 10,
                        minValue: 0,
                        maxValue: 120,
                        title: { text: 'Time in minutes' },
                        labels: { horizontalAlignment: 'right' },
                        tickMarks: { color: '#BCBCBC' }
                    },
                    colorScheme: 'scheme06',
                    seriesGroups:
                        [
                            {
                                type: 'stackedcolumn',
                                columnsGapPercent: 50,
                                seriesGapPercent: 0,
                                series: [
                                        { dataField: 'Running', displayText: 'Running' },
                                        { dataField: 'Swimming', displayText: 'Swimming' },
                                        { dataField: 'Cycling', displayText: 'Cycling' }
                                    ]
                            }
                        ]
                };
    
                // setup the chart
                $('#chartContainer').jqxChart(settings);
    
            });
        </script>
    </head>
    <body class='default'>
        <div id='chartContainer' style="width: 850px; height: 500px;" />
    </body>
    </html>

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Show sum in Chart with multiple series #79553

    kantorg
    Participant

    Hey Dimitar,

    Thank you, excellent job!

    Kind regards,
    kantorg

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.