-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from deriv-com/shafin/ChampionTrader/feat-chart
chore: update simple chart with real data
- Loading branch information
Showing
9 changed files
with
208 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Chart Component | ||
|
||
The Chart component displays market data using a WebSocket connection. It is responsible for: | ||
|
||
- **Real-Time Price Updates:** Receiving and displaying live market prices. | ||
- **Connection Status:** Indicating whether the WebSocket connection is active or disconnected. | ||
- **Error Handling:** Displaying errors when the WebSocket encounters issues. | ||
- **Customization:** Accepting an optional `className` prop for styling. | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { Chart } from "@/components/Chart"; | ||
|
||
function App() { | ||
return ( | ||
<div> | ||
<Chart className="custom-chart-class" /> | ||
</div> | ||
); | ||
} | ||
``` | ||
|
||
## Props | ||
|
||
| Prop | Type | Description | | ||
|-----------|--------|---------------------------------------| | ||
| className | string | Optional CSS class for the component. | | ||
|
||
## Implementation Details | ||
|
||
- The component uses the `useMarketWebSocket` hook with a hardcoded instrument ID of `"R_100"`. | ||
- WebSocket events such as connection, price updates, and errors are logged to the console. | ||
- The UI displays the current market price, a disconnected message when the connection is lost, and any error messages. | ||
|
||
## Future Enhancements | ||
|
||
- Integrate a visual charting library for dynamic price visualization. | ||
- Add configurable instrument IDs and callback functions via props. |
Oops, something went wrong.