【问题标题】:jquery getting x values in sparklinejquery在迷你图中获取x值
【发布时间】:2015-07-02 07:43:30
【问题描述】:

我是 jQuery 新手,正在尝试制作迷你图。我想要的是当鼠标指向图表中的一个点时,应该看到 x 值和 y 值。目前,只有 y 值是可见的。

<script>
    $(document).ready(function () {
        $("#sparkline").sparkline([1, 4, 6, 6, 8, 5, 3, 5], {
            type: 'line',
            height: '200',
            width: '240',
            barWidth: 20,
            barSpacing: 10,
            barColor: '#615c5a',
            fillColor:"white"
        });
    });
</script>

【问题讨论】:

  • 你想在 y 显示中添加 'x' 吗?

标签: jquery sparklines


【解决方案1】:

你可以试试这个:

$('#sparkline').sparkline([1, 4, 6, 6, 8, 5, 3, 5], {
        type: 'line',
        height: '200',
        width: '240',
        barWidth: 20,
        barSpacing: 10,
        barColor: '#615c5a',
        fillColor:"white",          
        tooltipFormatter: function (sparkline, options, fields) {
         return "x: " + fields.x + " y: " + fields.y + "";
        }
 });

Demo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-23
    • 2011-06-08
    • 2016-05-27
    • 2017-01-06
    • 2019-06-12
    • 2021-08-19
    • 1970-01-01
    相关资源
    最近更新 更多