javascript - 当某些 x 轴刻度为空值时如何在 Jqplot 中显示 'fillToValue'

标签 javascript jquery graph charts jqplot

我正在尝试使用 jQplot 系列的 fillToValue 属性将该系列填充到特定值。

我正在使用这个函数来创建一个系列数组:

/**
 * This function populates the graphSeries array to contain the different properties of each series.
 *
 * @param {string} Yaxis: which Y axis to use(yaxis or y2axis)
 * @param {string} Color: Color code for the graph line
 * @param {string} MarkerColor: Color of the marker for each point on the graph
 * @param {string} Style: Shape of the marker(star, diamond, etc)
 * @param {string} Label: Text value of the series, which would appear on the legend also.
 */ 
    function seriesCreation(Yaxis, Color, MarkerColor, Style, Label, Show){

        graphSeries.push({
            yaxis : Yaxis,
            shadow : true,
            shadowAngle: 45,
            shadowOffset : 2.25,
            color : Color,
            label : Label,
            breakOnNull : true,
            markerOptions: {
                show: true,
                size: 12.0,
                color: MarkerColor,
                style: Style
            },
            show: true,
            fill: Show,
            fillToZero : true,
            fillToValue : 1
        });
    }

如果我有一个值数组,其中没有任何 null 值,这很好用,但是如果我有一个包含 null 值的数组,那么它不会填充颜色也不画线。

示例:chartData1 工作正常但 chartData2 不工作(不填充颜色也不显示线条)

var chartData1 = [["19-Jan-2012", 2.61], ["20-Jan-2012", 5.00], ["21-Jan-2012", 6.00], ["22-Jan-2012", 3.00], ["23-Jan-2012", 8.00], ["24-Jan-2012", 1.00]];

var chartData2 = [["19-Jan-2012", null], ["20-Jan-2012", null], ["21-Jan-2012", 6.00], ["22-Jan-2012", 3.00], ["23-Jan-2012", 8.00], ["24-Jan-2012", null]];

有人知道怎么做吗?我认为这个概念可能对很多使用 jqplot 的人有用。

最佳答案

您可以在绘制图表之前进行预处理,您可以在其中将每个等于“null”的值修改为整数值:“0”。

关于javascript - 当某些 x 轴刻度为空值时如何在 Jqplot 中显示 'fillToValue',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16920559/

相关文章:

javascript - 在angularjs中实现html5拖放?

添加母版页后 JavaScript 不工作

jquery - 如何编写自己的自定义 jQuery 插件(未捕获的 TypeError : . .. 不是函数)

postgresql - 如何在 Postgresql 中对图形数据建模?

javascript - 使用不同参数的重写方法来扩展 Typescript 类不可能吗?

javascript - 如何为自动点击器编写代码,用于点击 Chrome 网页中的特定链接

javascript - 为点击事件添加音频

c - 如何通过在C中传递 "Console Windows"来将像素设置为 "String Pointer"?

javascript - dygraph 函数 - 如何同时放大多个图表

javascript - 是否可以将 javascript 文件导入到 java ScriptEngine