Note that there are some explanatory texts on larger screens.

plurals
  1. POjqPlot DateAxis tickInterval not working
    primarykey
    data
    text
    <p>I'm trying to draw a chart with a single datapoint each month. I'm sending this through to jqPlot as a single point on the first of each month:</p> <pre><code>$.jqplot('actualChart', [[['2011-10-01',0.296],['2011-11-01',0.682]]], { title: programSelection.options[programSelection.selectedIndex].text, axes: { xaxis: { renderer: $.jqplot.DateAxisRenderer, rendererOptions: { tickRenderer: $.jqplot.CanvasAxisTickRenderer }, tickOptions: { formatString: '%b' } } } } </code></pre> <p>I'm loading the chart data using Ajax. Some datasets have more points of data than others - in the example above with only 2 points, the x-axis ticks (which '%b' means just appear as Oct and Nov) are rendered automatically along the axis, but too often, e.g. Sep...Oct...Oct...Oct...Oct...Nov - at regular points along the line that is shown. I just want a single tick at the start of Oct and another at the start of Nov.</p> <p>I have spent a lot of time searching and it seems tickInterval is made for this, but adding</p> <pre><code>tickInterval: '1 month' </code></pre> <p>just makes the x-axis, datapoints and line disappear - this is the broken functionality I'm referring to! Specifying any other interval e.g.</p> <pre><code>tickInterval: '2 days' </code></pre> <p>also breaks it.</p> <p>A workaround is to provide the ticks manually, e.g.</p> <pre><code>ticks: ['2011-10-01','2011-11-01'] </code></pre> <p>This <em>does</em> put the ticks in the right place, but</p> <p>a) is a hassle that should not be required, and</p> <p>b) loses the nice padding at either end of the graph's datapoints, so the points at either end appear on the edges of the graph. Unless manual ticks either side are added, of course, but in the Oct-Nov example above I don't want to provide a whole month on either side because then the interesting data takes up only the middle third of the graph.</p> <p>Can anyone help me with this? Thanks in advance.</p> <p><strong>EDIT - found a solution:</strong> Providing a <em>min</em> attribute for the axis does appear to fix this (for whatever reason... bug?), so unless anyone has any better ideas I'll do this!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload