Loading Static data to a chart with Ajax/JSON
This fiddle demonstrates how to load a static set of data into a chart and render it using Ajax/JSON
by sonylnagale
HTML
<link rel="stylesheet" type="text/css" href="https://jsfiddle.chartiq.com/chart/css/stx-chart.css" media="screen" />
<div class="chartContainer" style="width:100%;height:400px;position:relative;"></div>
<!--[if IE 8]><script>alert("This template is not compatible with IE8");</script><![endif]-->
JavaScript
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);
const stxx = new CIQ.ChartEngine({
container: document.querySelector(".chartContainer")
}); // Declare a CIQ.ChartEngine object. This is the main object for drawing charts.
const symbol = "SPY";
CIQ.postAjax("https://jsfiddle.chartiq.com/sample_json.js?symbol=" + symbol, null, function(status, response) {
if (status != 200) {
return;
}
var yourData = JSON.parse(response);
stxx.loadChart(
symbol,
yourData,
null, {
periodicity: {
period: 1,
interval: 'day'
}
}
);
});