Set range and freeze screen
by sonylnagale
HTML
<link rel="stylesheet" type="text/css" href="https://jsfiddle.chartiq.com/chart/css/stx-chart.css" media="screen" />
<div class="chartContainer" style="width:600px;height:400px;position:relative;"></div>
JavaScript
import { CIQ } from "https://jsfiddle.chartiq.com/chart/js/advanced.js";
// Activate the License Key
import getLicenseKey from "https://jsfiddle.chartiq.com/chart/key.js";
getLicenseKey(CIQ);
import sampleData from "https://jsfiddle.chartiq.com/chart/examples/data/STX_SAMPLE_DAILY.js";
CIQ.ChartEngine.prototype.prepend("drawXAxis", () => {
// stxx.chart.panel.left = 0;
//stxx.chart.panel.width = 600;
})
const stxx = new CIQ.ChartEngine({
container: document.querySelector(".chartContainer"),
layout: {
chartType: "mountain",
}
}); // Declare a CIQ.ChartEngine object. This is the main object for drawing charts.
// disable zoom and scroll
stxx.allowZoom = false;
stxx.allowScroll = false;
//remove the zoom and home buttons from the screen
stxx.controls["chartControls"] = null;
stxx.controls["home"] = null;
//stxx.chart.yaxisPaddingLeft = 50;
//stxx.chart.yaxisPaddingRight = 100;
stxx.calculateYAxisPositions();
stxx.loadChart(
"SPY",
{
masterData: sampleData,
range: {
dtLeft: new Date(2012, 10, 15),
dtRight: new Date(2012, 10, 25),
}
}
);
console.log(stxx.chart.panel.width, stxx.chart.panel.left)