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

[Bug]: Subtitle is not drawn #109

Open
1 task
athanhat opened this issue May 3, 2023 · 1 comment
Open
1 task

[Bug]: Subtitle is not drawn #109

athanhat opened this issue May 3, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@athanhat
Copy link

athanhat commented May 3, 2023

Would you like to work on a fix?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

Current and expected behavior

In the following Svelte component code the legend of an horizontal barchart is displayed with the registered Title but the registered SubTitle does not appear on the graph

<script lang="ts">
    // @ts-nocheck
    import { Bar } from "svelte-chartjs";
    import {
        Chart,
        Title,
        SubTitle,
        Tooltip,
        Legend,
        BarElement,
        CategoryScale,
        LinearScale,
    } from "chart.js";

    const data = {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [
            {
                label: "% of Votes",
                data: [12, 19, 3, 5, 2, 3],
                backgroundColor: [
                    "rgba(255, 134,159,0.4)",
                    "rgba(98,  182, 239,0.4)",
                    "rgba(255, 218, 128,0.4)",
                    "rgba(113, 205, 205,0.4)",
                    "rgba(170, 128, 252,0.4)",
                    "rgba(255, 177, 101,0.4)",
                ],
                borderWidth: 4,
                borderColor: [
                    "rgba(255, 134, 159, 1)",
                    "rgba(98,  182, 239, 1)",
                    "rgba(255, 218, 128, 1)",
                    "rgba(113, 205, 205, 1)",
                    "rgba(170, 128, 252, 1)",
                    "rgba(255, 177, 101, 1)",
                ],
            },
        ],
    };

    const options = {
        responsive: true,
        maintainAspectRatio: false,

        indexAxis: "y",

        scales: {
            y: {
                grid: {
                    display: false,
                },
                position: "right",
            },
        },

        plugins: {
            legend: {
                display: true,
                title: {
                    display: true,
                    text: "This is the title",
                },
                subtitle: {
                    display: true,
                    text: "This is the subtitle",                    
                },
            },
        },
    };

    Chart.register(
        Title,
        SubTitle,
        Tooltip,
        Legend,
        BarElement,
        CategoryScale,
        LinearScale
    );
</script>

<article>
    <h3>chart.js horizontal barchart</h3>
    <div id="chart-container">
        <Bar {data} {options} />
    </div>
</article>

<style>
    #chart-container {
        width: 100%;
        height: 800px;
        min-height: 200px;
    }
</style>

Reproduction

https://www.chartjs.org/docs/latest/configuration/subtitle.html

chart.js version

4.3.0

svelte-chartjs version

3.1.2

Possible solution

No response

@athanhat athanhat added the bug Something isn't working label May 3, 2023
@niemyjski
Copy link
Collaborator

Can you please submit a pr for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants