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);
// Create your QuoteFeed object.
var myQuoteFeed = {};
myQuoteFeed.url = "https://jsfiddle.chartiq.com/sample_json.js";
// The chart uses a few different methods attached to your quotefeed to get data.
// This is where the action is, in these methods. params will tell you what the chart needs (symbol, interval, date ranges)
// Use that data to construct your query. Use our ajax, jquery, or any other method to fetch the data
// Make sure it's in the right format and return it in the callback like below. Always use cb() to return data from fetch methods! Even errors.
// This method is called by the chart to fetch initial data
myQuoteFeed.fetchInitialData = function(symbol, startDate, endDate, params, cb) {
console.log("params=", params);
var query = this.url +
"?symbol=" + symbol +
"&interval=" + params.interval +
"&startDate=" + CIQ.yyyymmddhhmm(startDate) +
"&endDate=" + CIQ.yyyymmddhhmm(endDate);
CIQ.postAjax(query, null, function(status, response) {
if (status == 200) {
cb({
quotes: JSON.parse(response),
moreAvailable: false
});
} else {
cb({
error: (response ? response : status)
});
}
});
// This sample assumes the response returns only the data and in the right format.
// Put your code here to format the response according to the specs
// and return it in the callback.
// Example code to iterate trough the reformatted responses and load them one at a time:
// var quotes=formatQuotes(response); // your function to creates a properly formated array.
// var newQuotes=[];
// for(var i=0;i<quotes.length;i++){
// newQuotes[i]={};
// newQuotes[i].Date=quotes[i][0]; // Or set newQuotes[i].DT if you have a JS Date
// newQuotes[i].Open=quotes[i][1];
...
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.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path.
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!