@grafana/viz-contract 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +201 -0
  3. package/README.md +140 -0
  4. package/fixtures/epoch-range/args.json +14 -0
  5. package/fixtures/epoch-range/meta.json +4 -0
  6. package/fixtures/epoch-range/request.json +17 -0
  7. package/fixtures/epoch-range/response.json +114 -0
  8. package/fixtures/epoch-range/result.json +252 -0
  9. package/fixtures/epoch-range/spec.json +141 -0
  10. package/fixtures/epoch-range/state.json +4 -0
  11. package/fixtures/error-all-queries-failed/spec.json +45 -0
  12. package/fixtures/error-all-queries-failed/state.json +8 -0
  13. package/fixtures/error-invalid-spec/spec.json +25 -0
  14. package/fixtures/error-invalid-spec/state.json +8 -0
  15. package/fixtures/error-unsupported-panel-type/spec.json +1372 -0
  16. package/fixtures/error-unsupported-panel-type/state.json +8 -0
  17. package/fixtures/error-unsupported-spec-version/spec.json +1372 -0
  18. package/fixtures/error-unsupported-spec-version/state.json +8 -0
  19. package/fixtures/hostile-label/args.json +14 -0
  20. package/fixtures/hostile-label/meta.json +4 -0
  21. package/fixtures/hostile-label/request.json +17 -0
  22. package/fixtures/hostile-label/response.json +420 -0
  23. package/fixtures/hostile-label/result.json +558 -0
  24. package/fixtures/hostile-label/spec.json +447 -0
  25. package/fixtures/hostile-label/state.json +4 -0
  26. package/fixtures/no-data/args.json +14 -0
  27. package/fixtures/no-data/meta.json +4 -0
  28. package/fixtures/no-data/request.json +17 -0
  29. package/fixtures/no-data/response.json +40 -0
  30. package/fixtures/no-data/result.json +178 -0
  31. package/fixtures/no-data/spec.json +67 -0
  32. package/fixtures/no-data/state.json +4 -0
  33. package/fixtures/partial-error/args.json +20 -0
  34. package/fixtures/partial-error/meta.json +4 -0
  35. package/fixtures/partial-error/request.json +28 -0
  36. package/fixtures/partial-error/response.json +220 -0
  37. package/fixtures/partial-error/result.json +358 -0
  38. package/fixtures/partial-error/spec.json +253 -0
  39. package/fixtures/partial-error/state.json +9 -0
  40. package/fixtures/pick-annotations-only/args.json +10 -0
  41. package/fixtures/pick-annotations-only/meta.json +4 -0
  42. package/fixtures/pick-annotations-only/response.json +41 -0
  43. package/fixtures/pick-annotations-only/result.json +53 -0
  44. package/fixtures/pick-categories/args.json +10 -0
  45. package/fixtures/pick-categories/meta.json +4 -0
  46. package/fixtures/pick-categories/response.json +58 -0
  47. package/fixtures/pick-categories/result.json +116 -0
  48. package/fixtures/pick-empty-result/args.json +10 -0
  49. package/fixtures/pick-empty-result/meta.json +4 -0
  50. package/fixtures/pick-empty-result/response.json +11 -0
  51. package/fixtures/pick-empty-result/result.json +23 -0
  52. package/fixtures/pick-failed-query-with-frames/args.json +10 -0
  53. package/fixtures/pick-failed-query-with-frames/meta.json +4 -0
  54. package/fixtures/pick-failed-query-with-frames/response.json +43 -0
  55. package/fixtures/pick-failed-query-with-frames/result.json +131 -0
  56. package/fixtures/pick-few-parts/args.json +10 -0
  57. package/fixtures/pick-few-parts/meta.json +4 -0
  58. package/fixtures/pick-few-parts/response.json +40 -0
  59. package/fixtures/pick-few-parts/result.json +98 -0
  60. package/fixtures/pick-heatmap-cells/args.json +10 -0
  61. package/fixtures/pick-heatmap-cells/meta.json +4 -0
  62. package/fixtures/pick-heatmap-cells/response.json +55 -0
  63. package/fixtures/pick-heatmap-cells/result.json +143 -0
  64. package/fixtures/pick-log-lines/args.json +10 -0
  65. package/fixtures/pick-log-lines/meta.json +4 -0
  66. package/fixtures/pick-log-lines/response.json +49 -0
  67. package/fixtures/pick-log-lines/result.json +76 -0
  68. package/fixtures/pick-no-rows/args.json +10 -0
  69. package/fixtures/pick-no-rows/meta.json +4 -0
  70. package/fixtures/pick-no-rows/response.json +32 -0
  71. package/fixtures/pick-no-rows/result.json +120 -0
  72. package/fixtures/pick-node-graph/args.json +10 -0
  73. package/fixtures/pick-node-graph/meta.json +4 -0
  74. package/fixtures/pick-node-graph/response.json +77 -0
  75. package/fixtures/pick-node-graph/result.json +89 -0
  76. package/fixtures/pick-numeric-only/args.json +10 -0
  77. package/fixtures/pick-numeric-only/meta.json +4 -0
  78. package/fixtures/pick-numeric-only/response.json +40 -0
  79. package/fixtures/pick-numeric-only/result.json +89 -0
  80. package/fixtures/pick-single-stat/args.json +10 -0
  81. package/fixtures/pick-single-stat/meta.json +4 -0
  82. package/fixtures/pick-single-stat/response.json +29 -0
  83. package/fixtures/pick-single-stat/result.json +69 -0
  84. package/fixtures/pick-time-series-instant/args.json +10 -0
  85. package/fixtures/pick-time-series-instant/meta.json +4 -0
  86. package/fixtures/pick-time-series-instant/response.json +40 -0
  87. package/fixtures/pick-time-series-instant/result.json +128 -0
  88. package/fixtures/pick-time-series-long/args.json +10 -0
  89. package/fixtures/pick-time-series-long/meta.json +4 -0
  90. package/fixtures/pick-time-series-long/response.json +61 -0
  91. package/fixtures/pick-time-series-long/result.json +167 -0
  92. package/fixtures/pick-time-series-multi-frame/args.json +10 -0
  93. package/fixtures/pick-time-series-multi-frame/meta.json +4 -0
  94. package/fixtures/pick-time-series-multi-frame/response.json +74 -0
  95. package/fixtures/pick-time-series-multi-frame/result.json +162 -0
  96. package/fixtures/pick-time-series-null-time/args.json +10 -0
  97. package/fixtures/pick-time-series-null-time/meta.json +4 -0
  98. package/fixtures/pick-time-series-null-time/response.json +40 -0
  99. package/fixtures/pick-time-series-null-time/result.json +128 -0
  100. package/fixtures/pick-time-series-single/args.json +10 -0
  101. package/fixtures/pick-time-series-single/meta.json +4 -0
  102. package/fixtures/pick-time-series-single/response.json +40 -0
  103. package/fixtures/pick-time-series-single/result.json +128 -0
  104. package/fixtures/pick-time-series-wide/args.json +10 -0
  105. package/fixtures/pick-time-series-wide/meta.json +4 -0
  106. package/fixtures/pick-time-series-wide/response.json +61 -0
  107. package/fixtures/pick-time-series-wide/result.json +149 -0
  108. package/fixtures/prometheus-line/args.json +14 -0
  109. package/fixtures/prometheus-line/meta.json +4 -0
  110. package/fixtures/prometheus-line/request.json +17 -0
  111. package/fixtures/prometheus-line/response.json +1344 -0
  112. package/fixtures/prometheus-line/result.json +1483 -0
  113. package/fixtures/prometheus-line/spec.json +1372 -0
  114. package/fixtures/prometheus-line/state.json +4 -0
  115. package/fixtures/smoke-barchart/spec.json +64 -0
  116. package/fixtures/smoke-barchart/state.json +4 -0
  117. package/fixtures/smoke-boxplot/spec.json +96 -0
  118. package/fixtures/smoke-boxplot/state.json +4 -0
  119. package/fixtures/smoke-bubble/spec.json +229 -0
  120. package/fixtures/smoke-bubble/state.json +4 -0
  121. package/fixtures/smoke-candlestick/spec.json +97 -0
  122. package/fixtures/smoke-candlestick/state.json +4 -0
  123. package/fixtures/smoke-chord/spec.json +72 -0
  124. package/fixtures/smoke-chord/state.json +4 -0
  125. package/fixtures/smoke-funnel/spec.json +62 -0
  126. package/fixtures/smoke-funnel/state.json +4 -0
  127. package/fixtures/smoke-geomap/spec.json +76 -0
  128. package/fixtures/smoke-geomap/state.json +4 -0
  129. package/fixtures/smoke-heatmap/spec.json +103 -0
  130. package/fixtures/smoke-heatmap/state.json +4 -0
  131. package/fixtures/smoke-histogram/spec.json +63 -0
  132. package/fixtures/smoke-histogram/state.json +4 -0
  133. package/fixtures/smoke-nodeGraph/spec.json +101 -0
  134. package/fixtures/smoke-nodeGraph/state.json +4 -0
  135. package/fixtures/smoke-parallel/spec.json +78 -0
  136. package/fixtures/smoke-parallel/state.json +4 -0
  137. package/fixtures/smoke-piechart/spec.json +62 -0
  138. package/fixtures/smoke-piechart/state.json +4 -0
  139. package/fixtures/smoke-radar/spec.json +82 -0
  140. package/fixtures/smoke-radar/state.json +4 -0
  141. package/fixtures/smoke-sankey/spec.json +72 -0
  142. package/fixtures/smoke-sankey/state.json +4 -0
  143. package/fixtures/smoke-state-timeline/spec.json +64 -0
  144. package/fixtures/smoke-state-timeline/state.json +4 -0
  145. package/fixtures/smoke-status-history/spec.json +64 -0
  146. package/fixtures/smoke-status-history/state.json +4 -0
  147. package/fixtures/smoke-streamgraph/spec.json +229 -0
  148. package/fixtures/smoke-streamgraph/state.json +4 -0
  149. package/fixtures/smoke-sunburst/spec.json +72 -0
  150. package/fixtures/smoke-sunburst/state.json +4 -0
  151. package/fixtures/smoke-timeseries/spec.json +163 -0
  152. package/fixtures/smoke-timeseries/state.json +4 -0
  153. package/fixtures/smoke-treemap/spec.json +72 -0
  154. package/fixtures/smoke-treemap/state.json +4 -0
  155. package/fixtures/too-large/args.json +14 -0
  156. package/fixtures/too-large/meta.json +4 -0
  157. package/fixtures/type-mismatch/args.json +15 -0
  158. package/fixtures/type-mismatch/meta.json +4 -0
  159. package/fixtures/type-mismatch/request.json +17 -0
  160. package/fixtures/type-mismatch/response.json +1344 -0
  161. package/fixtures/type-mismatch/result.json +9 -0
  162. package/package.json +32 -0
  163. package/registry/chart-types.json +170 -0
  164. package/registry/constants.json +14 -0
  165. package/registry/notices.json +40 -0
  166. package/registry/panel-types.json +14 -0
  167. package/registry/pick.json +46 -0
  168. package/registry/states.json +85 -0
  169. package/renderer-api.d.ts +70 -0
  170. package/schemas/bundled/query-datasource-args.schema.json +86 -0
  171. package/schemas/bundled/registry.schema.json +375 -0
  172. package/schemas/bundled/tool-result.schema.json +245 -0
  173. package/schemas/bundled/viz-spec.schema.json +261 -0
@@ -0,0 +1,9 @@
1
+ {
2
+ "isError": true,
3
+ "content": [
4
+ {
5
+ "type": "text",
6
+ "text": "type-mismatch: sankey needs source, target and value fields. Charts that fit: timeseries, barchart, histogram, piechart, funnel, heatmap, state-timeline, status-history, streamgraph, bubble."
7
+ }
8
+ ]
9
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@grafana/viz-contract",
3
+ "version": "1.1.0",
4
+ "description": "Contract between a Grafana query source, the host that shows the chart, and the Renderer",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/grafana/viz-contract.git"
9
+ },
10
+ "type": "module",
11
+ "files": [
12
+ "schemas/bundled/",
13
+ "registry/",
14
+ "fixtures/",
15
+ "renderer-api.d.ts",
16
+ "README.md",
17
+ "CHANGELOG.md",
18
+ "LICENSE"
19
+ ],
20
+ "exports": {
21
+ "./renderer-api": {
22
+ "types": "./renderer-api.d.ts"
23
+ },
24
+ "./schemas/*": "./schemas/bundled/*",
25
+ "./registry/*": "./registry/*",
26
+ "./fixtures/*": "./fixtures/*",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }
@@ -0,0 +1,170 @@
1
+ {
2
+ "charts": [
3
+ {
4
+ "name": "timeseries",
5
+ "panel": "grafana-echartscartesian-panel",
6
+ "options": { "seriesType": "line" },
7
+ "fits": [{ "hasFieldType.time": true, "hasFieldType.number": true }],
8
+ "description": "Lines of values over time",
9
+ "dataShape": "a time field and number fields"
10
+ },
11
+ {
12
+ "name": "barchart",
13
+ "panel": "grafana-echartscartesian-panel",
14
+ "options": { "seriesType": "bar" },
15
+ "fits": [{ "hasFieldType.number": true }],
16
+ "description": "Bars of values by category or time",
17
+ "dataShape": "number fields, with a string or time field for the categories"
18
+ },
19
+ {
20
+ "name": "histogram",
21
+ "panel": "grafana-echartscartesian-panel",
22
+ "options": { "histogram": true },
23
+ "fits": [{ "hasFieldType.number": true }],
24
+ "description": "Bucket counts of the values",
25
+ "dataShape": "number fields"
26
+ },
27
+ {
28
+ "name": "candlestick",
29
+ "panel": "grafana-echartscartesian-panel",
30
+ "options": { "seriesType": "candlestick" },
31
+ "fits": [{ "hasFieldName.open": true, "hasFieldName.high": true, "hasFieldName.low": true, "hasFieldName.close": true }],
32
+ "description": "Open, high, low and close values for each time or category",
33
+ "dataShape": "number fields named open, high, low and close"
34
+ },
35
+ {
36
+ "name": "boxplot",
37
+ "panel": "grafana-echartscartesian-panel",
38
+ "options": { "seriesType": "boxplot" },
39
+ "fits": [{ "hasFieldName.min": true, "hasFieldName.q1": true, "hasFieldName.median": true, "hasFieldName.q3": true, "hasFieldName.max": true }],
40
+ "description": "Five-number summary for each category",
41
+ "dataShape": "number fields named min, q1, median, q3 and max"
42
+ },
43
+ {
44
+ "name": "piechart",
45
+ "panel": "grafana-echartsparttowhole-panel",
46
+ "options": { "seriesType": "pie" },
47
+ "fits": [{ "hasFieldType.number": true }],
48
+ "description": "Parts of a whole as slices",
49
+ "dataShape": "a number field, with a string field for the names of the parts"
50
+ },
51
+ {
52
+ "name": "funnel",
53
+ "panel": "grafana-echartsparttowhole-panel",
54
+ "options": { "seriesType": "funnel" },
55
+ "fits": [{ "hasFieldType.number": true }],
56
+ "description": "Values of the stages of a process, from largest to smallest",
57
+ "dataShape": "a number field, with a string field for the names of the stages"
58
+ },
59
+ {
60
+ "name": "heatmap",
61
+ "panel": "grafana-echartsheatmap-panel",
62
+ "options": {},
63
+ "fits": [{ "hasDataFrameType.heatmap-cells": true }, { "hasFieldType.time": true, "hasFieldType.number": true }],
64
+ "description": "Colored cells of values over time and buckets",
65
+ "dataShape": "heatmap cells, or a time field and number fields for the buckets"
66
+ },
67
+ {
68
+ "name": "geomap",
69
+ "panel": "grafana-echartsgeo-panel",
70
+ "options": {},
71
+ "fits": [
72
+ { "hasFieldType.geo": true },
73
+ { "hasFieldName.geohash": true },
74
+ { "hasFieldName.latitude": true, "hasFieldName.longitude": true },
75
+ { "hasFieldName.lat": true, "hasFieldName.lon": true },
76
+ { "hasFieldName.lat": true, "hasFieldName.lng": true }
77
+ ],
78
+ "description": "Points on a map",
79
+ "dataShape": "a geo field, a geohash field, or latitude and longitude fields"
80
+ },
81
+ {
82
+ "name": "state-timeline",
83
+ "panel": "grafana-echartsstatetimeline-panel",
84
+ "options": {},
85
+ "fits": [{ "hasFieldType.time": true, "fieldCount": { "min": 2 } }],
86
+ "description": "Changes of state over time, as bands",
87
+ "dataShape": "a time field and string, boolean or number fields"
88
+ },
89
+ {
90
+ "name": "status-history",
91
+ "panel": "grafana-echartsstatushistory-panel",
92
+ "options": {},
93
+ "fits": [{ "hasFieldType.time": true, "fieldCount": { "min": 2 } }],
94
+ "description": "Status at each time, as cells",
95
+ "dataShape": "a time field and string, boolean or number fields"
96
+ },
97
+ {
98
+ "name": "nodeGraph",
99
+ "panel": "grafana-relations-panel",
100
+ "options": { "seriesType": "graph" },
101
+ "fits": [{ "hasPreferredVisualisationType.nodeGraph": true }, { "hasFieldName.source": true, "hasFieldName.target": true }],
102
+ "description": "Nodes and the links between them",
103
+ "dataShape": "node graph frames, or source and target fields"
104
+ },
105
+ {
106
+ "name": "sankey",
107
+ "panel": "grafana-relations-panel",
108
+ "options": { "seriesType": "sankey" },
109
+ "fits": [{ "hasFieldName.source": true, "hasFieldName.target": true, "hasFieldType.number": true }],
110
+ "description": "Flows between nodes, with a width for each value",
111
+ "dataShape": "source, target and value fields"
112
+ },
113
+ {
114
+ "name": "chord",
115
+ "panel": "grafana-relations-panel",
116
+ "options": { "seriesType": "chord" },
117
+ "fits": [{ "hasFieldName.source": true, "hasFieldName.target": true, "hasFieldType.number": true }],
118
+ "description": "Flows between nodes on a circle",
119
+ "dataShape": "source, target and value fields"
120
+ },
121
+ {
122
+ "name": "treemap",
123
+ "panel": "grafana-echartshierarchy-panel",
124
+ "options": { "seriesType": "treemap" },
125
+ "fits": [{ "hasFieldType.string": true, "hasFieldType.number": true }],
126
+ "description": "Nested rectangles of a hierarchy, with an area for each value",
127
+ "dataShape": "string fields for the levels and a number field"
128
+ },
129
+ {
130
+ "name": "sunburst",
131
+ "panel": "grafana-echartshierarchy-panel",
132
+ "options": { "seriesType": "sunburst" },
133
+ "fits": [{ "hasFieldType.string": true, "hasFieldType.number": true }],
134
+ "description": "Rings of a hierarchy, with an angle for each value",
135
+ "dataShape": "string fields for the levels and a number field"
136
+ },
137
+ {
138
+ "name": "radar",
139
+ "panel": "grafana-echartsmultivariate-panel",
140
+ "options": { "seriesType": "radar" },
141
+ "fits": [{ "hasFieldType.time": false, "fieldCountByType.number": { "min": 3 } }],
142
+ "description": "Several values of each item on axes around a center",
143
+ "dataShape": "three or more number fields"
144
+ },
145
+ {
146
+ "name": "parallel",
147
+ "panel": "grafana-echartsmultivariate-panel",
148
+ "options": { "seriesType": "parallel" },
149
+ "fits": [{ "hasFieldType.time": false, "fieldCountByType.number": { "min": 2 } }],
150
+ "description": "Several values of each item as lines across parallel axes",
151
+ "dataShape": "two or more number fields"
152
+ },
153
+ {
154
+ "name": "streamgraph",
155
+ "panel": "grafana-echartsstream-panel",
156
+ "options": { "streamChartType": "river" },
157
+ "fits": [{ "hasFieldType.time": true, "hasFieldType.number": true }],
158
+ "description": "Stacked flows of values over time",
159
+ "dataShape": "a time field and number fields"
160
+ },
161
+ {
162
+ "name": "bubble",
163
+ "panel": "grafana-echartsstream-panel",
164
+ "options": { "streamChartType": "bubble" },
165
+ "fits": [{ "hasFieldType.time": true, "hasFieldType.number": true }],
166
+ "description": "Bubbles of values over time, with a size for each value",
167
+ "dataShape": "a time field and number fields"
168
+ }
169
+ ]
170
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "maxResultBytes": { "value": 1048576, "unit": "bytes", "meaning": "Largest structuredContent of the tool result", "changeable": true },
3
+ "refreshTimeoutMs": { "value": 60000, "unit": "ms", "meaning": "Time before a refresh with no result fails" },
4
+ "defaultHeightPx": { "value": 400, "unit": "px", "meaning": "Chart height when the element height is 0" },
5
+ "defaultFrom": { "value": "now-1h", "unit": "time", "meaning": "from when the tool arguments have none" },
6
+ "defaultTo": { "value": "now", "unit": "time", "meaning": "to when the tool arguments have none" },
7
+ "defaultMaxDataPoints": { "value": 1000, "unit": "points", "meaning": "maxDataPoints of a query that has none. intervalMs is the range divided by it" },
8
+ "maxSeries": { "value": 50, "unit": "series", "meaning": "Most series that the Renderer draws", "changeable": true },
9
+ "maxBundleGzipBytes": { "value": null, "unit": "bytes", "meaning": "Largest gzip size of the Renderer bundle. Not set until the host size research is done", "changeable": true },
10
+ "maxAppNotes": { "value": 5, "unit": "notes", "meaning": "Most notes of the Source that render_grafana_app adds to its text line", "changeable": true },
11
+ "maxAppNoteChars": { "value": 200, "unit": "characters", "meaning": "Longest note in the text line of render_grafana_app", "changeable": true },
12
+ "deprecationDays": { "value": 30, "unit": "days", "meaning": "Shortest deprecation period of a change to a frozen interface", "changeable": true },
13
+ "specVersion": { "value": 1, "unit": "version", "meaning": "The viz spec version that this contract gives" }
14
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "notices": [
3
+ {
4
+ "code": "query-failed",
5
+ "raisedBy": "renderer",
6
+ "when": "An entry of data.results has an error, and another entry has no error",
7
+ "message": "Query <refId> failed: <error>"
8
+ },
9
+ {
10
+ "code": "unit-unknown",
11
+ "raisedBy": "renderer",
12
+ "when": "panel.fieldConfig.defaults.unit is not a unit ID of @grafana/data",
13
+ "message": "Unit <unit> is not a Grafana unit. The values show with no unit."
14
+ },
15
+ {
16
+ "code": "series-truncated",
17
+ "raisedBy": "renderer",
18
+ "when": "The frames have more series than maxSeries",
19
+ "message": "<omitted> series with the smallest peak values are not shown."
20
+ },
21
+ {
22
+ "code": "chart-changed",
23
+ "raisedBy": "app",
24
+ "when": "A refresh got the type-mismatch error, and the App drew the picked chart in its place",
25
+ "message": "The <old> chart does not fit the new data. The chart is now a <new>."
26
+ },
27
+ {
28
+ "code": "geo-map-tiles",
29
+ "raisedBy": "renderer",
30
+ "when": "A map layer of the geo panel needs map tiles from the network",
31
+ "message": "Map layer <name> (<type>) needs map tiles from the network. The vector basemap is drawn in its place."
32
+ },
33
+ {
34
+ "code": "geo-offline-file",
35
+ "raisedBy": "renderer",
36
+ "when": "A map layer of the geo panel needs a file that is not in the Renderer",
37
+ "message": "Map layer <name>: <url> is not available offline."
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "panels": [
3
+ { "id": "grafana-echartscartesian-panel", "family": "cartesian", "name": "XY chart" },
4
+ { "id": "grafana-echartsgeo-panel", "family": "geo", "name": "geo map" },
5
+ { "id": "grafana-echartsheatmap-panel", "family": "heatmap", "name": "heatmap" },
6
+ { "id": "grafana-echartshierarchy-panel", "family": "hierarchy", "name": "hierarchy chart" },
7
+ { "id": "grafana-echartsmultivariate-panel", "family": "multivariate", "name": "multivariate chart" },
8
+ { "id": "grafana-echartsparttowhole-panel", "family": "partToWhole", "name": "part-to-whole chart" },
9
+ { "id": "grafana-relations-panel", "family": "relations", "name": "relations chart" },
10
+ { "id": "grafana-echartsstatetimeline-panel", "family": "stateTimeline", "name": "state timeline" },
11
+ { "id": "grafana-echartsstatushistory-panel", "family": "statusHistory", "name": "status history" },
12
+ { "id": "grafana-echartsstream-panel", "family": "stream", "name": "stream chart" }
13
+ ]
14
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "pickVersion": 1,
3
+ "rules": [
4
+ {
5
+ "id": "node-graph",
6
+ "reason": "A frame has the preferred visualization type nodeGraph.",
7
+ "when": { "hasPreferredVisualisationType.nodeGraph": true },
8
+ "chart": "nodeGraph"
9
+ },
10
+ {
11
+ "id": "heatmap-cells",
12
+ "reason": "A frame has the data frame type heatmap-cells.",
13
+ "when": { "hasDataFrameType.heatmap-cells": true },
14
+ "chart": "heatmap"
15
+ },
16
+ {
17
+ "id": "time-series",
18
+ "reason": "The frames have a time field with more than one instant and a number field.",
19
+ "when": { "hasFieldType.time": true, "hasFieldType.number": true, "isInstant": false },
20
+ "chart": "timeseries"
21
+ },
22
+ {
23
+ "id": "few-parts",
24
+ "reason": "The frames have one string field, one number field and 2 to 10 rows.",
25
+ "when": {
26
+ "hasFieldType.time": false,
27
+ "fieldCountByType.string": 1,
28
+ "fieldCountByType.number": 1,
29
+ "rowCountTotal": { "min": 2, "max": 10 }
30
+ },
31
+ "chart": "piechart"
32
+ },
33
+ {
34
+ "id": "categories",
35
+ "reason": "The frames have a string field and a number field, and no time field.",
36
+ "when": { "hasFieldType.time": false, "hasFieldType.string": true, "hasFieldType.number": true },
37
+ "chart": "barchart"
38
+ },
39
+ {
40
+ "id": "default",
41
+ "reason": "No other rule matches.",
42
+ "when": {},
43
+ "chart": "barchart"
44
+ }
45
+ ]
46
+ }
@@ -0,0 +1,85 @@
1
+ {
2
+ "states": [
3
+ {
4
+ "state": "rendering",
5
+ "final": false,
6
+ "meaning": "The render is not complete. The Renderer shows nothing"
7
+ },
8
+ {
9
+ "state": "ready",
10
+ "final": true,
11
+ "meaning": "The Renderer shows the chart"
12
+ },
13
+ {
14
+ "state": "no-data",
15
+ "final": true,
16
+ "meaning": "The frames have no rows. The Renderer shows No data, as Grafana does"
17
+ },
18
+ {
19
+ "state": "error",
20
+ "final": true,
21
+ "meaning": "The Renderer shows an error message in place of the chart"
22
+ }
23
+ ],
24
+ "errors": [
25
+ {
26
+ "code": "invalid-spec",
27
+ "when": "The viz spec is not an object, or a required field is missing",
28
+ "message": "The viz spec is not correct: <field> is missing."
29
+ },
30
+ {
31
+ "code": "unsupported-spec-version",
32
+ "when": "specVersion is not a version that the Renderer supports",
33
+ "message": "This viz spec version (<n>) is not supported. Supported versions: <list>."
34
+ },
35
+ {
36
+ "code": "unsupported-panel-type",
37
+ "when": "panel.type is not a panel ID of panel-types.json",
38
+ "message": "Panel type <type> is not supported. Supported types: <list>."
39
+ },
40
+ {
41
+ "code": "all-queries-failed",
42
+ "when": "Each entry of data.results has an error",
43
+ "message": "Query <refId> failed: <error>"
44
+ },
45
+ {
46
+ "code": "panel-error",
47
+ "when": "The panel shows its own error view in place of the chart",
48
+ "message": "<panel message>"
49
+ },
50
+ {
51
+ "code": "render-error",
52
+ "when": "An error occurs in the Renderer after the checks of the viz spec",
53
+ "message": "This data cannot be shown as a <panelName>."
54
+ }
55
+ ],
56
+ "toolErrors": [
57
+ {
58
+ "code": "type-mismatch",
59
+ "when": "The frames have data, and they do not meet the fits condition of the type from the model",
60
+ "message": "<chart> needs <dataShape>. Charts that fit: <charts>."
61
+ },
62
+ {
63
+ "code": "too-large",
64
+ "when": "The structured content of the tool result is larger than maxResultBytes",
65
+ "message": "The result is larger than <maxResultBytes> bytes. Use a shorter range, a larger intervalMs or fewer series."
66
+ }
67
+ ],
68
+ "refresh": [
69
+ {
70
+ "code": "refresh-failed",
71
+ "when": "The App calls setRefreshed(false, error) with an error text, or onRefresh throws",
72
+ "message": "Refresh failed: <error>"
73
+ },
74
+ {
75
+ "code": "refresh-failed-no-detail",
76
+ "when": "The App calls setRefreshed(false) with no error text",
77
+ "message": "Refresh failed."
78
+ },
79
+ {
80
+ "code": "refresh-timeout",
81
+ "when": "refreshTimeoutMs passes with no result",
82
+ "message": "Refresh failed: no result in time."
83
+ }
84
+ ]
85
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The Renderer API. The App imports the Renderer as an ES module. 3-renderer.md, 4-states-and-notices.md and
3
+ * 5-refresh.md give the rules.
4
+ *
5
+ * This file has types only. The package has no JavaScript. Import it with `import type`. The values that it
6
+ * declares, for example render, come from the Renderer.
7
+ *
8
+ * The Renderer takes React and the Grafana packages from the App. The peerDependencies of the Renderer give
9
+ * them.
10
+ */
11
+
12
+ /** Semver of the Renderer. */
13
+ export declare const version: string;
14
+
15
+ /** The specVersion values that the Renderer supports. */
16
+ export declare const specVersions: readonly number[];
17
+
18
+ /**
19
+ * Draws a viz spec into el, and returns at once. A spec that is not correct gives the error state. It does not
20
+ * throw. render throws only if el is not an HTMLElement.
21
+ */
22
+ export declare function render(el: HTMLElement, spec: unknown, options?: RenderOptions): RenderHandle;
23
+
24
+ export interface RenderOptions {
25
+ /** Called when the Renderer shows a new final state or new notices. */
26
+ onState?: (state: RenderState) => void;
27
+ /**
28
+ * Called when the user clicks Refresh or picks a time range. The Renderer shows Refresh and the time picker
29
+ * only when the App gives this option.
30
+ */
31
+ onRefresh?: (request: RefreshRequest) => void;
32
+ }
33
+
34
+ export interface RenderHandle {
35
+ /** Draws a new viz spec in the same element. */
36
+ update(spec: unknown): void;
37
+ /** Gives the result of the last refresh. With ok false, error is the text that the Renderer shows. */
38
+ setRefreshed(ok: boolean, error?: string): void;
39
+ /** Removes the chart and its listeners. */
40
+ destroy(): void;
41
+ }
42
+
43
+ /** A final state. The value is the same as the data-viz-state attribute of el. */
44
+ export interface RenderState {
45
+ state: 'ready' | 'no-data' | 'error';
46
+ /** Present only when state is error. */
47
+ error?: RenderError;
48
+ /** The notices that the chart shows, in the same order. Can be empty. */
49
+ notices: Notice[];
50
+ }
51
+
52
+ export interface RenderError {
53
+ /** A code of errors in registry/states.json. */
54
+ code: string;
55
+ /** The message, made from the pattern of the code. */
56
+ message: string;
57
+ }
58
+
59
+ export interface Notice {
60
+ /** A code of registry/notices.json. */
61
+ code: string;
62
+ /** The message, made from the pattern of the code. */
63
+ message: string;
64
+ }
65
+
66
+ /**
67
+ * The cause of a refresh. For timeRange, from and to are the range that the user picked. A relative range, for
68
+ * example now-6h to now, stays relative. An absolute range is in epoch milliseconds.
69
+ */
70
+ export type RefreshRequest = { cause: 'refresh' } | { cause: 'timeRange'; from: string; to: string };
@@ -0,0 +1,86 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "query_datasource arguments",
4
+ "description": "Query a Grafana data source through /api/ds/query and draw the result as a chart.",
5
+ "type": "object",
6
+ "required": [
7
+ "datasourceUid",
8
+ "queries"
9
+ ],
10
+ "properties": {
11
+ "datasourceUid": {
12
+ "type": "string",
13
+ "minLength": 1,
14
+ "description": "UID of the data source. All queries use this data source."
15
+ },
16
+ "queries": {
17
+ "type": "array",
18
+ "minItems": 1,
19
+ "description": "The queries of /api/ds/query: a unique refId and the fields of the data source, for example expr and legendFormat for Prometheus.",
20
+ "items": {
21
+ "type": "object",
22
+ "required": [
23
+ "refId"
24
+ ],
25
+ "properties": {
26
+ "refId": {
27
+ "type": "string",
28
+ "minLength": 1
29
+ }
30
+ }
31
+ }
32
+ },
33
+ "from": {
34
+ "type": [
35
+ "string",
36
+ "integer"
37
+ ],
38
+ "default": "now-1h",
39
+ "$comment": "Generated from registry/constants.json (defaultFrom). Do not edit.",
40
+ "description": "Start of the time range, in a format that /api/ds/query accepts, for example now-6h or epoch milliseconds (a string or an integer)."
41
+ },
42
+ "to": {
43
+ "type": [
44
+ "string",
45
+ "integer"
46
+ ],
47
+ "default": "now",
48
+ "$comment": "Generated from registry/constants.json (defaultTo). Do not edit.",
49
+ "description": "End of the time range, in a format that /api/ds/query accepts, for example now or epoch milliseconds."
50
+ },
51
+ "type": {
52
+ "type": "string",
53
+ "$comment": "Generated from registry/chart-types.json. Do not edit.",
54
+ "enum": [
55
+ "timeseries",
56
+ "barchart",
57
+ "histogram",
58
+ "candlestick",
59
+ "boxplot",
60
+ "piechart",
61
+ "funnel",
62
+ "heatmap",
63
+ "geomap",
64
+ "state-timeline",
65
+ "status-history",
66
+ "nodeGraph",
67
+ "sankey",
68
+ "chord",
69
+ "treemap",
70
+ "sunburst",
71
+ "radar",
72
+ "parallel",
73
+ "streamgraph",
74
+ "bubble"
75
+ ],
76
+ "description": "Optional chart to draw. With no type, the chart comes from the data. Each chart needs: timeseries (a time field and number fields), barchart (number fields, with a string or time field for the categories), histogram (number fields), candlestick (number fields named open, high, low and close), boxplot (number fields named min, q1, median, q3 and max), piechart (a number field, with a string field for the names of the parts), funnel (a number field, with a string field for the names of the stages), heatmap (heatmap cells, or a time field and number fields for the buckets), geomap (a geo field, a geohash field, or latitude and longitude fields), state-timeline (a time field and string, boolean or number fields), status-history (a time field and string, boolean or number fields), nodeGraph (node graph frames, or source and target fields), sankey (source, target and value fields), chord (source, target and value fields), treemap (string fields for the levels and a number field), sunburst (string fields for the levels and a number field), radar (three or more number fields), parallel (two or more number fields), streamgraph (a time field and number fields), bubble (a time field and number fields)."
77
+ },
78
+ "unit": {
79
+ "type": "string",
80
+ "minLength": 1,
81
+ "description": "Optional Grafana unit ID for all values, for example bytes, percent or reqps."
82
+ }
83
+ },
84
+ "additionalProperties": false,
85
+ "$comment": "Generated from schemas/query-datasource-args.schema.json. Do not edit."
86
+ }