Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ngstar into feature/add-docs
  • Loading branch information
Eskils committed Aug 20, 2024
2 parents 3e97075 + ae05bcd commit acb021c
Show file tree
Hide file tree
Showing 15 changed files with 342 additions and 198 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is the source code repository of the Highcharts Dashboards connectors for Morningstar Direct Web Services.
This is the source code repository of the Highcharts Connectors for Morningstar Direct Web Services.

Read more on licensing alternatives here:
- https://shop.highcharts.com/
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Morningstar Connectors
======================

Collection of [Highcharts Dashboards] connectors for
[Morningstar Direct Web Services].
Collection of [Highcharts Connectors] for [Morningstar Direct Web Services].



Expand All @@ -11,15 +10,19 @@ Usage

The connectors are available as

* ES6 modules by importing `@highcharts/morningstar-connectors` in your project.
* ES6 modules by importing `@highcharts/connectors-morningstar` in your project.

* UMD bundle by adding the `@highcharts/morningstar-connectors/dist/all.js`
script to your web app or web page.
* UMD bundle by adding the
`@highcharts/connectors-morningstar/connectors-morningstar.js` script to your
web app or web page.

**Note:** The UMD bundle is not available via
`https://code.highcharts.com/connectors/connectors-morningstar.js` yet.



<!-- Link References -->

[Highcharts Dashboards]: https://highcharts.com/dashboards/
[Highcharts Connectors]: https://highcharts.com/connectors/

[Morningstar Direct Web Services]: https://developer.morningstar.com/direct-web-services/
42 changes: 42 additions & 0 deletions demos/dashboards-rna-news/demo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@import url("https://code.highcharts.com/dashboards/css/datagrid.css");
@import url("https://code.highcharts.com/css/highcharts.css");
@import url("https://code.highcharts.com/dashboards/css/dashboards.css");

body {
font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
}

.row {
display: flex;
flex-wrap: wrap;
}

.cell {
flex: 1;
min-width: 20px;
}

.cell > .highcharts-dashboards-component {
position: relative;
margin: 10px;
background-clip: border-box;
}

.highcharts-dashboards-component-title {
padding: 10px;
margin: 0;
background-color: var(--highcharts-neutral-color-5);
color: var(--highcharts-neutral-color-100);
border: solid 1px var(--highcharts-neutral-color-20);
border-bottom: none;
}

#dashboard-col-1 .highcharts-dashboards-component-title {
background-color: #336;
}

@media screen and (max-width: 1000px) {
.row {
flex-direction: column;
}
}
24 changes: 24 additions & 0 deletions demos/dashboards-rna-news/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="demo.css" />
<script src="https://code.highcharts.com/dashboards/datagrid.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="../../code/connectors-morningstar.src.js"></script>
<title>Highcharts Dashboards + Morningstar RNA News</title>
</head>
<body>
<h1>Highcharts Dashboards + Morningstar RNA News</h1>
<p>
Add your Postman environment file from Morningstar to start the demo:
<input type="file" id="postman-json" accept=".json,application/json" />
</p>
<p id="loading-label" style="display: none;">Loading data…</p>
<div class="row" id="container">
<div class="cell" id="dashboard-col-0"></div>
<div class="cell" id="dashboard-col-1"></div>
</div>
<script src="./demo.js"></script>
</body>
</html>
190 changes: 190 additions & 0 deletions demos/dashboards-rna-news/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
const loadingLabel = document.getElementById('loading-label');

function displayRNANews (postmanJSON) {
const board = Dashboards.board('container', {
dataPool: {
connectors: [{
id: 'rna',
type: 'MorningstarRNANews',
options: {
security: {
id: 'GB00BLGZ9862',
idType: 'MSID'
},
postman: {
environmentJSON: postmanJSON
}
}
},
{
id: 'rna-type-amount',
type: 'JSON',
options: {
columnNames: ['Type', 'Amount'],
data: [
[],
[]
],
orientation: 'columns',
firstRowAsNames: false
}
}
]
},
components: [
{
renderTo: 'dashboard-col-0',
connector: {
id: 'rna'
},
type: 'DataGrid',
title: 'News',
dataGridOptions: {
editable: false,
columns: {
Day: {
cellFormatter: function () {
return new Date(this.value)
.toISOString()
.substring(0, 10);
}
}
}
}
},
{
renderTo: 'dashboard-col-1',
connector: {
id: 'rna-type-amount',
columnAssignment: [{
seriesId: 'number-per-type',
data: ['Type', 'Amount']
}]
},
type: 'Highcharts',
chartOptions: {
chart: {
animation: false,
type: 'column'
},
title: {
text: 'Number of items per type'
},
subtitle: {
text: 'Shows number of news items of each kind'
},
series: [{
id: 'number-per-type',
name: 'Number per type'
}],
tooltip: {
shared: true,
split: true,
stickOnContact: true
},
lang: {
accessibility: {
chartContainerLabel:
'Shows number of news items of each kind'
}
},
xAxis: {
type: 'category',
accessibility: {
description: 'Kind of news annoucement'
}
},
yAxis: {
title: {
text: 'Number of announcements'
}
}
}
}
]
});

board.dataPool
.getConnectorTable('rna')
.then(async table => {
const types = table.getColumn('Type');
const uniqueTypes = Array.from(new Set(types));
const numberPerType = uniqueTypes.map(type =>
types.reduce((previous, current) => {
if (current === type) {
return previous + 1;
}
return previous;
}, 0)
);

board.dataPool.setConnectorOptions({
id: 'rna-type-amount',
type: 'JSON',
options: {
columnNames: ['Type', 'Amount'],
orientation: 'columns',
firstRowAsNames: false,
data: [
uniqueTypes,
numberPerType
]
}
});

// Refresh the component after updating the table
await board.getComponentByCellId('dashboard-col-1').initConnectors();
await board.getComponentByCellId('dashboard-col-1').update({
connector: {
id: 'rna-type-amount',
columnAssignment: [{
seriesId: 'number-per-type',
data: ['Type', 'Amount']
}]
}
});
})
.finally(() => {
loadingLabel.style.display = 'none';
});
}

async function handleSelectEnvironment (evt) {
const target = evt.target;
const postmanJSON = await getPostmanJSON(target);

if (!postmanJSON) {
loadingLabel.textContent = 'The provided file is not a Postman Environment Configuration.';
loadingLabel.style.display = 'block';

return;
}

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

loadingLabel.style.display = 'block';
loadingLabel.textContent = 'Loading data…';

displayRNANews(postmanJSON);
}

document.getElementById('postman-json')
.addEventListener('change', handleSelectEnvironment);

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

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

return fileJSON;
}
7 changes: 4 additions & 3 deletions demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<title>Morningstar Connectors Demos</title>
</head>
<body>
<h1>Morningstar Connectors Demos</h1>
<ul>
<li><a href="rna-news/demo.html">Highcharts Dashboards RNA news demo</a></li>
<li><a href="stock/demo.html">Highcharts Stock demo</a></li>
<li><a href="dashboards-rna-news/demo.html">Highcharts Dashboards + Morningstar RNA News</a></li>
<li><a href="stock-timeseries/demo.html">Highcharts Stock + Morningstar TimeSeries</a></li>
</ul>
</body>
</html>
</html>
14 changes: 0 additions & 14 deletions demos/rna-news/demo.html

This file was deleted.

Loading

0 comments on commit acb021c

Please sign in to comment.