Comments (4)
Hi, the candlestick examples are still there. Please check this section in readme - https://github.com/yuankunzhang/charming/#candlestick-charts
from charming.
thanks! I will close the issue, was checking out the project on docs.rs and that might be why I didn't see it
from charming.
@pferreira8
Hi,
Do you know how to use polars dataframe in charming ? Is it compatible with charming dataframe ?
from charming.
@pferreira8 Hi, Do you know how to use polars dataframe in charming ? Is it compatible with charming dataframe ?
It is compatible once you convert the Dataframe into a Vec<Vec>
I have the logic split between two functions, it could be cleaned up for sure but this was my hacky method that worked.
// pass df into this function, assuming column names below or edit them to match properly
fn parse_ohlc_data(data: DataFrame) -> Result< (Vec<Vec<f64>>, Vec<String> ), Box<dyn std::error::Error> > {
let d_open: Vec<f64> = data.column("open")?.f64()?.into_iter().map(|x| x.unwrap()).collect();
let d_high: Vec<f64> = data.column("high")?.f64()?.into_iter().map(|x| x.unwrap()).collect();
let d_low: Vec<f64> = data.column("low")?.f64()?.into_iter().map(|x| x.unwrap()).collect();
let d_close: Vec<f64> = data.column("close")?.f64()?.into_iter().map(|x| x.unwrap()).collect();
let dt: Vec<String> = data.column("date")?.iter().map(|x| x.to_string()).collect();
let mut ohlc_vec: Vec<Vec<f64>> = Vec::new();
for i in 0..d_open.len() {
let array: [f64;4] = [d_open[i], d_high[i], d_low[i], d_close[i]];
ohlc_vec.push(array.to_vec());
}
Ok((ohlc_vec, dt))
}
pub fn build_symbol_chart(symbol_name: &str, ohlc: (Vec<Vec<f64>>, Vec<String>)) -> Result<(), EchartsError> {
let chart = Chart::new()
.x_axis(Axis::new().show(true).data(ohlc.1))
.y_axis(Axis::new().show(true).scale(true))
.data_zoom(
DataZoom::new()
.type_(DataZoomType::Slider)
.min_value_span(5),
)
.series(Candlestick::new().data(
ohlc.0
)).background_color("6E7468");
let mut rend = HtmlRenderer::new("OHLCV", 1000, 800).theme(Westeros);
let dir_file = format!("./html/charts/{}.html", symbol_name);
HtmlRenderer::render(&rend, &chart)?;
rend.save(&chart, std::path::Path::new(&dir_file))?;
// println!("saving chart to html");
Ok(())
}
// EXAMPLE
//converts polars df to work with charming
let ohlc = parse_ohlc_data(data).unwrap();
// creates an html file for candlestick charts
tools::chart::build_symbol_chart(YOUR_FILE_NAME_HERE, ohlc)?;
from charming.
Related Issues (20)
- Line with label is not supported? HOT 2
- Custom themes by deserializing JSON? HOT 2
- feat: method to set decal pattern in ItemStyle
- [feature request] Derive some useful traits HOT 2
- Shall we have a discord channel? HOT 2
- roadmap HOT 3
- ChartResize has no pub fields
- Could Echart be Clone?
- Slice of a polar plot
- No support for u64 or usize
- Polars Dataframe, ndarray and charming dataframe HOT 1
- Customized label
- impl `Clone` on everything
- chart-rs and charming
- Discord link is broken
- Live plots ??
- Issue with running example on windows-gnu HOT 1
- Feature Request: Table
- Feature Request: Logarithmic scale Histogram
- Feature Request: Scatter Plot with Histogram
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from charming.