Skip to content

Commit

Permalink
Simplified stock demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
bre1470 committed Aug 9, 2024
1 parent bd2f205 commit a1e032e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 51 deletions.
5 changes: 2 additions & 3 deletions demos/stock/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://code.highcharts.com/dashboards/2.2.0/css/dashboards.css" />
<script src="https://code.highcharts.com/dashboards/2.2.0/dashboards.src.js"></script>
<script src="../../code/morningstar-connectors.src.js"></script>
<script src="https://code.highcharts.com/stock/highstock.src.js"></script>
<script src="../../code/morningstar-standalone.src.js"></script>
<title>Highcharts Stock Demo - Morningstar Connectors Demos</title>
</head>
<body>
Expand Down
94 changes: 46 additions & 48 deletions demos/stock/demo.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@
document.getElementById('postman-json').addEventListener(
'change',
async function (
evt
) {
async function (evt) {
const target = evt.target;
const postmanJSON = JSON.parse(await target.files[0]?.text());
const postmanJSON = await getPostmanJSON(evt.target);

if (!postmanJSON) {
return;
}

target.parentNode.style.display = 'none';

Dashboards.board('container', {
dataPool: {
connectors: [{
id: 'morningstar-dividend',
type: 'MorningstarTimeSeries',
options: {
postman: {
environmentJSON: postmanJSON
},
series: 'Dividend',
securities: [{
id: 'F0GBR06KY1',
idType: 'MSID'
}, {
id: 'LU0011963245USD',
idType: 'ISIN'
}],
startDate: '2020-01-01',
endDate: '2024-12-31'
}
}]
const dividendConnector = new MorningstarConnectors.TimeSeriesConnector({
postman: {
environmentJSON: postmanJSON
},
gui: {
layouts: [{
id: 'layout-1',
rows: [{
cells: [{
id: 'dashboard-col-0'
}]
}]
}]
series: {
type: 'Dividend'
},
components: [{
renderTo: 'dashboard-col-0',
connector: {
id: 'morningstar-dividend',
columnAssignment: [{
seriesId: 'F0GBR06KY1',
data: ['Date', 'F0GBR06KY1']
}, {
seriesId: 'LU0011963245USD',
data: ['Date', 'LU0011963245USD']
}]
},
type: 'Highcharts',
chartConstructor: 'stockChart',
securities: [{
id: 'F0GBR06KY1',
idType: 'MSID'
}, {
id: 'LU0011963245USD',
idType: 'ISIN'
}],
startDate: '2020-01-01',
endDate: '2024-12-31'
});

await dividendConnector.load();

Highcharts.stockChart('container', {
series: [{
type: 'line',
table: dividendConnector.dataTable
}]
});
});

async function getPostmanJSON (htmlInputFile) {
let file;
let fileJSON;

for (file of htmlInputFile.files) {
try {
fileJSON = JSON.parse(await file.text());
if (MorningstarConnectors.isPostmanEnvironmentJSON(fileJSON)) {
break;
}
} catch (error) {
// fail silently
}
}

return fileJSON
}

0 comments on commit a1e032e

Please sign in to comment.