2

我是 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>
4

1 回答 1

3

你可以试试这个:

$('#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 + "";
        }
 });

演示

于 2015-07-02T07:51:53.793 回答