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";
/********** emulator to simulate demo server-side data *******/
for (let i = 0; i < sampleData.length; i++) {
sampleData[i]["field1"] = sampleData[i].Close;
sampleData[i]["field2"] = sampleData[i].Volume;
}
/*************************************************************/
// Declare a CIQ.ChartEngine object. This is the main object for drawing charts.
var stxx = new CIQ.ChartEngine({
container: document.querySelector(".chartContainer")
});
// render a new chart with your data.
stxx.loadChart("SPY", sampleData, function() {
// add anything you want done in this callback
// In this case we are adding a few studies using server side data. So no calculation functions are used
// Define your studies.
// You can define a calculate function but if the data is precalculated,
// then you only need to set the series name and color.
// This can be done directly when calling CIQ.Studies.addStudy, or by first adding an entry to CIQ.Studies.studyLibrary.
// We provide both examples here.
// Complete documentation is here: http://documentation.chartiq.com/tutorial-Custom%20Studies.html
CIQ.Studies.studyLibrary["Plot High Low"] = {
"seriesFN": CIQ.Studies.displaySeriesAsHistogram,
inputs: {
"HistogramType": "stacked"
},
outputs: {
"High": "blue",
"Low": "red"
}
};
CIQ.Studies.studyLibrary["Plot Open Close"] = {
outputs: {
"Close": "blue",
"Open": "purple"
}
};
// Add a study to see it on the screen.
// They will display in the order that they are pushed onto the screen.
// These ones have a study library already defined
CIQ.Studies.addStudy(stxx, "Plot High Low");
CIQ.Studies.addStudy(stxx,...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.