0


我有一个 jqplot 线图

    $.jqplot('chartdiv1',  <?=$dataset?>,
            {
                title: 'GRAPT TITLE',
                axes: {
                    xaxis:{
                        label:"x axis",
                        renderer:$.jqplot.DateAxisRenderer,
                        tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
                        tickOptions:{formatString:'%d.%m.%y %H:%M:%S', angle: -30}
                    },
                    yaxis:{
                        label:"y axis",
                        labelRenderer: $.jqplot.CanvasAxisLabelRenderer
                    }
                },
                highlighter: {
                    show: true,
                    sizeAdjust: 7.5
                },
                cursor:{
                    show: true,
                    zoom:true,
                    showTooltip:false
                }
            });

它是这样显示的

为什么它在 x 轴上没有正确缩放?
值相差 1 分钟

4

1 回答 1

1

为您的轴添加一个最小值:

axes: {
 xaxis: {
  label: "x axis",
  renderer: $.jqplot.DateAxisRenderer,
  tickRenderer: $.jqplot.CanvasAxisTickRenderer,
  tickOptions:{formatString:'%d.%m.%y %H:%M:%S', angle: -30},
  min: '2013-02-05 10:50',
  max: '2013-02-05 12:15',
  tickInterval: '1 hour', //only if you want to draw a tick each hour.
  autoscale: false        //only if you want to draw a tick each hour. 
 } 
}

编辑

当您放大时,将 xaxis 边界调整为要绘制的数据是一种“正常”行为。如果-当您缩小时-您的情节与开始时的行为相同(左中空),您可以禁用本机缩放重置,这要归功于

cursor:{
   clickReset: false, 
   dblClickReset: false
} 

并在绘制绘图后添加一个新的双击事件处理程序:

$("#chartdiv1").dblclick(function(){resetZoomOnPlot(myplot);});
function resetZoomOnPlot(targetPlot){
  target.resetZoom();
  target.axes.xaxis.min = '2013-02-25 10:50';
  target.axes.xaxis.max = '2013-02-25 12:15';
  target.axes.xaxis._tickInterval = '1 hour';
  target.replot();    
}

其中 myplot 是一个包含您的情节的变量:var myplot = $.jqplot('chartdiv1', <?=$dataset?>, options);。options 是一个包含您的 jqplot 选项的变量:var options = {title: 'Graph title', axes: {...}...};

于 2013-02-15T10:43:06.947 回答