如何在morris酒吧聊天中显示ykeys中不存在的标签值?

时间:2017-09-08 07:24:58

标签: morris.js

在徘徊在聊天时显示总订单,这很好。它显示是因为包含要绘制的数据系列的标签的字符串列表(对应于ykeys选项中的值)。我想在徘徊在聊天时显示金额,而不是在ykeys上添加它。 以下是我的代码,请检查。

 var order_graph_chat = [
    {order_date: '01', count: 10, amount: 9000},
    {order_date: '02', count: 75, amount: 6500},
    {order_date: '03', count: 50, amount: 4000},
    {order_date: '04', count: 75, amount: 6500},
    {order_date: '05', count: 50, amount: 4000},
    {order_date: '06', count: 75, amount: 6005},
    {order_date: '07', count: 10, amount: 9000},
    {order_date: '08', count: 75, amount: 6500},
    {order_date: '09', count: 50, amount: 4000},
    {order_date: '10', count: 75, amount: 6500},
    {order_date: '11', count: 50, amount: 4000},
    {order_date: '12', count: 75, amount: 6005},
];
$(function () {
    "use strict";
    //BAR CHART
    var bar = new Morris.Bar({
        element: 'bar-chart',
        resize: true,
        data: order_graph_chat,
        barColors: ['#00a65a', '#f56954'],
        xkey: 'order_date',
        ykeys: ['count'],
        labels: ['Total Orders'],
        hideHover: 'auto'
    });
});

下面是悬停在其上的聊天图片。我只想表明金额。

Bar Chart Image

任何人都可以帮助我这样做。提前致谢

1 个答案:

答案 0 :(得分:0)

您可以尝试使用hoverCallback函数,如下所示:

hoverCallback: function(index, options, content) {
      var data = options.data[index];
      content += 'Amount: '+data.amount;
      return content;
  },