Skip to content

Commit

Permalink
#7779 fix regression in histogram labeling (#7785)
Browse files Browse the repository at this point in the history
* #7743 fix

* #7743 fix typo

* #7779 fix histogram labeling
  • Loading branch information
piorek authored and LeeTZ committed Sep 7, 2018
1 parent 2c25b4c commit 29f02fb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions js/notebook/src/plot/CombinedPlotScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export default class CombinedPlotScope {

this.id = `bko-plot-${bkUtils.generateId(6)}`;
this.element.find('.combplot-plotcontainer').attr('id', this.id);
this.element.find('.plot-title').attr('class', `plot-title plot-title-${this.id}`);
this.saveAsMenuContainer = $(`#${this.id}`);
this.contextMenu = new ContextMenu(this);

Expand Down
10 changes: 3 additions & 7 deletions js/notebook/src/plot/PlotScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export default class PlotScope {
this.legendDone = false;
this.update();
this.fillCellModelWithPlotMethods();
this.adjustModelWidth();
this.emitSizeChange(true);
this.pointsLimitModal.init();
}
Expand Down Expand Up @@ -293,9 +292,10 @@ export default class PlotScope {

standardizeData() {
const model = this.model.getCellModel();
const plotModel = PlotModelFactory.getPlotModel(model, this.prefs);

this.stdmodel = plotModel.getStandardizedModel();
this.stdmodel = PlotModelFactory
.getPlotModel(model, this.prefs)
.getStandardizedModel();
}

initFlags() {
Expand All @@ -315,10 +315,6 @@ export default class PlotScope {
this.removePipe.length = 0;
}

adjustModelWidth() {
this.plotSize.updateModelWidth(this.plotSize.getPlotWithLegendWidth());
}

updatePlot() {
this.standardizeData();
this.initFlags();
Expand Down
23 changes: 21 additions & 2 deletions js/notebook/src/plot/PlotSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,34 @@ export default class PlotSize {
const legendPosition = this.scope.stdmodel.legendPosition.position;
// Logic based on updateLegendPosition method
const isLegendPlacedHorizontaly = (
(["LEFT", "RIGTH"].indexOf(legendPosition) !== -1)
(["LEFT", "RIGHT"].indexOf(legendPosition) !== -1)
|| (["TOP", "BOTTOM"].indexOf(legendPosition) === -1 && this.scope.stdmodel.legendLayout === "VERTICAL")
);

let legendWidth = this.scope.jqlegendcontainer.find('.plot-legend').width() || 0;

legendWidth = legendWidth ? legendWidth + this.scope.layout.legendMargin + 2 : 0;

return isLegendPlacedHorizontaly ? plotWidth - legendWidth : plotWidth;
return isLegendPlacedHorizontaly ? plotWidth + legendWidth : plotWidth;
}

getPlotWithLegendHeight() {
const containerHeight = this.scope.jqcontainer.parents('.output_subarea').height();
const plotHeight = containerHeight && containerHeight < this.scope.layout.plotSize.height
? containerHeight
: this.scope.layout.plotSize.height;
const legendPosition = this.scope.stdmodel.legendPosition.position;
// Logic based on updateLegendPosition method
const isLegendPlacedHorizontaly = (
(["LEFT", "RIGHT"].indexOf(legendPosition) !== -1)
|| (["TOP", "BOTTOM"].indexOf(legendPosition) === -1 && this.scope.stdmodel.legendLayout === "VERTICAL")
);

let legendHeight = this.scope.jqlegendcontainer.find('.plot-legend').height() || 0;

legendHeight = legendHeight ? legendHeight + this.scope.layout.legendMargin + 2 : 0;

return isLegendPlacedHorizontaly ? plotHeight : plotHeight + legendHeight;
}

setResizable() {
Expand Down
2 changes: 2 additions & 0 deletions js/notebook/src/plot/std/axis/DefaultAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default class DefaultAxis {
numIntws: any[];

axisLabelWithCommon: any;
showGridlineLabels: boolean;

constructor(type: any) {
this.axisType = type == null ? "linear" : type; // linear, log, time, category, nanotime
Expand All @@ -68,6 +69,7 @@ export default class DefaultAxis {
this.axisFixedLabels = {};
this.dateIntws = [];
this.numIntws = [];
this.showGridlineLabels = true;

this.setNumFixs();
}
Expand Down

0 comments on commit 29f02fb

Please sign in to comment.