Skip to content

Commit fdbd1c5

Browse files
authored
Merge pull request #985 from finos/856-chart-otherconfig-improvement
updating definition of otherConfig in fdc3.chart to use an array of context objects
2 parents 7abfe73 + 8015083 commit fdbd1c5

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2323
### Changed
2424

2525
* Updated definition of the `ChatInitSettings` context type to use the new `Message` type. ([#779](https://github.com/finos/FDC3/pull/779))
26+
* Updated the `StartChat` intent to return a reference to the room. ([#794](https://github.com/finos/FDC3/pull/794))
2627
* Updated definition of the `Instrument` context type to include optional market identifiers ([#819](https://github.com/finos/FDC3/pull/819))
2728
* Corrected API functions and object types to always use `string` instead of `String` ([#924](https://github.com/finos/FDC3/pull/924))
28-
* Updated the `StartChat` intent to return a reference to the room. ([#794](https://github.com/finos/FDC3/pull/794))
29+
* 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))
2930

3031
### Deprecated
3132

docs/context/ref/Chart.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ In addition to handling requests to plot charts, a charting application may use
2121

2222
## Schema
2323

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

2626
## Details
2727

@@ -31,9 +31,9 @@ https://fdc3.finos.org/schemas/next/chart.schema.json
3131
| `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> |
3232
| `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> |
3333
| `style` | string | No | one of: `'line'`, `'bar'`, `'stacked-bar'`, `'mountain'`, `'candle'`, `'pie'`, `'scatter'`, `'histogram'`, `'heatmap'`, `'custom'` |
34-
| `otherConfig`* | object | No | `{ /* unstandardized additional config */}` |
34+
| `otherConfig`* | array | No | `[ {/* additional config context objects */} ]` |
3535

36-
\* 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.
36+
\* 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.
3737

3838
## Example
3939

@@ -60,20 +60,24 @@ const chart = {
6060
endTime: "2020-10-31T08:00:00.000Z"
6161
},
6262
style: "line",
63-
otherConfig: {
64-
indicators: [
65-
{
66-
name: "ma",
67-
parameters: {
68-
period: 14,
69-
type: "ema"
70-
}
71-
},
72-
{
73-
name: "volume"
63+
otherConfig: [
64+
{
65+
type: "somevendor.someproduct.indicator",
66+
name: "stddev",
67+
parameters: {
68+
period: 10,
69+
matype: "exponential"
7470
}
75-
]
76-
}
71+
},
72+
{
73+
type: "someothervendor.someotherproduct.formula",
74+
formula: "standard-deviation",
75+
fields: {
76+
lookback: 10,
77+
type: "ema"
78+
}
79+
}
80+
]
7781
};
7882

7983
fdc3.raiseIntent("ViewChart", chart);

src/context/ContextTypes.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
export interface Chart {
2626
instruments: InstrumentElement[];
27-
otherConfig?: { [key: string]: any };
27+
otherConfig?: OtherConfigElement[];
2828
range?: TimeRangeObject;
2929
style?: Style;
3030
type: string;
@@ -62,6 +62,13 @@ export interface PurpleMarket {
6262
[property: string]: any;
6363
}
6464

65+
export interface OtherConfigElement {
66+
id?: { [key: string]: any };
67+
name?: string;
68+
type: string;
69+
[property: string]: any;
70+
}
71+
6572
export interface TimeRangeObject {
6673
endTime?: Date;
6774
startTime?: Date;
@@ -623,7 +630,7 @@ const typeMap: any = {
623630
Chart: o(
624631
[
625632
{ json: 'instruments', js: 'instruments', typ: a(r('InstrumentElement')) },
626-
{ json: 'otherConfig', js: 'otherConfig', typ: u(undefined, m('any')) },
633+
{ json: 'otherConfig', js: 'otherConfig', typ: u(undefined, a(r('OtherConfigElement'))) },
627634
{ json: 'range', js: 'range', typ: u(undefined, r('TimeRangeObject')) },
628635
{ json: 'style', js: 'style', typ: u(undefined, r('Style')) },
629636
{ json: 'type', js: 'type', typ: '' },
@@ -664,6 +671,14 @@ const typeMap: any = {
664671
],
665672
'any'
666673
),
674+
OtherConfigElement: o(
675+
[
676+
{ json: 'id', js: 'id', typ: u(undefined, m('any')) },
677+
{ json: 'name', js: 'name', typ: u(undefined, '') },
678+
{ json: 'type', js: 'type', typ: '' },
679+
],
680+
'any'
681+
),
667682
TimeRangeObject: o(
668683
[
669684
{ json: 'endTime', js: 'endTime', typ: u(undefined, Date) },

src/context/schemas/chart.schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
"enum": [ "line", "bar", "stacked-bar", "mountain", "candle", "pie", "scatter", "histogram", "heatmap", "custom"]
2121
},
2222
"otherConfig": {
23-
"type": "object"
23+
"type": "array",
24+
"items": {
25+
"$ref": "context.schema.json#"
26+
}
2427
}
2528
},
2629
"required": ["instruments"]

0 commit comments

Comments
 (0)