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: website/docs/charts/candlestick.mdx
+94
Original file line number
Diff line number
Diff line change
@@ -502,6 +502,100 @@ Events can be handled by passing an array of event objects to the `events` prop
502
502
</VictoryChart>
503
503
```
504
504
505
+
## Candlestick - Brush and Zoom
506
+
507
+
Candlestick charts support zoom and pan behavior by using the `VictoryZoomContainer` and `VictoryBrushContainer` components. See the [Brush & Zoom](/docs/guides/brush-and-zoom) guide for more information.
508
+
509
+
```jsx live noInline
510
+
functionApp() {
511
+
constsampleData= [
512
+
{
513
+
x:5,
514
+
open:5,
515
+
close:10,
516
+
high:15,
517
+
low:0,
518
+
},
519
+
{
520
+
x:10,
521
+
open:10,
522
+
close:15,
523
+
high:20,
524
+
low:5,
525
+
},
526
+
{
527
+
x:15,
528
+
open:15,
529
+
close:20,
530
+
high:22,
531
+
low:10,
532
+
},
533
+
{
534
+
x:20,
535
+
open:20,
536
+
close:10,
537
+
high:25,
538
+
low:7,
539
+
},
540
+
{
541
+
x:25,
542
+
open:10,
543
+
close:8,
544
+
high:15,
545
+
low:5,
546
+
},
547
+
];
548
+
const [state, setState] =React.useState({});
549
+
550
+
consthandleZoom= (domain) => {
551
+
setState({ selectedDomain: domain });
552
+
};
553
+
554
+
consthandleBrush= (domain) => {
555
+
setState({ zoomDomain: domain });
556
+
};
557
+
558
+
return (
559
+
<div>
560
+
<VictoryChart
561
+
theme={VictoryTheme.clean}
562
+
domainPadding={{ x:25 }}
563
+
containerComponent={
564
+
<VictoryZoomContainer
565
+
zoomDimension="x"
566
+
zoomDomain={state.zoomDomain}
567
+
onZoomDomainChange={handleZoom}
568
+
/>
569
+
}
570
+
>
571
+
<VictoryCandlestick
572
+
data={sampleData}
573
+
/>
574
+
</VictoryChart>
575
+
576
+
<VictoryChart
577
+
height={170}
578
+
theme={VictoryTheme.clean}
579
+
domainPadding={{ x:25 }}
580
+
padding={{top:0, left:50, right:50, bottom:30}}
581
+
containerComponent={
582
+
<VictoryBrushContainer
583
+
brushDimension="x"
584
+
brushDomain={state.selectedDomain}
585
+
onBrushDomainChange={handleBrush}
586
+
/>
587
+
}
588
+
>
589
+
<VictoryAxis />
590
+
<VictoryCandlestick data={sampleData} />
591
+
</VictoryChart>
592
+
</div>
593
+
)
594
+
}
595
+
596
+
render(<App />);
597
+
```
598
+
505
599
## Standalone Rendering
506
600
507
601
Box Plot charts can be rendered outside a VictoryChart.
0 commit comments