Initialize the chart to display data from Daimler.
const token = ''; // Authentication token to gain access to frontgate
const fdsContainer = new FdsComponents('#fdsg-container');
const idNotation = 161766; // daimler
const mdg2Client = fdsContainer.createMdg2Client(token);
const orders = [{
time: new Date('2021-03-31 14:00:00'),
price: 75,
number: 'ORD1',
type: 'SELL',
instrumentName: 'Daimler AG',
wknIsin: 'DE0007100000',
exchange: 'FRA',
amount: 200,
limit: 70,
limitType: 'PRICE',
orderAddition: '',
orderStatus: 'EXECUTED',
validity: 'Yes',
}];
const props = {
mdg2Client,
idNotation,
id: 0,
spans: ['intraday', '5d', '10d', '1m', '3m', '6m', '1y', '3y', '5y', '10y', 'max'],
periods: ['1m', '5m', '10m', '15m', '30m', '1h', '1d', '1w', '30d'],
showPreviousDayQuote: false,
isColorblindMode: true,
news: [{ time: new Date(), id: 0, headline: 'this is not real data' }],
orders: orders,
};
await mdg2Client.connect();
await fdsContainer.init(props, {
'onLayoutChanged': (layout) => console.log(layout),
'onBenchmarksChanged': (benchmarks) => console.log(benchmarks),
'ready': () => console.log('chart is ready'),
'benchmark-edit-start': () => console.log('benchmark edit called'),
'benchmark-add-click': (event) => console.log('add value clicked'),
});
// Props are reactive and can be manipulated later on, for example to turn off color blind mode
props.isColorblindMode = false;
| Properties | ||
|---|---|---|
| mdg2Client | The logged in mdg2Client | Required |
| id | The id of the chart | Required |
| idNotation | The id notation of the instrument | Required |
| spans | The spans available to select from | Required |
| periods | The periods available to select from | Required |
| showPreviousDayQuote | Show or hide the line for the previous day quote | Optional, defaults to false |
| isColorblindMode | Activate or disable color blind mode | Optional, defaults to false |
| news | News objects that can be displayed as markers ({ time: Date, headline: string, id: string }) | Optional |
| orders | Order objects that are used to display the order markers | Optional |
| showPeriodSelect | Enable/Disable the period selector | Optional, defaults to true |
| showStudySelect | Enable/Disable the study selector | Optional, defaults to true |
| showTypeSelect | Enable/Disable the type selector | Optional, defaults to true |
| showTooltipToggle | Enable/Disable the tooltip toggle | Optional, defaults to true |
| showBenchmarkLegend | Enable/Disable the benchmark legend | Optional, defaults to true |
| showDrawingsToggle | Enable/Disable the drawings toggle | Optional, defaults to true |
| showVolumeStudy | Enable/Disable the volume study in the bottom panel | Optional, defaults to true |
| Listeners | ||
| onLayoutChanged | A callback that is called whenever a layout change is detected | Optional |
| onBenchmarksChanged | A callback that is called whenever a benchmarks change is detected | Optional |
| benchmark-edit-start | A callback that is called when a benchmark legend item is clicked | Optional |
| ready | A callback that is called once the chart has been initialized | Optional |
| initError | A callback that is called if the initialization of the chart fail | Optional |
The wrapper exposes several methods to interact with it.
fdsContainer.setLanguage('de');
| Method | Description | Parameters | Returns |
|---|---|---|---|
| setLanguage | Set the language of the chart | The language, for example de or en | - |
The chart exposes several methods to interact with it.
const chart = fdsContainer.getChart();
// Export the chart as PNG
const image = await chart.exportPng();
// Add, edit and remove a benchmark
chart.addBenchmark('20735', 'red');
chart.editBenchmark('20735', 'blue');
// Edit benchmark and set line width to 20px
chart.editBenchmark('20735', 'blue', 20);
chart.removeBenchmark('20735');
// Add and remove a custom limit with an icon
const id = 'custom-limit-1';
const price = 202.12;
const color = 'blue'; // or #0000ff
const icon = new Image();
// The image must be available in the same host so that it can show up in the PNG export
icon.src = '/locally-available.png';
chart.addLimit(id, price, color, icon);
chart.removeLimit(id);
// The icon is optional, so the following is possible as well
chart.addLimit('other-id', 12.99, 'blue');
// Set the date range to display
chart.setRange(new Date('2021-01-10'), new Date('2021-01-13'));
// Enable markers
chart.enableNews();
chart.enableDividends();
chart.enableCompanyEvents();
chart.enableOrders();
// Disable markers
chart.disableNews();
chart.disableDividends();
chart.disableCompanyEvents();
chart.disableOrders();
// Import Layout
// The layout can be obtained from the onLayoutChanged event listener
const layout = {}; // You want to use the layout given to you by the chart here
chart.importLayout(layout);
// Studies
const study = chart.addStudy('ATX');
chart.removeStudy(study);
// Selects
chart.hideAllSelects();
// Set span to 1 month
chart.setSpan('1m');
// Set chart scale to percent
chart.setChartScale('percent');
| Method | Description | Parameters | Returns |
|---|---|---|---|
| exportPng | Exports the chart as PNG, just as it currently is displayed | - | A Promise that resolves to an Image |
| addBenchmark | Add a benchmark to the current chart | idNotation Color of the graph | - |
| editBenchmark | Edit a benchmark in the current chart | idNotation New color of the graph (optional) new width of line | - |
| removeBenchmark | Remove a benchmark from the current chart | idNotation | - |
| addLimit | Add a custom limit line to the chart | id: Identifier to differentiate multiple limits price: Limit price color: The color of the line icon: The icon to the displayed over the line | - |
| removeLimit | Remove a custom limit line from the chart | id: Identifier to differentiate multiple limits | - |
| setRange | Sets the date range to be displayed. Always uses EOD data. | dateFrom: A Date object representing the start of the range dateTo: A Date object representing the end of the range, must be greater than dateFrom | - |
| enableNews | Show the news marker on the chart | - | - |
| enableDividends | Fetch and show the dividends marker on the chart | - | - |
| enableCompanyEvents | Fetch and show the company events marker on the chart | - | - |
| enableOrders | Display the inserted orders | - | - |
| disableNews | Remove the news marker on the chart | - | - |
| disableDividends | Remove the dividends marker on the chart | - | - |
| disableCompanyEvents | Remove the company events marker on the chart | - | - |
| disableOrders | Stop displaying orders in the chart | - | - |
| importLayout | Import the layout of a chart (user preferences) | layout | - |
| addStudy | Activate a study of a certain type | Type | Study object |
| removeStudy | Remove a study of a certain type | Study object | - |
| hideAllSelects | Hide all the open selects | - | - |
| setSpan | Set the currently displayed span | The identifier of the span. Throws an error if the identifier is not activated. | - |
| setChartScale | Set the current scale of the chart | log | linear | percent | relative | - |