Jqplot y轴缩放

时间:2013-12-31 04:41:19

标签: jquery jqplot

我想像下面的图像一样缩放y轴 enter image description here

但我有如下图表 enter image description here

我想像第一个图一样实现y轴缩放。我想在大范围内显示.09和1之间的值。我也希望将pf值范围显示为0到1(最小值为0,最大值为1)。

有什么想法吗?

我尝试过的代码是HERE

$.jqplot.config.enablePlugins = true;
var chartData = [[1, .92], [2,.93], [3, .98],[4,.95]];

function PlotChart(chartData) {

    var plot2 = $.jqplot('chart1', [chartData], {
        title: '',
        seriesDefaults: {
            renderer: $.jqplot.CanvasAxisLabelRenderer,
            rendererOptions: {
                smooth: true
            },
            pointLabels: {
                show: true
            }
        },
        axes: {
            xaxis: {
                label: 'date',
                ticks : [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10','11', '12', '13', '14'],
                renderer: $.jqplot.CategoryAxisRenderer,
                // renderer to use to draw the axis,     
                tickOptions: {
                    formatString: '%d'
                }
            },
            yaxis: {              
                ticks:[ '0', '.5','.9', '1' ],
                label: 'PF',
                tickOptions: {
                    formatString: '%.2f'
                }
            }
        },
        highlighter: {
            sizeAdjust: 7.5
        },
        cursor: {
            show: true
        }
    });
}

PlotChart(chartData);

1 个答案:

答案 0 :(得分:5)

我认为jqplot不允许做你想做的事情,我知道在轴上工作是非常严格的(我试图在工具提示上显示带小数的完整值,即使比例太大而无法显示小数)。

你可以做的是调整间隔大小,尝试使用min和max:

     yaxis: {              
            ticks:[ '.9', '1' ],
            label: 'PF',
            tickOptions: {
                formatString: '%.2f'
            }
            min: 0.8,
            max: 1.1
        }

使用该间隔,jqplot将使图形显示完美的线条。

相关问题