Jquery JQPlot设置刻度,然后重新标记

Jquery JQPlot设置刻度,然后重新标记,jquery,jqplot,Jquery,Jqplot,我想使用从1到20的线性比例来设置x轴刻度和的格式,但是我想用不同的值重新标记它们。这可能吗?我没有看到任何“ticklab”字段 我目前正在使用ticks:array设置ticks,其中数组包含的数据间隔不相同。我要做的是标记:[1,2…20]然后用数组中的值标记标记 例如,现在,我的数组包含像“100121125128140”这样的数据。我希望x轴的间隔均匀,并且仍然显示“100121125128140” 下面是我正在使用的x轴代码: xaxis : { tickRenderer :

我想使用从1到20的线性比例来设置x轴刻度和的格式,但是我想用不同的值重新标记它们。这可能吗?我没有看到任何“ticklab”字段

我目前正在使用
ticks:array
设置ticks,其中数组包含的数据间隔不相同。我要做的是
标记:[1,2…20]
然后用数组中的值标记标记

例如,现在,我的数组包含像“100121125128140”这样的数据。我希望x轴的间隔均匀,并且仍然显示“100121125128140”

下面是我正在使用的x轴代码:

xaxis :
{
    tickRenderer : $.jqplot.CanvasAxisTickRenderer,
    tickOptions :
    {
        angle : -90,
        textColor : '#FFA500',
        fontSize : '1em',
        fontFamily : '"Trebuchet   MS",Arial,Helvetica,sans-serif'
    },
    label : "Value",
    pad : 0,
    min : minValue,
    max : maxValue,
    ticks : values,
    autoscale : false
}
values
是一个数组,其中包含我希望在x轴上显示的值,但我希望x轴上的值的距离相同

以下是全部内容:

var plot = $.jqplot (chartID ,[val1, val2, val3, val4, val5],
        {
            title: "5 Items" ,

              series:[
                      {
                        label:val[0],
                        lineWidth:2, 
                        markerOptions: { style:'dimaond' }
                      },
                      {
                          label:val[1],
                            lineWidth:2, 
                            markerOptions: { style:'dimaond' }
                      },
                      {
                          label:val[2],
                            markerOptions: { style:"circle" }
                      }
                      ,
                      {
                          label:val[3],
                            markerOptions: { style:"circle" }
                      }
                      ,
                      {
                          label:val[4],
                            markerOptions: { style:"circle" }
                      }
                      ]
                      ,
               grid: {
                          background: '#fffdf6',   
                          borderColor: '#999999'     
                      },              

                  axes: {
                      // options for each axis are specified in seperate
                        // option objects.
                      xaxis: {
                          tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
                          tickOptions: {
                              angle: -90,
                              textColor:'#FFA500',
                              fontSize:'1em',
                              fontFamily: '"Trebuchet MS",Arial,Helvetica,sans-serif'
                          },
                        label: "Value",
                        pad: 0,
                        min:minValue,
                        max:maxValue,
                        renderer: $.jqplot.CategoryAxisRenderer,
                        ticks: values,
                        autoscale:false
                      },
                      yaxis: {              
                        min:minTime,
                        max:maxTime,
                          tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
                          tickOptions: {
                              formatString: "%#.2f",
                              textColor:'#FFA500',
                              fontSize:'1em',
                              fontFamily: '"Trebuchet MS",Arial,Helvetica,sans-serif'
                          }
                      }
              },
              legend:{
                  show:true,
                  location:'se',
                  labels:vals,
                  placement:"insideGrid"
              }
        });

使用-showLabel:“true”尝试勾选选项

 ticks: [],      // a 1D [val1, val2, ...], or 2D [[val, label], [val, label], ...]
                    // array of ticks to use.  Computed automatically.
 numberTicks: undefined, 

 tickOptions: {
        mark: 'outside',    // Where to put the tick mark on the axis
                            // 'outside', 'inside' or 'cross',
        showMark: true,
        showGridline: true, // wether to draw a gridline (across the whole grid) at this tick,
        markSize: 4,        // length the tick will extend beyond the grid in pixels.  For
                            // 'cross', length will be added above and below the grid boundary,
        show: true,         // wether to show the tick (mark and label),
        showLabel: true,    // wether to show the text label at the tick,
        formatString: '',   // format string to use with the axis tick formatter
    } 

我认为使用
$.jqplot.CategoryAxisRenderer
可以解决您的问题。 请将jqplot.CategoryAxisRenderer.js文件也添加到您的页面

请回答您的问题:

例如:


我更新了问题,“现在,我的数组包含像“100121125128140”这样的数据。我希望x轴的间隔均匀,并且仍然显示“100121125128140”。“我可以显示刻度,但是如果我使用线性比例,我的间隔很好,但是标签不是我想要的,如果我使用数组,标签很好,但图表上的间距不是我想要的。你能分享你的代码或任何截图吗?@Gyandeep,我已经添加了代码。这似乎修复了x轴比例,但现在没有一行显示出来。@sportsfan72请使用JSFIDLE链接我的答案,它将帮助你解决这个问题。我已经看过了,但是我不确定为什么在添加了那行代码之后,现在没有显示行的值。你知道吗?如果有帮助的话,我已经添加了我的y轴代码。我必须先查看您的整个代码,然后才能说什么。您是否在代码中包含了jqplot.CategoryAxisRenderer.js文件。您还可以给我提供一些
val
变量的值吗
xaxis :
{
    tickRenderer : $.jqplot.CanvasAxisTickRenderer,
    tickOptions :
    {
        angle : -90,
        textColor : '#FFA500',
        fontSize : '1em',
        fontFamily : '"Trebuchet   MS",Arial,Helvetica,sans-serif'
    },
    label : "Value",
    pad : 0,
    min : minValue,
    max : maxValue,
    renderer: $.jqplot.CategoryAxisRenderer,
    ticks : values,
    autoscale : false
}