-
Notifications
You must be signed in to change notification settings - Fork 21
Fix: Updated axis.js to use customPadding as constantPadding (fixes #22) #83
Changes from 3 commits
245799f
2b156df
afa2810
21a61ab
2642165
361c0a1
fd712a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -577,9 +577,6 @@ const getYAxisHeight = (config) => config.height; | |
* @returns {number} Height of the X Axis ticks, labels and numbers/datetimes | ||
*/ | ||
const getXAxisHeight = (config) => { | ||
if (config.padding.hasCustomPadding) { | ||
return config.padding.bottom; | ||
} | ||
const scale = getScale(config.axis.x.type) | ||
.domain(config.axis.x.domain) | ||
.range([0, config.canvasWidth]); | ||
|
@@ -654,9 +651,6 @@ const getAxisLabelHeight = (label) => { | |
* @returns {number} label width | ||
*/ | ||
const getYAxisWidth = (id, config) => { | ||
if (config.padding.hasCustomPadding) { | ||
return config.padding.left; | ||
} | ||
const scale = d3.scale | ||
.linear() | ||
.domain([ | ||
|
@@ -683,16 +677,9 @@ const getYAxisWidth = (id, config) => { | |
* @param {object} config - config object derived from input JSON. | ||
* @returns {number} label width | ||
*/ | ||
const getY2AxisWidth = (config) => { | ||
if (config.padding.hasCustomPadding) { | ||
return config.padding.right; | ||
} | ||
return ( | ||
(hasY2Axis(config.axis) | ||
? getYAxisWidth(constants.Y2_AXIS, config) | ||
: 20) + config.padding.right | ||
); | ||
}; | ||
const getY2AxisWidth = (config) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
(hasY2Axis(config.axis) ? getYAxisWidth(constants.Y2_AXIS, config) : 20) + | ||
config.padding.right; | ||
/** | ||
* Checks if X Axis orientation is set to top | ||
* | ||
|
@@ -714,9 +701,8 @@ const isXAxisOrientationTop = (xAxisOrientation) => | |
*/ | ||
const calculateAxesSize = (config) => { | ||
config.axisSizes = {}; | ||
config.axisSizes.y = config.padding.hasCustomPadding | ||
? getYAxisWidth(constants.Y_AXIS, config) | ||
: getYAxisWidth(constants.Y_AXIS, config) + config.padding.left; | ||
config.axisSizes.y = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Dinesh94Singh Why did we need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is to determine if the customPadding is given as input. inside getPadding function, we return the padding object from constants or default few of the fields to constants when not all fields are given as part of custom padding. Since config.padding is assigned to the return value of getPadding, there is no way to distinguish if the padding is a custom padding or constant padding. |
||
getYAxisWidth(constants.Y_AXIS, config) + config.padding.left; | ||
config.axisSizes.y2 = getY2AxisWidth(config); | ||
config.axisSizes.x = getXAxisHeight(config); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember right - removing this might break Gantt with customPadding set to all 0's. Can you post a screenshot of what happens for Gantt having 0 custom padding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't break the code.
But I am not able to understand, that why are we using
tracklabel
to define paddingleft
for bothcustom
andconstant
GanttConfig.jsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason might be because, track labels are displayed in the left and the length of the trackLabel defines where to start the Gantt (since we wouldn't want our labels to get cut off - giving arbitrary values).