Setting the Width of a Study

by sonylnagale

HTML

<link rel="stylesheet" href="https://jsfiddle.chartiq.com/chart/css/stx-chart.css">
<div class="chartContainer" style="width:600px;height:400px;position:relative;"></div>
<script src="https://jsfiddle.chartiq.com/chart/examples/data/STX_SAMPLE_DAILY.js"></script>
<script src="https://jsfiddle.chartiq.com/chart/js/chartiq.js"></script>

JavaScript

window.addEventListener('load', () => {
  const chart = new CIQ.ChartEngine({
    container: document.querySelector('.chartContainer')
  })

window.stxx = chart

  chart.loadChart('SPY', sampleData, () => {
  	const myStudy = {}

    Object.assign(myStudy, CIQ.Studies.studyLibrary.ma)
    myStudy.renderer =  [
      { label:false,type: "line", field: "Signal", binding: { color: "Signal" }, baseColor: "transparent", width: 20 }
    ]
    myStudy.outputs = { Signal: "#00FF00" }
    myStudy.overlay = true

		// add this line if you will be loading the study at load time AND are using storage to save layout
    CIQ.Studies.addStudy(chart, "ma", { id: "Moving Average"}, null, null, 'chart', myStudy);
  })
      CIQ.Studies.addStudy(chart, "ma", { id: "Moving Average 2"}, null, null, 'chart');

})