Skip to content

Commit f7ba904

Browse files
authored
Maryia/style: readme (#1524)
* style: readme * style: remove info about removed Marker component * style: update readme * style: typos
1 parent 71ac7c1 commit f7ba904

File tree

3 files changed

+17
-43
lines changed

3 files changed

+17
-43
lines changed

README.md

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -249,47 +249,22 @@ Attributes marked with `*` are **mandatory**:
249249
| opacityOnOverlap | Sets the opacity of the barrier when it is overlapping with other barrier. |
250250
| high\* | Sets the price of the high barrier. |
251251
| low\* | Sets the price of the low barrier. |
252-
#### ~~Marker API~~ (Depricated)
252+
#### Marker API
253253
254-
Markers provide a way for developers to place DOM elements inside the chart that are positioned based on date, values or tick location. Unlike [CharIQ's Markers](http://documentation.chartiq.com/tutorial-Markers.html#main), we only allow markers to be placed on the main chart. Also note that this Marker implementation does not factor the width and height of the marker; this is expensive to calculate, so we expect you to offset this in CSS.
254+
Use `FastMarker` to render given components inside the chart.
255+
Markers provide a way for developers to place DOM elements that are positioned based on date, values or tick location inside the chart. Also, please note that this `FastMarker` implementation does not factor the width and height of the marker: this is expensive to calculate, so we expect you to offset this in CSS.
256+
`FastMarker` will keep the marker position on the chart.
257+
It can be imported from `@deriv/deriv-chart` package either as `FastMarker`, or simply as `Marker`.
255258
256259
```jsx
257260
<SmartChart>
258-
<Marker
259-
x={1533192979}
260-
yPositioner="none"
261-
className="chart-line vertical trade-start-line"
261+
<FastMarker
262+
markerRef={setRef}
263+
className="your-css-class"
262264
>
263-
{/* Place marker content here */}
264-
<div className="drag-line" />
265-
<div className="trade-text">Trade Start</div>
266-
</Marker>
267-
</SmartChart>
268-
```
269-
270-
| Attribute | Description |
271-
| ----------- | ----------------------------------------------------------------------------- |
272-
| className | Adds custom class name to marker. All markers have class name `stx-marker`. |
273-
| x | x position of the chart; depends on `xPositioner`. |
274-
| xPositioner | Determines x position. Choose between `epoch` or `none`. Defaults to `epoch`. |
275-
| y | y position of the chart; depends on `yPositioner`. |
276-
| yPositioner | Determines y position. Choose between `value` or `none`. Defaults to `value`. |
277-
278-
There are more options for `xPositioner` and `yPositioner` in [ChartIQ docs](http://documentation.chartiq.com/CIQ.Marker.html#main). What we document here is the most common use case.
279-
280-
#### Marker API
281-
282-
Use `FastMarker` to render given Components under stx-subholder.
283-
It will keep the marker position on the chart.
284-
285-
```jsx
286-
<FastMarker
287-
markerRef={setRef}
288-
threshold={optional visibility threshold}
289-
className="your-css-class"
290-
>
291265
<your content here/>
292-
</FastMarker>
266+
</FastMarker>
267+
</SmartChart>
293268
294269
```
295270
@@ -308,7 +283,6 @@ USAGE:
308283
309284
PROPS:
310285
311-
- `threshold` (optional): the chart has a zoom level, the marker will be only shown within that threshold.
312286
- `markerRef` (required): pass the `setRef` callback using this property
313287
- `className` (optional): avoid expoensive css transition or keyframe animations on this class.
314288
@@ -372,15 +346,15 @@ Here are the following components you can import:
372346
- `<ChartTypes enabled={true} onChange={(chartType) => {}} />`
373347
- `<StudyLegend />`
374348
- `<DrawTools />`
375-
- `<Views portalNodeId='modal_root' onChartType={()=>{}} onGranularity={()=>{}}/>`
349+
- `<Views onChartType={(chartType) => {}} onGranularity={(granularity) => {}} />`
376350
- `<Share />`
377351
- `<Timeperiod enabled={true} onChange={(chartType) => {}} />`
378352
- `<ChartSize />`
379353
- `<ChartSetting />`
380354
- Toolbar Widget
381-
- `<ChartMode portalNodeId='modal_root' onChartType={()=>{}} onGranularity={updateGranularity={()=>{}}}/>`
355+
- `<ChartMode onChartType={(chartType) => {}} onGranularity={(granularity) => {}} />`
382356
383-
> Note: ChartMode and Views have the same type of props . It include onChartType and onGranularity callback with portalNodeId
357+
> Note: ChartMode and Views have the same type of props. It includes required `onChartType` and `onGranularity` callbacks and an optional `portalNodeId`.
384358
385359
386360
### Props vs UI
@@ -664,7 +638,7 @@ export default connect(({ chartTitle: c }) => ({
664638
665639
##### 3. Independent Components: components that are not managed by the main store
666640
667-
Examples: `<Barrier />`, `<Marker />`
641+
Examples: `<Barrier />`, `<ChartMode />`
668642
669643
Independent components is able to access the main store, but the main store has no control over independent components. As such, each independent component manages its own life cycle. Here is the interface for its store:
670644

src/components/ChartMode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Timeperiod from './Timeperiod';
1919

2020
type TChartModeProps = {
2121
portalNodeId?: string;
22-
onChartType: (chartType?: string | undefined) => void;
22+
onChartType: (chartType?: string) => void;
2323
onGranularity: (granularity?: TGranularity) => void;
2424
};
2525

src/components/FastMarker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { TRefData } from 'src/types';
55
import { strToDateTime } from 'src/utils/date';
66
import { getUTCDate } from '../utils';
77

8-
// Render given Components under stx-subholder.
8+
// Render given Components inside the chart.
99
// This component is used to position a marker on the chart.
1010
//
1111
// USAGE:
@@ -159,7 +159,7 @@ const FastMarker = (props: TFastMarkerProps) => {
159159
const maxWidth = chartNode && !overlap_y_axis ? chartNode.offsetWidth - yAxisWidth - 10 : '100%';
160160

161161
return (
162-
<div className='fast-marker' style={{ maxWidth: maxWidth }}>
162+
<div className='fast-marker' style={{ maxWidth }}>
163163
<div className={className} ref={setRef} style={{ position: 'absolute' }}>
164164
{children}
165165
</div>

0 commit comments

Comments
 (0)