首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在每个列的顶部显示值| Hightcharts | Vue-chartkick | Cube Js

如何在每个列的顶部显示值| Hightcharts | Vue-chartkick | Cube Js
EN

Stack Overflow用户
提问于 2019-10-10 20:35:50
回答 2查看 707关注 0票数 1

我使用Vue chartkick和highcharts来可视化柱状图。我想在每个列栏的顶部显示值。帮我完成它。

https://imgur.com/ehIQJAd

上面的链接是我输出的图像。

代码语言:javascript
复制
<template>
    <column-chart lable="value" :min="0" :refresh="60" height="400px" 
     xtitle="City" :data="series" :library="values"></column-chart>
<template>

下面的代码是我的脚本。我正在使用Vue.js

代码语言:javascript
复制
<script>
   data(){
        return{
            values: {
                borderWidth: 10,
                dataLabels: {
                    enabled: true
                }
            }
        }
    },
</script> 

我的期望如下

https://imgur.com/cGIi6Ul

EN

回答 2

Stack Overflow用户

发布于 2019-10-10 23:42:32

尝试添加

Label=“值”

到你的柱状图,

代码语言:javascript
复制
<column-chart :min="0" :refresh="60" height="400px" xtitle="City" 
:data="series" label="Value"></column-chart>
票数 0
EN

Stack Overflow用户

发布于 2019-10-11 03:01:20

我让它在这里工作:https://codepen.io/torkelv/pen/abbvLWy

这基本上是一种黑客行为,但不幸的是,没有简单的方法来做到这一点。

通过使用pluginservice:

代码语言:javascript
复制
Chart.pluginService.register({
    beforeRender: function(chart) {
        if (chart.config.options.showAllTooltips) {
            chart.pluginTooltips = [];
            chart.config.data.datasets.forEach(function(dataset, i) {
                chart.getDatasetMeta(i).data.forEach(function(sector, j) {
                    chart.pluginTooltips.push(new Chart.Tooltip({
                        _chart: chart.chart,
                        _chartInstance: chart,
                        _data: chart.data,
                        _options: chart.options.tooltips,
                        _active: [sector]
                    }, chart));
                });
            }); // turn off normal tooltips 
            chart.options.tooltips.enabled = false;
        }
    },
    afterDraw: function(chart, easing) {
        if (chart.config.options.showAllTooltips) {
            // we don't want the permanent tooltips to animate, so don't do anything till the animation runs atleast once 
            if (!chart.allTooltipsOnce) {
                if (easing !== 1) return;
                chart.allTooltipsOnce = true;
            }
            chart.options.tooltips.enabled = true;
            Chart.helpers.each(chart.pluginTooltips, function(tooltip) {
                tooltip.initialize();
                tooltip.update(); // we don't actually need this since we are not animating tooltips 
                tooltip.pivot();
                tooltip.transition(easing).draw();
            });
            chart.options.tooltips.enabled = false;
        }
    }

然后将options: { showAllTooltips: true, }添加到图表中。

来源:https://github.com/chartjs/Chart.js/issues/1861

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58323033

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档