admin管理员组

文章数量:1123011

Having a dimple.js line plot to compare time series for several years, on the x axis is one tick for each month, with the month number as label.

I would like the tick labels on the x axis, to be printed at the mid of each interval, instead of being aligned to the ticks.

The ticks are set by:

var x = myLinePlot.addTimeAxis("x", "month_day");
x.tickFormat = "%m";

month_day contains the time values, like "07/18" for the 18th of July, ranging from 01/01 to 12/31.

I assume I will likely have to use the afterDraw method or equivalent, to postprocess my chart, selecting elements with d3, doing some math, and move them rightwards.

  var myLinePlot = new dimple.chart(mySVG, myJsonData);
  (...)  
  myLinePlot.afterDraw = function (...) {
     (...)
        var myLinePlot = d3.select(...)
     (...)
  }

Is there some easier way to do that with dimple.js, and if no, how can I do this with d3?

I also need the label "01" to be printed for the month of January.

I am aware that setting a category axis instead of a time axis, would print the labels between ticks, but a time axis is still justified in this case.

本文标签: labelDimplejs How to set the XAxis ticks to the mid of each intervalStack Overflow