mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-22 16:59:48 +02:00
gantt/ganttRenderer: add top x-axis for large Gantt charts
I am leveraging a Gantt chart to generate a years-long Roadmap from text. This is for a large team, so it is quite large. A request I get from my stakeholders is for a top labelling axis in parallel to the current bottom one, so that the dates are labelled no matter where we are scrolled on the screen.
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
|||||||
scaleLinear,
|
scaleLinear,
|
||||||
interpolateHcl,
|
interpolateHcl,
|
||||||
axisBottom,
|
axisBottom,
|
||||||
|
axisTop,
|
||||||
timeFormat
|
timeFormat
|
||||||
} from 'd3';
|
} from 'd3';
|
||||||
import { parser } from './parser/gantt';
|
import { parser } from './parser/gantt';
|
||||||
@@ -369,6 +370,22 @@ export const draw = function(text, id) {
|
|||||||
.attr('stroke', 'none')
|
.attr('stroke', 'none')
|
||||||
.attr('font-size', 10)
|
.attr('font-size', 10)
|
||||||
.attr('dy', '1em');
|
.attr('dy', '1em');
|
||||||
|
|
||||||
|
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 + ', ' + (h - 50) + ')')
|
||||||
|
.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) {
|
function vertLabels(theGap, theTopPad) {
|
||||||
|
Reference in New Issue
Block a user