highcharts 折线图中的缺失值导致没有线,只有点

编程入门 行业动态 更新时间:2024-10-11 15:21:44
本文介绍了highcharts 折线图中的缺失值导致没有线,只有点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

请看这个:

http://jsfiddle/2rNzr/

var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        data: [29.9, '', 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]

});

您会注意到数据中有一个空白值(第二个值),这会导致折线图显示不正确.

you'll notice that the data has a blank value in it (the second value), which causes the line graph to display incorrectly.

这是一个错误吗?

指定缺失值以便折线图中会有间隙的正确方法是什么?即我不希望折线图简单地在点 1 和 3 之间画一条线.

What is the correct way of specifying a missing value so there will be a gap in the line graph? i.e. I would NOT want the line graph to simply draw a line between points 1 and 3.

非常感谢您制作了出色的产品!

Many thanks for producing an excellent product!

托尼.

推荐答案

您需要将缺失值更改为 null,并指定您想要一条穿过现有值的线/样条.

You will need to change your missing values to null, and specify that you want a line/spline through the existing values.

var chart = new Highcharts.Chart({

    chart: {
        defaultSeriesType: 'line',
        renderTo: 'container'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        data: [29.9, null, 106.4, 129.2, 144.0, 176.0, null, 148.5, 216.4, 194.1, 95.6, 54.4],
    }]

});

参见 http://jsfiddle/xynZT/,以 defaultSeriesType: 'spline' 为例.

see http://jsfiddle/xynZT/ with defaultSeriesType: 'spline' as an example.

这篇关于highcharts 折线图中的缺失值导致没有线,只有点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-01 09:14:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/826320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:折线   缺失   图中   highcharts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!