Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

* Updated definition of the `Instrument` context type to include optional market identifiers ([#819](https://github.com/finos/FDC3/pull/819))
* Corrected API functions and object types to always use `string` instead of `String` ([#924](https://github.com/finos/FDC3/pull/924))
* Updated definition of the `otherConfig` element of the `Chart` context type from an Object to an array of Contexts as this allows the `type` of each additional item of config to be examined before it is used ([#985](https://github.com/finos/FDC3/pull/985))

### Deprecated

Expand Down
36 changes: 20 additions & 16 deletions docs/context/ref/Chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In addition to handling requests to plot charts, a charting application may use

## Schema

https://fdc3.finos.org/schemas/next/chart.schema.json
[https://fdc3.finos.org/schemas/next/chart.schema.json](https://fdc3.finos.org/schemas/next/chart.schema.json)

## Details

Expand All @@ -31,9 +31,9 @@ https://fdc3.finos.org/schemas/next/chart.schema.json
| `instruments` | Instrument[] | Yes | <pre>[<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.instrument",<br/>&emsp;&emsp;&emsp;&emsp;"id": {<br/>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"ticker": "AAPL"<br/>&emsp;&emsp;&emsp;&emsp;}<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.instrument",<br/>&emsp;&emsp;&emsp;&emsp;"id": {<br/>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"ticker": "MSFT"<br/>&emsp;&emsp;&emsp;&emsp;}<br/>&emsp;&emsp;}<br/>]</pre> |
| `range` | TimeRange | No | <pre>{<br/>&emsp;&emsp;"type": "fdc3.timerange",<br/>&emsp;&emsp;"startTime": "2022-03-30T15:44:44+00:00",<br/>&emsp;&emsp;"endTime": "2022-04-30T23:59:59+00:00"<br/>}</pre> |
| `style` | string | No | one of: `'line'`, `'bar'`, `'stacked-bar'`, `'mountain'`, `'candle'`, `'pie'`, `'scatter'`, `'histogram'`, `'heatmap'`, `'custom'` |
| `otherConfig`* | object | No | `{ /* unstandardized additional config */}` |
| `otherConfig`* | array | No | `[ {/* additional config context objects */} ]` |

\* It is common for charts to support other configuration, such as indicators, annotations etc., which do not have standarized formats, but may be included in the `otherConfig` element.
\* It is common for charts to support other configuration, such as indicators, annotations etc., which do not have standardized formats, but may be included in the `otherConfig` array as context objects.

## Example

Expand All @@ -60,20 +60,24 @@ const chart = {
endTime: "2020-10-31T08:00:00.000Z"
},
style: "line",
otherConfig: {
indicators: [
{
name: "ma",
parameters: {
period: 14,
type: "ema"
}
},
{
name: "volume"
otherConfig: [
{
type: "somevendor.someproduct.indicator",
name: "stddev",
parameters: {
period: 10,
matype: "exponential"
}
]
}
},
{
type: "someothervendor.someotherproduct.formula",
formula: "standard-deviation",
fields: {
lookback: 10,
type: "ema"
}
}
]
};

fdc3.raiseIntent("ViewChart", chart);
Expand Down
19 changes: 17 additions & 2 deletions src/context/ContextTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

export interface Chart {
instruments: InstrumentElement[];
otherConfig?: { [key: string]: any };
otherConfig?: OtherConfigElement[];
range?: TimeRangeObject;
style?: Style;
type: string;
Expand Down Expand Up @@ -62,6 +62,13 @@ export interface PurpleMarket {
[property: string]: any;
}

export interface OtherConfigElement {
id?: { [key: string]: any };
name?: string;
type: string;
[property: string]: any;
}

export interface TimeRangeObject {
endTime?: Date;
startTime?: Date;
Expand Down Expand Up @@ -600,7 +607,7 @@ const typeMap: any = {
Chart: o(
[
{ json: 'instruments', js: 'instruments', typ: a(r('InstrumentElement')) },
{ json: 'otherConfig', js: 'otherConfig', typ: u(undefined, m('any')) },
{ json: 'otherConfig', js: 'otherConfig', typ: u(undefined, a(r('OtherConfigElement'))) },
{ json: 'range', js: 'range', typ: u(undefined, r('TimeRangeObject')) },
{ json: 'style', js: 'style', typ: u(undefined, r('Style')) },
{ json: 'type', js: 'type', typ: '' },
Expand Down Expand Up @@ -641,6 +648,14 @@ const typeMap: any = {
],
'any'
),
OtherConfigElement: o(
[
{ json: 'id', js: 'id', typ: u(undefined, m('any')) },
{ json: 'name', js: 'name', typ: u(undefined, '') },
{ json: 'type', js: 'type', typ: '' },
],
'any'
),
TimeRangeObject: o(
[
{ json: 'endTime', js: 'endTime', typ: u(undefined, Date) },
Expand Down
5 changes: 4 additions & 1 deletion src/context/schemas/chart.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
"enum": [ "line", "bar", "stacked-bar", "mountain", "candle", "pie", "scatter", "histogram", "heatmap", "custom"]
},
"otherConfig": {
"type": "object"
"type": "array",
"items": {
"$ref": "context.schema.json#"
}
}
},
"required": ["instruments"]
Expand Down