首页 > 解决方案 > 高图表样条图未使用单个数据绘制

问题描述

我创建了带有高图表的样条图,它适用于多个数据。但是当我有一个系列记录时,它不会在图表上绘制任何东西。

请检查下面的 jsFiddle 与多个工作正常的数据。 https://jsfiddle.net/6ntu7Ls1/1/

<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px; width: 95%"></div>
Highcharts.chart('container', {
        chart: {
            type: 'areaspline',
            marginTop:  4,
            plotBackgroundColor: '#f2f2f2',
            backgroundColor: '#f2f2f2',
            zoomType: '',
            resetZoomButton: {
                theme: {
                    r: 20
                },
                position: {
                    x: -5,
                    y: 5
                }
            },

        },
       title:{text:''} ,

    xAxis: {
            type: 'datetime',
            dateTimeLabelFormats: {
                millisecond:  '%b-%d-%Y',
                second:  '%b-%d-%Y',
                minute:  '%b-%d-%Y',
                hour:  '%b-%d-%Y',
                day:'%b-%d-%Y',
                week: '%b-%d-%Y',
                month: '%b-%d-%Y',
                year:  '%Y'
            },
            min: 1618444800000,
            max: 1618531200000,
            tickPixelInterval: 150,
            minTickInterval:   undefined,
            tickInterval: null,
            gridLineWidth: 0,
            lineWidth: 0,

        },
        yAxis: {
            title: (function () {
                return {
                    text:'(PD%)',
                    align: 'high',
                    margin: -18,
                    offset: 20,
                    y: -100,
                    x: 10,
                    rotation: 0,
                    style: {
                        fontSize: '11px'
                    }
                };
            })(),
            min: 0,
            max: 4.8017044515217,

            labels: {
                
            },
          showFirstLabel: true,
          showLastLabel: true,
          opposite: false,
          tickInterval:  undefined,
          tickAmount: 5,
          lineWidth: 0,
          gridLineWidth:0,
          minorGridLineWidth :0,
          lineColor: 'transparent',
          startOnTick:false,
          endOnTick:true,
          plotBands:
          {
              from: 4.8017044515217,
              to:100,
              color: '#fbb189',
          }
        },
        tooltip: {
            enabled: false
        },
        credits: {
            enabled: false
        },
        plotOptions: {
            areaspline: {
                fillOpacity: 1,
                zoneAxis: 'x',
                lineWidth:0,
                zones:[],
                gridLineWidth: 0,
                minorGridLineWidth: 0,
               },
            series: {
                marker: {
                    enabled: false
                },
                states: {
                    hover: {
                        enabled: false
                    }
                },
                dataLabels: {
                    enabled: false,
                    inside: false,
                    style: {
                        fontWeight: "bold",
                    },


                },
                events: {
                    legendItemClick() {
                        return false;
                    }
                },


            },
            enableMouseTracking: false,
            tooltip: {
                enabled: false
            },



        },

        series: [
            {
            color: '#fbb189',
            name: 'Deteriorating',
            showInLegend: false,
            data: [{x: 1618444800000, y: 4.8017044515217},{x: 1618531200000, y: 4.8017044515217}],
            legendIndex: 3
            
             
        },
        {
            color: '#fff2d0',
            name: 'Stable',
            showInLegend: false,
            data: [{x: 1618444800000, y: 1.5426857827908}, {x: 1618531200000, y: 1.5389919557792}],
            legendIndex: 2

        }, {
            color: '#c2e0b7',
            name: 'Improving',
            showInLegend: false,
            data:  [{x: 1618444800000, y: 0.5853383784494}, {x: 1618531200000, y: 0.5819433217592}],
            legendIndex: 1
            
        },
        {
            name: '',
            showInLegend: false,
            type: 'spline',
            data: [{x: 1618444800000, y: 0.6352655741304001}, {x: 1618531200000, y: 0.6339928215217}],
            legendIndex: 0,
            color: 'red'
            
            
        }
        ]
    });

下面是工作 jsFiddle 的屏幕截图:

在此处输入图像描述

请检查以下 jsFiddle 与单个数据不起作用。 https://jsfiddle.net/g3m0x25d/

<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px; width: 95%"></div>

Highcharts.chart('container', {
        chart: {
            type: 'areaspline',
            marginTop:  4,
            plotBackgroundColor: '#f2f2f2',
            backgroundColor: '#f2f2f2',
            zoomType: '',
            resetZoomButton: {
                theme: {
                    r: 20
                },
                position: {
                    x: -5,
                    y: 5
                }
            },

        },
       title:{text:''} ,

    xAxis: {
            type: 'datetime',
            dateTimeLabelFormats: {
                millisecond:  '%b-%d-%Y',
                second:  '%b-%d-%Y',
                minute:  '%b-%d-%Y',
                hour:  '%b-%d-%Y',
                day:'%b-%d-%Y',
                week: '%b-%d-%Y',
                month: '%b-%d-%Y',
                year:  '%Y'
            },
            min: 1618444800000,
            max: 1618531200000,
            tickPixelInterval: 150,
            minTickInterval:   undefined,
            tickInterval: null,
            gridLineWidth: 0,
            lineWidth: 0,

        },
        yAxis: {
            title: (function () {
                return {
                    text:'(PD%)',
                    align: 'high',
                    margin: -18,
                    offset: 20,
                    y: -100,
                    x: 10,
                    rotation: 0,
                    style: {
                        fontSize: '11px'
                    }
                };
            })(),
            min: 0,
            max: 4.8017044515217,

            labels: {
                
            },
          showFirstLabel: true,
          showLastLabel: true,
          opposite: false,
          tickInterval:  undefined,
          tickAmount: 5,
          lineWidth: 0,
          gridLineWidth:0,
          minorGridLineWidth :0,
          lineColor: 'transparent',
          startOnTick:false,
          endOnTick:true,
            plotBands:
          {
              from: 4.8017044515217,
              to:100,
              color: '#fbb189',
          }
          
        },
        tooltip: {
            enabled: false
        },
        credits: {
            enabled: false
        },
        plotOptions: {
            areaspline: {
                fillOpacity: 1,
                zoneAxis: 'x',
                lineWidth:0,
                zones:[],
                gridLineWidth: 0,
                minorGridLineWidth: 0,
               },
            series: {
                marker: {
                    enabled: false
                },
                states: {
                    hover: {
                        enabled: false
                    }
                },
                dataLabels: {
                    enabled: false,
                    inside: false,
                    style: {
                        fontWeight: "bold",
                    },


                },
                events: {
                    legendItemClick() {
                        return false;
                    }
                },


            },
            enableMouseTracking: false,
            tooltip: {
                enabled: false
            },



        },

        series: [
            {
            color: '#fbb189',
            name: 'Deteriorating',
            showInLegend: false,
            data: [{x: 1618444800000, y: 4.8017044515217}],
            legendIndex: 3
            
             
        },
        {
            color: '#fff2d0',
            name: 'Stable',
            showInLegend: false,
            data: [{x: 1618444800000, y: 1.5426857827908}],
            legendIndex: 2

        }, {
            color: '#c2e0b7',
            name: 'Improving',
            showInLegend: false,
            data:  [{x: 1618444800000, y: 0.5853383784494}],
            legendIndex: 1
            
        },
        {
            name: '',
            showInLegend: false,
            type: 'spline',
            data: [{x: 1618444800000, y: 0.6352655741304001}],
            legendIndex: 0,
            color: 'red'
            
            
        }
        ]
    });

以下是不起作用的小提琴的屏幕截图:

在此处输入图像描述

标签: javascriptjqueryhighchartsspline

解决方案


我认为一切都按应有的方式工作,将其设置plotOptions.series.marker.enabled为 false 隐藏点。

演示:https ://jsfiddle.net/BlackLabel/r9m34x8f/


推荐阅读