d3fc icon indicating copy to clipboard operation
d3fc copied to clipboard

Need more examples - a techan.js style gallery of financial charts?

Open ralyodio opened this issue 9 years ago • 17 comments

Would it be possible to have more variations on candlestick/ohlc charts here?

ralyodio avatar Aug 19 '17 19:08 ralyodio

Sure, what sort of examples are you looking for?

ColinEberhardt avatar Aug 20 '17 06:08 ColinEberhardt

This project has a lot of examples, but its abandoned: https://github.com/andredumas/techan.js/wiki/Gallery

ralyodio avatar Aug 20 '17 13:08 ralyodio

I didn't realise techan.js had been abandoned. d3fc has a very similar feature-set, so should be a decent alternative to techan.

I might have a go at creating a similar gallery for d3fc.

ColinEberhardt avatar Aug 21 '17 07:08 ColinEberhardt

Any progress on this?

ralyodio avatar Sep 04 '17 21:09 ralyodio

I'm slowly building up these examples on my blocks page:

https://bl.ocks.org/ColinEberhardt

Once I have a decent number, I'll add them to the d3fc examples page. If you've got any specific examples you want to see, let me know.

Also, feel free to create your own ;-)

ColinEberhardt avatar Sep 05 '17 05:09 ColinEberhardt

I'm looking to use your library to build something like this: https://cryptowat.ch/poloniex/btcusd

If you had an example with the charting, volume and MACD or whatever else your library offers that would be cool.

ralyodio avatar Sep 05 '17 10:09 ralyodio

@chovy - the examples page is growing ... with quite a few financial charts

screen shot 2017-09-11 at 08 47 38

ColinEberhardt avatar Sep 11 '17 08:09 ColinEberhardt

Awesome!

ralyodio avatar Sep 11 '17 15:09 ralyodio

@ColinEberhardt, I've modded your simplified lowbarrel line chart. Very nice work and a great example! Im trying to figure how to annotate or label various points on the main chart.

Im getting the data like so:

    data.forEach(function(d) {
        d.date = new Date(d['candledate']);
        d.price = Number(d['close']);
        if (Number(d['buy']) > 0)
          d.action = 'B';
        else if (Number(d['sell']) > 0)
          d.action = 'S';
        else
          d.action = '';
    });

and then under example.mainChart I have:

    var lineSeries = fc.series.line()
        .xValue(function(d) { return d.date; })
        .yValue(function(d) { return d.price; })
        .decorate(function(selection) {
          selection.enter()
            .append('text')
            .style('text-anchor', 'middle')
            .attr('transform', 'translate(0, -10)')
            .text(function(d) { return d.action; })
            .attr('fill', 'black');
        });

So I've attempted to add text via decorate though apparently I'm not using it correctly. Is there any chance we could get an example of annotating and/or labeling points?

generalectric avatar Oct 17 '17 01:10 generalectric

@generalectric happy to help! Your decorate code looks right to me, not sure what the problem is?

You can find an example, based on a bar chart here:

https://bl.ocks.org/ColinEberhardt/8845df1f2c6b496148eb4e3b02c238ac

Alternatively, if you can get your code into a codepen / jsfiddle, I'd be happy to take a look.

ColinEberhardt avatar Oct 17 '17 07:10 ColinEberhardt

@ColinEberhardt awesome! another great example.. slimming it down removing the variable altogether and all options... i mean just hard coding the text to be displayed each point still shows blank. Im probably missing something silly, but here is a plunkr with what i have.

https://plnkr.co/edit/02ZdjUmyJSx29VPaFq1I?p=preview

generalectric avatar Oct 18 '17 01:10 generalectric

@generalectric unfortunately you are using a very very old version of both d3fc and D3. Where did you find a link to 'lowbarrel'? We really should remove (or update) that.

Here's an example of a navigator chart using the latest version of d3fc (and D3v4):

https://bl.ocks.org/ColinEberhardt/000b1721b69868f1ce5d

It might be a better starting point.

ColinEberhardt avatar Oct 18 '17 10:10 ColinEberhardt

Thanks alot @ColinEberhardt, thats very useful and gets me back on track. Its actually the best brush example ive seen. I believe you actually updated the old low barrel code with the brush example so thats good hopefully it can save some other people time and prevent them from running into a roadblock down the road. i have however tried adding labels to the new code using decorate and have failed in hard coding them. Any chance you could paste me a snippet of how i would add a text label with the letter 'A' to every single point in mainchart?

generalectric avatar Oct 19 '17 03:10 generalectric

Sure, here you go:

https://codepen.io/anon/pen/YrBOpO?editors=1010

I think the issue you might have faced is that line / area series are drawn as a single SVG path, which means they don't have individual datapoints which you can decorate. The above code combines a line series with a point series (via multi), and decorates the point series to add the letter 'A'. You can of course hide the point series circles via CSS (or even remove them within the enter selection when decorating).

ColinEberhardt avatar Oct 19 '17 14:10 ColinEberhardt

Thank you so much! Oh and you nailed it, I had no clue that I had to combine points into multi series. Also I've tried to remove circles within enter selection but no luck. I did however remove them 'globally' using .size(0) outside of decorate, though I would like to remove them within enter selection as you mentioned. And Im trying to change text color from fill black... to fill green or red but the fonts are all stroked black. Is there a way within decorate to remove the stroke or is this simply something for css? I tried using .style('text-stroke', '0px') and some others with no luck.

generalectric avatar Oct 20 '17 05:10 generalectric

Is it possible to include an example where multiple indicators are included with a candlestick chart similar to techanjs "All Plots"? In particular the MACD and RSI at the bottom?

http://bl.ocks.org/andredumas/edf630690c10b89be390

irperez avatar Dec 14 '17 15:12 irperez

@irperez I appreciate this is a little late in the day but this example shows something similar to what you're after. If you want to break it out into its own separate plot area, you'll need to create a custom chart using d3fc-element with custom CSS.

Closing to track new example requests using the label requires-example

chrisprice avatar Aug 21 '18 10:08 chrisprice