Skip to content

Commit

Permalink
Parameter subchart_axis_x_show is now working (#2806)
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Giuliano <marco.giuliano@tesisquare.com>
  • Loading branch information
digEmAll and Marco Giuliano authored Aug 8, 2020
1 parent 062a185 commit fdc4c86
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
20 changes: 20 additions & 0 deletions docs/reference.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
= partial :reference_menu_item, locals: { id: 'subchart.show', experimental: true }
= partial :reference_menu_item, locals: { id: 'subchart.size.height', experimental: true }
= partial :reference_menu_item, locals: { id: 'subchart.onbrush', experimental: true }
= partial :reference_menu_item, locals: { id: 'subchart.axis.x.show', experimental: true }

%li Zoom
= partial :reference_menu_item, locals: { id: 'zoom.enabled', experimental: true }
Expand Down Expand Up @@ -3009,6 +3010,25 @@
}
%hr

%section
%h3
= partial :reference_item_link, locals: { id: 'subchart.axis.x.show', experimental: true }
%p Show or hide x axis of subchart.
%h5 Default:
<code>true</code>
%h5 Format:
%div.sourcecode
%pre
%code.html.javascript
subchart: {
&nbsp;&nbsp;axis: {
&nbsp;&nbsp;&nbsp;&nbsp;x: {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;show: true
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
}
%hr

%section
%h3
= partial :reference_item_link, locals: { id: 'zoom.enabled', experimental: true }
Expand Down
5 changes: 3 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,10 @@ ChartInternal.prototype.updateSizes = function() {
hasArc = $$.hasArcType(),
xAxisHeight =
config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'),
subchartXAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x',true),
subchartHeight =
config.subchart_show && !hasArc
? config.subchart_size_height + xAxisHeight
? config.subchart_size_height + subchartXAxisHeight
: 0

$$.currentWidth = $$.getCurrentWidth()
Expand Down Expand Up @@ -462,7 +463,7 @@ ChartInternal.prototype.updateSizes = function() {
: {
top: $$.currentHeight - subchartHeight - legendHeightForBottom,
right: NaN,
bottom: xAxisHeight + legendHeightForBottom,
bottom: subchartXAxisHeight + legendHeightForBottom,
left: $$.margin.left
}

Expand Down
6 changes: 3 additions & 3 deletions src/size.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import CLASS from './class'
import { ChartInternal } from './core'
import { isValue, ceil10 } from './util'
import { isValue, ceil10, isDefined } from './util'

ChartInternal.prototype.getCurrentWidth = function() {
var $$ = this,
Expand Down Expand Up @@ -127,11 +127,11 @@ ChartInternal.prototype.getAxisWidthByAxisId = function(id, withoutRecompute) {
$$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40)
)
}
ChartInternal.prototype.getHorizontalAxisHeight = function(axisId) {
ChartInternal.prototype.getHorizontalAxisHeight = function(axisId, isSubchart) {
var $$ = this,
config = $$.config,
h = 30
if (axisId === 'x' && !config.axis_x_show) {
if (axisId === 'x' && !(isDefined(isSubchart) && isSubchart ? config.subchart_axis_x_show : config.axis_x_show)) {
return 8
}
if (axisId === 'x' && config.axis_x_height) {
Expand Down
1 change: 1 addition & 0 deletions src/subchart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ ChartInternal.prototype.initSubchart = function() {
.attr('class', CLASS.axisX)
.attr('transform', $$.getTranslate('subx'))
.attr('clip-path', config.axis_rotated ? '' : $$.clipPathForXAxis)
.style('visibility', config.subchart_axis_x_show ? 'visible' : 'hidden');
}
ChartInternal.prototype.initSubchartBrush = function() {
var $$ = this
Expand Down

0 comments on commit fdc4c86

Please sign in to comment.