-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/highcharts/connectors-morni…
…ngstar into feature/add-docs
- Loading branch information
Showing
15 changed files
with
342 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.