Skip to content

Commit

Permalink
Don't adjust size simultaneously when options were applied to time scale
Browse files Browse the repository at this point in the history
Fixes #443
  • Loading branch information
timocov committed May 26, 2020
1 parent 4d66f57 commit ae27d22
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/gui/chart-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,7 @@ export class ChartWidget implements IDestroyable {

container.appendChild(this._element);
this._updateTimeAxisVisibility();
this._model.timeScale().optionsApplied().subscribe(
() => {
this._updateTimeAxisVisibility();
this.adjustSize();
},
this
);
this._model.timeScale().optionsApplied().subscribe(this._model.fullUpdate.bind(this._model), this);
}

public model(): ChartModel {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function generateBar(i, target) {
var step = (i % 20) / 1000;
var base = i / 5;
target.open = base * (1 - step);
target.high = base * (1 + 2 * step);
target.low = base * (1 - 2 * step);
target.close = base * (1 + step);
}

function generateData() {
var res = [];
var time = new Date(Date.UTC(2018, 0, 1, 0, 0, 0, 0));
for (var i = 0; i < 500; ++i) {
var item = {
time: time.getTime() / 1000,
};
time.setUTCDate(time.getUTCDate() + 1);

generateBar(i, item);
res.push(item);
}
return res;
}

// eslint-disable-next-line no-unused-vars
function runTestCase(container) {
var chart = LightweightCharts.createChart(container);

var mainSeries = chart.addCandlestickSeries();

mainSeries.setData(generateData());

chart.applyOptions({
leftPriceScale: { visible: true },
rightPriceScale: { visible: true },
timeScale: {},
});
}

0 comments on commit ae27d22

Please sign in to comment.