No primary series with a quote feed
Sample of how to render a chart with no primary series using a quote feed. Each series has it's own y axis
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/js/chartiq.js"></script>
<script src="https://jsfiddle.chartiq.com/chart/examples/feeds/quoteFeedSimulator.js"></script>
JavaScript
// start the chart engine
var stxx = new CIQ.ChartEngine({
container: $$$(".chartContainer")
});
// there will be no primary series so hide its axis
stxx.setYAxisPosition(stxx.chart.yAxis,"none");
// see spacial changes below required on update and pagination calls
// when there will be no primary series.
stxx.attachQuoteFeed(quoteFeedSimulator, {
refreshInterval: 1
});
// render a chart with no primary series:
// 1- set an empty symbol (make sure it has at least one character)
// 2- set an empty data array
stxx.loadChart("AAPL", [], function() {
stxx.addSeries("^AEDAFN", {
color: "green",
yAxis:{position:"right"} // give the series its own y-axis
});
stxx.addSeries("^AEDAFR", {
color: "red",
yAxis:{position:"right"} // give the series its own y-axis
});
stxx.addSeries("^AEDAFQ", {
color: "blue",
yAxis:{position:"right"} // give the series its own y-axis
});
});
/***************************************************************************/
/*********** Here is a modification of the quoteFeedSimulator *************/
/*********** to allow for a chart with no primary series. *****************/
/*********** Make sure updates or pagination requests for the **************/
/*********** empty symbol (" ") never return any data to guarantee *********/
/*********** nothing displays for the primary series ***********************/
/***************************************************************************/
quoteFeedSimulator.fetchUpdateData = function(symbol, startDate, params, cb) {
if(symbol == " ") { // !!! force no data for primary series
cb({
quotes: [] // always return an empty array on the callback
});
return;
}
var queryUrl = this.url +
"&identifier=" + symbol +
"&startdate=" + startDate.toISOString() +
"&interval=" + params.interval +
"&period=" + params.period +
"&extended=" + (params.extended ? 1 : 0); // using filter:true for after hours
CIQ.postAjax(queryUrl, null,...