@grafana/viz-contract 1.5.1 → 1.7.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.
package/README.md CHANGED
@@ -50,6 +50,7 @@ flowchart TB
50
50
  | Viz spec | The JSON object that the App gives to the Renderer |
51
51
  | Icon cache | The `react-inlinesvg` cache of the copy of `@grafana/ui` in the App. `Icon` reads an SVG from it, and makes no request for that SVG |
52
52
  | Note | A text line that the Source gives to `render_grafana_app`, and that the model reads in the same turn (`tool.28`). Not a notice: the Renderer shows a notice in the chart (`state.7`) |
53
+ | Legend overrides | The `fieldConfig` overrides that the user makes with the legend: hide, show and color an item. Only the Renderer keeps them (`renderer.37`) |
53
54
 
54
55
  The Renderer draws the panels of the package `@plugins/grafana-echarts`.
55
56
 
@@ -100,6 +101,29 @@ const pkg = createRequire(import.meta.url).resolve('@grafana/viz-contract/packag
100
101
  const fixturesDir = path.join(path.dirname(pkg), 'fixtures');
101
102
  ```
102
103
 
104
+ ## Use the Go module
105
+
106
+ The Go module `github.com/grafana/viz-contract` holds the bundled schemas, the registries and the fixtures. It has
107
+ the same tags as the npm package. A function gives each folder as its own `fs.FS`: `Registry()` (`registry/`),
108
+ `Schemas()` (`schemas/bundled/`) and `Fixtures()` (`fixtures/`). A binary that calls only `Registry()` does not
109
+ carry the fixtures. A path does not start with the folder name. It is the path after the folder in the npm package.
110
+
111
+ ```sh
112
+ go get github.com/grafana/viz-contract@latest
113
+ ```
114
+
115
+ ```go
116
+ import (
117
+ "io/fs"
118
+
119
+ vizcontract "github.com/grafana/viz-contract"
120
+ )
121
+
122
+ chartTypes, err := fs.ReadFile(vizcontract.Registry(), "chart-types.json")
123
+ vizSpec, err := fs.ReadFile(vizcontract.Schemas(), "viz-spec.schema.json")
124
+ args, err := fs.ReadFile(vizcontract.Fixtures(), "prometheus-line/args.json")
125
+ ```
126
+
103
127
  ## Promises
104
128
 
105
129
  The interfaces do not have the same promise of stability. [8-versioning.md](8-versioning.md) gives the three
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/viz-contract",
3
- "version": "1.5.1",
3
+ "version": "1.7.0",
4
4
  "description": "Contract between a Grafana query source, the host that shows the chart, and the Renderer",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/renderer-api.d.ts CHANGED
@@ -32,7 +32,7 @@ export interface RenderOptions {
32
32
  }
33
33
 
34
34
  export interface RenderHandle {
35
- /** Draws a new viz spec in the same element. */
35
+ /** Draws a new viz spec in the same element. It keeps the legend overrides of the user (renderer.35). */
36
36
  update(spec: unknown): void;
37
37
  /**
38
38
  * Gives the result of the refresh with this id. id is the id of the RefreshRequest. With ok false, error is the