在jqplot中将y轴值设置为零,用于不存在的x轴值

时间:2014-03-28 09:25:48

标签: jqplot

我正在使用jqplot来创建图形。 我有一个关于不存在的值的问题。 我创建了一个有5行的图形,显示为http://www.popularjava.net/wp-content/uploads/statisticGraphic.png 从图中可以看出,某些线条只有一个值,例如橙色线条。 但是,我想用y = 0来显示这些不存在的值。 我的意思是,如果没有任何日期的点,我想把y = 0用于所有日期。

这是我的代码。

var minGraphicXValue = response.minGraphicXValue;
var maxGraphicXValue = response.maxGraphicXValue;
var dataSeriesList = response.dataSeriesList;

 var plot1 = $.jqplot('countGraphicGrid', response.countArray, {
                title: 'Count/Time Graphic - ' + selectedItemType + ":" + itemValue + " - " + StatisticGraphic.selectedGraphicPeriod,
                axes: {
                    xaxis: {
                        label: "Time",
                        labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
                        labelOptions: {
                            fontFamily: 'Helvetica',
                            fontSize: '14pt'
                        },
                        renderer: $.jqplot.DateAxisRenderer,
                        tickRenderer: $.jqplot.CanvasAxisTickRenderer,
                        tickOptions: {
                            formatString: StatisticGraphic.tickFormatPattern,
                            angle: -30
                        },
                        tickInterval: StatisticGraphic.tickIntervalTime,
                        min: minGraphicXValue,
                        max: maxGraphicXValue,
                        drawMajorGridlines: false
                    },
                    yaxis: {
                        label: "Count",
                        tickOptions: {
                            formatString: '%d'
                        },
                        min: 0,
                        max: 100,
                        autoscale: true
                    }
                },
                legend: {
                    show: true,
                    placement: 'outside'
                },
                seriesDefaults: {
                    rendererOptions: {
                        smooth: true,
                        animation: {
                            show: true
                        }
                    },
                    showMarker: true
                },
                series: dataSeriesList,
                highlighter: {
                    show: true,
                    sizeAdjust: 7.5,
                    tooltipOffset: 9
                },
                grid: {
                    background: 'rgba(57,57,57,0.0)',
                    drawBorder: false,
                    shadow: false,
                    gridLineColor: '#666666',
                    gridLineWidth: 1
                }
            });

1 个答案:

答案 0 :(得分:0)

我认为最好的方法是在将数据渲染到地块上之前格式化数据。

我的意思是为你不存在的值添加值。你可以使用你的(最小|最大)GraphicXValue,如果不存在则将它们设置为0.