【问题标题】:JSXGraph change axis ticks to datesJSXGraph 将轴刻度更改为日期
【发布时间】:2019-11-17 07:42:32
【问题描述】:

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

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

【问题讨论】:

    标签: jsxgraph


    【解决方案1】:

    您可以“手动”插入刻度并将其标签设置为任意字符串。这是一个示例,请参阅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'}
      });
    

    【讨论】:

      猜你喜欢
      • 2015-07-13
      • 2021-03-05
      • 2020-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-11
      相关资源
      最近更新 更多