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

Incorrect label positioning with stacked charts #9

Open
matmarlow opened this issue Aug 30, 2016 · 0 comments
Open

Incorrect label positioning with stacked charts #9

matmarlow opened this issue Aug 30, 2016 · 0 comments

Comments

@matmarlow
Copy link

When implemented on a stacked bar chart, the labels aren't positioned correctly. The labels for both series are placed where they would be if they started at the bottom. This means the labels on the top bar are too low. For simplicity, the example screenshot has the same values for each series so they appear together. The labels are also BEHIND the bars.

screen shot 2016-08-30 at 14 23 01

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Labels Example</title>


    <script type='text/javascript' src="/assets/js/jquery-2.1.3.min.js"></script>
    <script type='text/javascript' src='/assets/plugins/charts-flot/jquery.flot.min.js'></script>
    <script type="text/javascript" src='/assets/plugins/charts-flot/jquery.flot.labels.js'></script>
    <script type='text/javascript' src='/assets/plugins/charts-flot/jquery.flot.stack.min.js'></script>

    <script type="text/javascript">
$(function () {

            var options = {
                axisLabels: {show: true},
                series: {
                    stack: true,
                    bars: {
                        show: true,
                        barWidth: 0.9,
                        lineWidth: 0,
                        align: "center",
                        order:1
                    }
                },
                colors: ["#ad1986", "#2ea5b4"]
            };

            var data = [
                {
                    points: { show: true },
                    showLabels: true,
                    labels: ["Alpha","Beta","Gamma","Delta","Epsilon","Zeta","Eta","Theta"],
                    labelPlacement: "left",
                    canvasRender: true,
                    cColor: "#AD8200",
                    data:[ [1, 44],[2, 64],[3, 422],[4, 591],[5, 428],[6, 317],[7, 377],[8, 484]]
                },

                {
                    points: { show: true },
                    showLabels: true,
                    labels: ["Alpha","Beta","Gamma","Delta","Epsilon","Zeta","Eta","Theta"],
                    labelPlacement: "right",
                    canvasRender: true,
                    cColor: "#AD8200",
                    data:[ [1, 44],[2, 64],[3, 422],[4, 591],[5, 428],[6, 317],[7, 377],[8, 484]]
                }
            ];

            $.plot($("#placeholder"), data, options);
        });
    </script>
</head>
<body>
<div id="placeholder" style="width:500px; height:350px"></div>

</body>
</html>
@matmarlow matmarlow changed the title Not working with stacked charts Incorrect label positioning with stacked charts Aug 30, 2016
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