|
| 1 | +# mix_chart_protocol |
| 2 | + |
| 3 | +`mix_chart_protocol` is the optional integration between the publishable |
| 4 | +`mix_chart` runtime and `mix_protocol`. It depends on both packages so |
| 5 | +`mix_chart` does not have to make serialization part of every chart app. |
| 6 | + |
| 7 | +Use the ready-to-use protocol for the common core-plus-chart composition: |
| 8 | + |
| 9 | +```dart |
| 10 | +import 'package:mix_chart_protocol/mix_chart_protocol.dart'; |
| 11 | +
|
| 12 | +final encoded = mixChartProtocol.encodeStyle(chartStyle); |
| 13 | +``` |
| 14 | + |
| 15 | +Applications, servers, and tooling opt into this sidecar only when they cross a |
| 16 | +JSON boundary. `mix_chart` itself must not depend on it: Dart packages have no |
| 17 | +optional dependencies, and most chart rendering does not need the protocol. |
| 18 | + |
| 19 | +Use the exported vocabulary directly only when combining charts with another |
| 20 | +package vocabulary: |
| 21 | + |
| 22 | +```dart |
| 23 | +import 'package:mix_chart_protocol/mix_chart_protocol.dart'; |
| 24 | +
|
| 25 | +final protocol = MixProtocol.compose([ |
| 26 | + mixProtocolCoreVocabulary, |
| 27 | + mixChartVocabulary, |
| 28 | + anotherVocabulary, |
| 29 | +]); |
| 30 | +``` |
| 31 | + |
| 32 | +The sidecar re-exports the protocol API used by `mixChartProtocol`, so this |
| 33 | +integration needs only one protocol import. |
| 34 | + |
| 35 | +The vocabulary uses the `mix_chart.v1.*` namespace and contains all 15 chart |
| 36 | +stylers, including shared nested stylers. Core stylers such as `TextStyler` |
| 37 | +inside chart labels recurse through the same composed union. Variants, |
| 38 | +modifiers, animation, property terms, tokens, and lenient decoding use the |
| 39 | +ordinary `mix_protocol` grammar. |
| 40 | + |
| 41 | +This sidecar is unpublished while `mix_protocol` is unpublished. Keeping it |
| 42 | +separate preserves `mix_chart`'s existing publish contract and avoids exposing |
| 43 | +the private Ack implementation. |
0 commit comments