mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 17:29:54 +02:00
Merge pull request #1954 from nacc/gantt-top-xaxis
Gantt: add top xaxis
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
scaleLinear,
|
||||
interpolateHcl,
|
||||
axisBottom,
|
||||
axisTop,
|
||||
timeFormat
|
||||
} from 'd3';
|
||||
import { parser } from './parser/gantt';
|
||||
@@ -346,7 +347,7 @@ export const draw = function(text, id) {
|
||||
}
|
||||
|
||||
function makeGrid(theSidePad, theTopPad, w, h) {
|
||||
let xAxis = axisBottom(timeScale)
|
||||
let bottomXAxis = axisBottom(timeScale)
|
||||
.tickSize(-h + theTopPad + conf.gridLineStartPadding)
|
||||
.tickFormat(timeFormat(parser.yy.getAxisFormat() || conf.axisFormat || '%Y-%m-%d'));
|
||||
|
||||
@@ -354,13 +355,31 @@ export const draw = function(text, id) {
|
||||
.append('g')
|
||||
.attr('class', 'grid')
|
||||
.attr('transform', 'translate(' + theSidePad + ', ' + (h - 50) + ')')
|
||||
.call(xAxis)
|
||||
.call(bottomXAxis)
|
||||
.selectAll('text')
|
||||
.style('text-anchor', 'middle')
|
||||
.attr('fill', '#000')
|
||||
.attr('stroke', 'none')
|
||||
.attr('font-size', 10)
|
||||
.attr('dy', '1em');
|
||||
|
||||
if (ganttDb.topAxisEnabled() || conf.topAxis) {
|
||||
let topXAxis = axisTop(timeScale)
|
||||
.tickSize(-h + theTopPad + conf.gridLineStartPadding)
|
||||
.tickFormat(timeFormat(parser.yy.getAxisFormat() || conf.axisFormat || '%Y-%m-%d'));
|
||||
|
||||
svg
|
||||
.append('g')
|
||||
.attr('class', 'grid')
|
||||
.attr('transform', 'translate(' + theSidePad + ', ' + theTopPad + ')')
|
||||
.call(topXAxis)
|
||||
.selectAll('text')
|
||||
.style('text-anchor', 'middle')
|
||||
.attr('fill', '#000')
|
||||
.attr('stroke', 'none')
|
||||
.attr('font-size', 10)
|
||||
.attr('dy', '1em');
|
||||
}
|
||||
}
|
||||
|
||||
function vertLabels(theGap, theTopPad) {
|
||||
|
Reference in New Issue
Block a user