0

这是javascript中的图形代码:

Highcharts.chart(here, {
        exporting: {
            enabled: false
        },
        chart: {
            type: "bar",
            //width: 300,
            //height: 60,
            width: 800,
            height: 160,
            margin: [0, 0, 0, 0]
        },
        title: {
            text: null
        },

        xAxis: {
            categories: ["Default category name"],
            title: {
                text: "testo uno"
            },
            //labels: {
            //    enabled: true
            //},
            opposite: true,
            tickInterval: 1
        },
        yAxis: {
            max: maximum,
            min: 0,
            title: {
                text: "testo due"
            }
            //labels: {
            //    enabled: true
            // }
        },
        tooltip: {
            enabled: true,
            valueSuffix: " millions"
        },
        plotOptions: {
            series: {
                pointPadding: 0.3,
                groupPadding: 0.1,
                animation: false
            }
        },
        legend: {
            enabled: false
        },
        credits: {
            enabled: false
        },
        series: [
            {
                name: "Name number one",
                data: [v1],
                color: "rgb(251, 147, 53)"
            },
            {
                name: "Name number two",
                data: [v2],
                color: "rgb(128, 128, 128)"
            },
            {
                name: "Name number three",
                data: [v3],
                color: "rgb(137, 196, 76)"
            }
        ]
    });

我希望默认刻度的标签显示在顶部。我似乎无法得到这些,我尝试将标签{启用}设置为 false,以及其他一些东西,但我似乎无法让刻度的标签显示在顶部。请查看随附的屏幕截图以查看我想要的刻度。有什么建议么? 在此处输入图像描述

4

1 回答 1

1

您需要为标签腾出空间,例如保持默认边距并设置yAxis.opposite为 true。

在 API 中,我们可以阅读:

边距:数字,数组。

...

默认情况下没有边距。除了spacingTop、spacingRight、spacingBottom 和spacingLeft 选项外,实际空间是根据轴标签、轴标题、标题、副标题和图例的偏移量动态计算的。

    yAxis: {
        opposite: true,
        ...
    }

现场演示:http: //jsfiddle.net/BlackLabel/9rgjdesw/

API参考:

https://api.highcharts.com/highcharts/chart.margin

https://api.highcharts.com/highcharts/xAxis.opposite

于 2020-12-14T10:48:10.083 回答