# Apexcharts-rs
[![Crates.io](https://img.shields.io/crates/v/apexcharts-rs)](https://crates.io/crates/apexcharts-rs)
[![Build](https://github.com/clementwanjau/apexcharts-rs/actions/workflows/build.yaml/badge.svg)](https://github.com/clementwanjau/apexcharts-rs/actions/workflows/build.yaml)
This is a Rust WASM bindings for generating charts using the [ApexCharts](https://apexcharts.com/) JavaScript library. The library provides components for creating charts with the `yew` and `leptos` frameworks. ApexCharts is a modern open source charting library that helps developers to create beautiful and interactive visualizations for web pages.
## Browsers support
| [](http://godban.github.io/browsers-support-badges/)
Firefox | [](http://godban.github.io/browsers-support-badges/)
Chrome | [](http://godban.github.io/browsers-support-badges/)
Safari | [](http://godban.github.io/browsers-support-badges/)
Edge | [](http://godban.github.io/browsers-support-badges/)
IE11 |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 31+ ✔ | 35+ ✔ | 6+ ✔ | Edge ✔ | [(IE11)](https://github.com/apexcharts/apexcharts.js?tab=readme-ov-file#using-it-with-ie11) ✔ |
## Usage
The components can be exposed for use by enabling features depending on the framework in use.
- ### Yew
```toml
[dependencies]
apexcharts-rs = {version="0.1", features=["yew"]}
```
and then in your code:
```rust,ignore
use yew::prelude::*;
use apexcharts_rs::prelude::{ApexChartComponent, ChartType, ChartSeries, SeriesData};
#[function_component]
fn MyApp() -> Html {
// This is the data to chart. The data is a vector of `ChartSeries`
// which contains the name of the series, the data points, color, type
// and z-index. Note that different charts require different data types.
let series = vec![
ChartSeries {
name: "New users".to_string(),
data: SeriesData::Single(vec![6500, 6418, 6456, 6526, 6356, 6456]),
color: "#1A56DB".to_string(),
r#type: None,
z_index: None,
}
];
// Options to further configure how the chart looks. Kindly refer to the ApexCharts documentation for more options.
let raw_options = r##"{
"chart": {
"fontFamily": "Inter, sans-serif",
"dropShadow": {
"enabled": false
},
"toolbar": {
"show": false
}
},
"xaxis": {
"categories": ["01 February", "02 February", "03 February", "04 February", "05 February", "06 February", "07 February"],
"labels": {
"show": false
},
"axisBorder": {
"show": false
},
"axisTicks": {
"show": false
}
},
"yaxis": {
"show": false
},
"legend": {
"show": false
},
"stroke": {
"width": 6,
"curve": "smooth"
},
"grid": {
"show": true,
"strokeDashArray": 4,
"padding": {
"left": 2,
"right": 2,
"top": 0
}
},
"dataLabels": {
"enabled": false
},
"tooltip": {
"enabled": true,
"x": {
"show": false
}
}
}"##;
html! {