Complete Novice

As the title suggests, I am a complete novice to Observable. I have a notebook where in I have imported a CSV file and I suppose what I need to do now, is start displaying that information in a graphical way.

Any pointers? A simple bar graph would suffice.

I’m biased, but I would suggest taking a look at Observable Plot (and Observable Inputs). The Plot notebook includes an example of working with CSV data:

Man thank you so much for the quick reply. To be clear it is a list of transactions. I suppose I can use it to display amount of time?

Hi @rynsp8 , and welcome! I think the long and short is that you can do anything you’d like! Plot is a charting library backed by D3.js much of the same ilk as other charting tools you get with, e.g. Python or even Excel. There are other options beside Observable Plot (which is really powerful), and depending on your customary tools we can offer more recommendations. The best way to start an open discussion like this is to share a notebook of your progress and to describe your problem and desired results. In that vein, is there more you can share? This community offers a lot of help!

There is more to share, I’m capturing a set of transactions over a few years. The data I’m working with can be found here…

I’m not well-versed in working within the observable community so there may be a more sophisticated way of sharing besides a URL.

Hi @rynsp8 - and this is a great way to share! Only thing is that for us to see, you need to publish (terminology for the ‘next’ interface) or link share (classic interface) so that we can see and explore. Currently that link appears to be private.

Here’s a notebook that addresses sharing:

And something of an update on sharing:

(which links to):

I believe I shared out with you to have a look. I have a few data objects, CryptoSpend, rawData, and fullFile. For some reason, the fullFile isn’t fetching, but it was yesterday.

I think for my immediate purposes, rawData is what I need to work with. Essentially, I would like to create a plot difference chart showing the difference of spending between financial quarters going back to 2017 to current.

I’ve actually made some progress with what I’m wanting. The last bit is adding some details like a header/title, changing the color of the bars, and adding some text.

Any advice/direction on that would be helpful.

that URL is still private, you need to share/publish that notebook.

Just published it.

It should be published now.

I would like to have the totals just after the end of each bar. And add a gradient fill from black, which would be positive, to red, which is negative

Looks like you’re almost there! Have you seen the more detailed information on bar charts?

Looks like there’s something quite close to your target.

aaronkyle, thanks for the input. I really do appreciate it. Do you have an example of data labels being placed on the outside end of the bar rather than overlapping the bar itself?

Hi @rynsp8 - Perhaps I should disclose that I have never made anything using Plot! I’ve been meaning to try…

From messing around on your notebook, it looks like that parameter is controlled here:

 Plot.text(newData, {x: "Quarter", y: "Total", text: "Total", dy: 10})

I simply increased the dy value from 5 to 10 and it re-positioned the text label.

It does, however, due to the positioning of the text, it moves ALL the text up or down at the same time. So, those totals at the bottom will move up into the bar itself, while those on the top will be positioned correctly, and vise versa.

1 Like

@rynsp8 One way to do it would be to pass a function to the y property that adjusts the vertical position depending on whether Total is greater than or less than 0. Here’s what that could look like:

Plot.text(newData, {
  x: "Quarter",
  y: d => d.Total > 0 ? d.Total + 50000 : d.Total - 50000,
  text: "Total",

Note that the adjustment has to be defined relative to your y-axis scale, not in pixels, hence why I’m adjusting by 50,000 in either direction. I had thought maybe there would be a way to pass a function as dy instead, so you could define the adjustment in pixels, but I seem to get an error when I try doing that. Maybe someone better versed in Plot (@mbostock?) can clarify if that’s expected behavior.

1 Like

You can do it as two separate filtered marks:

Plot.text(newData, {filter: d => d.Total >= 0, x: "Quarter", y: "Total", text: "Total", dy: -4}),
Plot.text(newData, {filter: d => d.Total < 0, x: "Quarter", y: "Total", text: "Total", dy: 10}),

Learning Observable - YouTube Just wanted to make sure this YouTube playlist is here to stumble upon on this thread for anyone new to the community! Thanks

1 Like