You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+108
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,114 @@ The scatter plot shown below has 30 time-series of test data, with two time axes
230
230
231
231
## usage
232
232
233
+
The `stream-charts` module wraps [d3](http://d3js.org) elements with functional [react](http://reactjs.org) in a way that keeps the chart (d3) updates out of the react render cycle. All `stream-charts` start with the [`<Chart/>`](./src/app/charts/Chart.tsx) root element.
234
+
235
+
### `<Chart/>`
236
+
237
+
The `Chart` component creates the main SVG element (container) holding the chart, manages a reference to that container, and is the wraps the children in the chart context provider so that they have access to the [useChart](./src/app/charts/hooks/useChart.tsx) hook which holds properties, styles, callbacks, subscription needed to construct the charts and make them interactive.
238
+
239
+
The `Chart`s properties fall into four categories:
240
+
1. container dimensions
241
+
2. chart style
242
+
3. initial (static data)
243
+
4. streamed data and how to manage the stream of data
244
+
245
+
#### Chart dimensions
246
+
> **width (pixels)**<br>
247
+
> The width (in pixels) of the container that holds the chart. The actual plot will be smaller based on the margins.
248
+
249
+
> **height (pixels)**<br>
250
+
> The height (in pixels) of the container that holds the chart. The actual plot will be smaller based on the margins.
> The margin (in pixels) around plot. For example, if the container has a (h, w) = (300, 600) and a margin of 10 pixels for the top, left, right, bottom, then the actual plot will have a (h, w) = (290, 590), leaving only 10 pixels around the plot for axis titles, ticks, and axis labels.
255
+
>
256
+
> The Margin has the following shape
257
+
>```typescript
258
+
>interfaceMargin {
259
+
> top:number
260
+
> bottom:number
261
+
> left:number
262
+
> right:number
263
+
>}
264
+
>```
265
+
266
+
267
+
> **color (string, optional)**<br>
268
+
> The color of the axis lines and text, which can be overridden specifically by the axes styles.
269
+
270
+
> **backgroundColor (string, optional)**<br>
271
+
> The color of the chart background (the whole chart, not just the plot).
> A map holding the data series name with an associated SeriesLineStyle. Any series listed in this map will use the associated styles for that series. Any series not in the map will use the default series styles.
289
+
>
290
+
> The SeriesLineStyle has the following shape
291
+
> ```typescript
292
+
>interfaceSeriesLineStyle {
293
+
> color:string
294
+
> lineWidth:number
295
+
>// the color of the series when the user mouses over the series
296
+
> highlightColor:string
297
+
>// the line width of the series when the user mouses over the series
298
+
> highlightWidth:number
299
+
>// the line margin used for raster charts
300
+
> margin?:number
301
+
> }
302
+
>```
303
+
304
+
#### Chart initial data
305
+
306
+
Holds the initial (static data). This data is displayed in the chart even before subscribing to the chart-data observable. The initial data can be used to generate static charts.
> An array holding the initial data series to be plotted before subscribing to the chart-data observable.
310
+
>
311
+
> The Series has the following shape
312
+
> ```typescript
313
+
>interfaceSeries {
314
+
>// the series name
315
+
>readonly name:string;
316
+
>// the array of time-value pairs
317
+
> data:Array<Datum>;
318
+
>// ... accessor functions
319
+
> .
320
+
> .
321
+
> .
322
+
> }
323
+
>
324
+
>```
325
+
> And the [Datum](./src/app/charts/datumSeries.ts) has the following shape
326
+
> ```typescript
327
+
>interfaceDatum {
328
+
>readonly time:number;
329
+
>readonly value:number;
330
+
> }
331
+
>```
332
+
> Please note that there are a number of helper functions for creating `Series` and `Datum`.
333
+
>
334
+
335
+
todo list the factory functions
336
+
337
+
initialData: Array<Series>
338
+
seriesFilter?: RegExp
339
+
340
+
233
341
### properties
234
342
235
343
The [examples](https://github.com/robphilipp/stream-charts-examples) project has example code that was used to generate the charts in the images above. The [StreamingRasterChart](https://github.com/robphilipp/stream-charts-examples/blob/master/src/app/examples/StreamingRasterChart.tsx) provides an example of using the raster chart. The [StreamingScatterChart](https://github.com/robphilipp/stream-charts-examples/blob/master/src/app/examples/StreamingScatterChart.tsx) provides an example of using the scatter chart. Both of these examples provide controls for enabling the filtering, tooltip, tracker, and magnifier enhancements.
0 commit comments