javascript - 如何将文本添加到 Highchart 的底部,但在图例上方?

标签 javascript jquery html css highcharts

我想在 Highchart 下面添加一些文本或图像,但它必须出现在 Highchart 图例上方。

我的代码:

$(function () {
    Highcharts.wrap(Highcharts.seriesTypes.bubble.prototype, 'drawPoints', function (proceed) {
        proceed.apply(this);
        for (i in this.data) {
            if(this.data[i].options.x > 90)
            this.data[i].graphic.dashstyleSetter(this.options.dashStyle || 'solid');
        }
    });

    $('#container').highcharts({

        chart: {
            type: 'bubble',
            zoomType: 'xy'
        },

        title: {
            text: 'Highcharts Bubbles'
        },

        series: [{
            dashStyle: 'dash',
            data: [
                [97, 36, 79],
                [94, 74, 60],
                [68, 76, 58],
                [64, 87, 56],
                [68, 27, 73],
                [74, 99, 42],
                [7, 93, 87],
                [51, 69, 40],
                [38, 23, 33],
                [57, 86, 31]
            ],
            marker: {
                lineColor: 'red'
            }
        }]
    });
});

这是我的 JsFiddle:http://jsfiddle.net/qebxk6ty/6/

我想在图表下方但在图例上方添加静态图像或文本以指示虚线气泡的含义。

此答案显示了如何将其添加到图例下方: How do you add text to the bottom center of legend and bottom center of chart under legend?

我不知道如何修改它。

提前致谢。

最佳答案

你可以这样做,

 $('#container').highcharts({
  xAxis: {
      title: {
        text: "DISPLAY WHATEVER YOU WANT TO"
      }
    },

DEMO

编辑

  chart: {
                events: {
                    load: function () {
                        var label = this.renderer.image('http://highcharts.com/demo/gfx/sun.png', 20, 50, 30, 30)
                        .css({
                            width: '450px',
                            color: '#222',
                            fontSize: '16px'
                        })
                        .attr({
                            'stroke': 'silver',
                            'stroke-width': 2,
                            'r': 5,
                            'padding': 10
                        })
                        .add();

                        label.align(Highcharts.extend(label.getBBox(), {
                            align: 'center',
                            x: 0, // offset
                            verticalAlign: 'bottom',
                            y: 50 // offset
                        }), null, 'spacingBox');

                    }
                },

DEMO

关于javascript - 如何将文本添加到 Highchart 的底部,但在图例上方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40589014/

相关文章:

html - 我可以使用哪个元素代替具有相同属性的表?

javascript - 从 Azure 函数提供 HTML 文件时出错

javascript - MDN bind polyfill 中一行的解释

javascript - 图表js如何在不点击的情况下切换线条

html - 应用 translate3d 时插入符号/文本光标停止

html - 在媒体查询中下载 Assets

javascript - 从 PHP 页面动态值解析到弹出模态框

javascript - 我可以自动将数据附加到链接吗?

jquery - Kendo UI 与 JQuery 更改模板 : <input> to readonly or disable

javascript - &#x00A0 并且无法在 iPad 上运行