0

我将如何更改给定示例上的 xaxis 标签或刻度以显示日期?

http://jsxgraph.uni-bayreuth.de/wiki/index.php/Time_series_II

4

1 回答 1

0

您可以“手动”插入刻度并将其标签设置为任意字符串。这是一个示例,请参见https://jsfiddle.net/8f65cgdq/7/

// Initialize the board without axes
const board = JXG.JSXGraph.initBoard('jxgbox', { 
    boundingbox: [-1, 100, 10, -8], axis:false
});

// Add a vertical axis
board.create('axis',[[0, 0], [0, 10]]);
// Add a horizontal axis
var xaxis = board.create('axis',[[0,0], [1,0]]);
// Remove the default ticks
xaxis.removeTicks(xaxis.defaultTicks);

// Create your own ticks with non-standard labels
var ticks = board.create('ticks', [xaxis, 
    [2, 4, 6, 8]], {
    labels: ['1.8.2019', '15.8.2019', '30.8.2019', '15.9.2019'],
    strokeColor: '#00ff00', 
    majorHeight: -1, 
    drawLabels: true, 
    label: {offset: [0,-5], anchorX: 'middle', anchorY: 'top'}
  });
于 2019-11-18T09:49:33.067 回答