Series without primary instrument

Sample of how to add a series to a chart without having a primary instrument

by sonylnagale

HTML

<link rel="stylesheet" href="https://jsfiddle.chartiq.com/chart/css/stx-chart.css">
<div class="chartContainer" style="width:100%;height:400px;position:relative;"></div>

<script src="https://jsfiddle.chartiq.com/chart/js/chartiq.js"></script>

JavaScript

// Declare a CIQ.ChartEngine object. This is the main object for drawing charts.
const stxx=new CIQ.ChartEngine({container:$$$(".chartContainer")}); 

// render a chart with no primary series:
stxx.loadChart();

// Set the periodicity to match what is in your series
stxx.setPeriodicityV2(1,"day");

const axis = new CIQ.ChartEngine.YAxis()
axis.min = 0
axis.max = 1000
stxx.setChartType('line')


// James: Add a series renderer and axis to the axis desired
var renderer = stxx.setSeriesRenderer(
	new CIQ.Renderer.Lines({ params: { name: "my-renderer", type: "line", yAxis: axis } })
);

// Now add each series. 
// 'shareYAxis' puts each series on the same y-axis
// 'permanent' prevents users from deleting a series by right clicking

stxx.addSeries("AAPL", {
  color:"#FF0000", 
  data:[{Date:"20160210",Close:140},{Date:"20160211",Close:141},{Date:"20160212",Close:141.2},{Date:"20160220",Close:138},{Date:"20160221",Close:141.5}], 
  shareYAxis:true,
  yAxis: axis
});

stxx.addSeries("SPY", {
  color:"#00FF00", 
  data:[{Date:"20160218",Close:138},{Date:"20161108",Close:137},{Date:"20161109",Close:135}], 
  shareYAxis:true, 
  yAxis: axis
  
});

stxx.addSeries("GOOG", {
  color:"#0000FF", 
  data:[{Date:"20161022",Close:142},{Date:"20161023",Close:140},{Date:"20161024",Close:141}], 
  shareYAxis:true,
  yAxis: axis
});