!bdzgpXRaSADLSnaZvx:matrix.org

ytop

7 Members
4 Servers

Load older messages


SenderMessageTime
21 Feb 2020
@tarkah:matrix.org@tarkah:matrix.orgI spent yesterday pretty much refactoring everything as I finally landed on how I wanted it all19:48:02
@cjbassi:matrix.orgcjbassiNice, yeah that seemed petty quick19:57:20
@cjbassi:matrix.orgcjbassi Btw have you seen cointop? It's similar but for crypto 19:57:47
@tarkah:matrix.org@tarkah:matrix.orgI have not, that looks super cool!19:58:48
@tarkah:matrix.org@tarkah:matrix.orgIt sucks, any stock / option data is basically paid or severly rate limited. The free api I found is ok, but lacking a lot.19:59:44
@tarkah:matrix.org@tarkah:matrix.organd I wanted whatever I created to be usable by anyone, not something you'd have to get a paid API key for. I just want it to open up and work20:01:36
@tarkah:matrix.org@tarkah:matrix.org Oh hey, I was going to say, thanks for the PR GraphType / Line. Question on that... what determines how many braille points fill in between x/y1 and x/y2 ? 20:17:46
@tarkah:matrix.org@tarkah:matrix.orgon my chart, when I have only a few datapoints, usually no new points are filled in between two datapoints20:18:24
@tarkah:matrix.org@tarkah:matrix.orgI tried using Canvas with Line before I saw your PR on master. But yeah, my "lines" hardly seem to do anything between two points20:20:16
@cjbassi:matrix.orgcjbassi Hmm, that's unfortunate. Is it possible to create your own API? XD 20:31:21
@cjbassi:matrix.orgcjbassi Yeah so there's something wrong with that pull request I made. It should create a full line between the points, but for some reason it's sometimes skips some dots 20:33:41
@cjbassi:matrix.orgcjbassiIt might be an issue with the canvas20:33:56
@tarkah:matrix.org@tarkah:matrix.org lol that'll have to be another project for another day :P 20:53:16
@tarkah:matrix.org@tarkah:matrix.orgMust be an issue with the canvas because it performed the same when I used canvas directly20:53:22
@cjbassi:matrix.orgcjbassi Hmm, well that's good to know. I have an issue open in ytop for that already. Maybe we need a tui issue too 21:07:47
@tarkah:matrix.org@tarkah:matrix.orgSo I am thinking about my issue more and I think it's different. I plot a datapoint along every point of the x axis. I think there needs to be some space between datapoints on the x axis for the line to work? I need to try a test out to extend my x_bounds by maybe 4x and space my data out along every 4th point on the x axis and see if that helps create an actual line between points.21:17:53
@tarkah:matrix.org@tarkah:matrix.orgYUP, that did the trick. I just multiplied the x_bounds end x 4 and the index of the dataset by 4 and it looks way better21:24:04
@tarkah:matrix.org@tarkah:matrix.orgwill need to figure out the optimal factor to scale by for each time frame as the # datapoints for each will be much different21:24:45
@tarkah:matrix.org@tarkah:matrix.orgScreenshot from 2020-02-21 13-28-59.png
Download Screenshot from 2020-02-21 13-28-59.png
21:30:05
@tarkah:matrix.org@tarkah:matrix.orgbefore21:30:07
@tarkah:matrix.org@tarkah:matrix.orgScreenshot from 2020-02-21 13-27-36.png
Download Screenshot from 2020-02-21 13-27-36.png
21:30:16
@tarkah:matrix.org@tarkah:matrix.orgafter21:30:17
@tarkah:matrix.org@tarkah:matrix.org'''diff21:34:16
@tarkah:matrix.org@tarkah:matrix.org
diff --git a/src/widget/stock.rs b/src/widget/stock.rs
index 83a169c..49a5c4b 100644
--- a/src/widget/stock.rs
+++ b/src/widget/stock.rs
@@ -12,6 +12,8 @@ use tui::widgets::{
     Axis, Block, Borders, Chart, Dataset, GraphType, Marker, Paragraph, Tabs, Text, Widget,
 };
 
+const X_SCALE: usize = 100;
+
 pub struct StockWidget {
     symbol: String,
     stock_service: service::stock::StockService,
@@ -117,7 +119,7 @@ impl StockWidget {
     fn x_bounds(&self) -> [f64; 2] {
         match self.time_frame {
             TimeFrame::Day1 => [0.0, 1000.0], // Need to update once intra ready
-            _ => [0.0, (self.prices.len() + 1) as f64],
+            _ => [0.0, ((self.prices.len() * X_SCALE) + 1) as f64],
         }
     }
 
@@ -282,7 +284,7 @@ impl Widget for StockWidget {
 }
 
 fn cast_as_dataset(input: (usize, &f32)) -> (f64, f64) {
-    ((input.0 + 1) as f64, *input.1 as f64)
+    (((input.0 * X_SCALE) + 1) as f64, *input.1 as f64)
 }
 
 fn cast_historical_as_price(input: &HistoricalDay) -> f32 {
21:35:39
@cjbassi:matrix.orgcjbassi Wow nice, that's awesome. Should tui be updated so we don't have to do the multiplication stuff ourselves? Might help people in the future 22:07:18
@tarkah:matrix.org@tarkah:matrix.orgI'd think so. Your dataset shouldn't have to be transformed to get a line graph. The line graph should be created reliably from whatever dataset you throw at it.22:12:18
@tarkah:matrix.org@tarkah:matrix.orgI'll open an issue22:12:38
@tarkah:matrix.org@tarkah:matrix.orgissue opened here:22:44:22
@tarkah:matrix.org@tarkah:matrix.orghttps://github.com/fdehau/tui-rs/issues/23222:44:24
22 Apr 2020
@daniel.bast:matrix.org@daniel.bast:matrix.org joined the room.06:26:06

Show newer messages


Back to Room ListRoom Version: 5