Bar Graph Question

Posted on
Wed Jun 05, 2019 12:03 pm
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Bar Graph Question

So I'm tracking how many cycles my AC runs in a day, and those values are accumulating in variables.... one for today that updates when the AC runs, one for yesterday, (which just shuffles the totals around..), and one for the day before yesterday.

Ideally, I'm looking for a bar graph that would have today and the 2 previous days expressed as individual totals in a bar graph, and as today's total increased, the bar for today would rise as well. I've got the CVS engine set up to track the variables, which are just plain numbers, but can't get the bar graph to work.

I have this set up for 3 bars(I'm hoping for one for each day I'm tracking)

For X Axis, I have the format as none, since this is not a day/hour graph, just a total, and scale is set to every day, since in essence, I'm looking at totals for a day..
Y Axis is checked, but haven't changed anything there.

For Bars 1,2, and 3, all I've got checked is "Annotate", and have selected different colors.

Values for today are 16, for yesterday 25, and for the previous day, 29

BUT so far, what I get isn't what I'm expecting. What I got is a chart with 3 bars, seemingly 1 for yesterday and 2 for the day before, but none for today.

Is there a way to make this work more like the Battery chart? Or do I need to wait a few days for the data to populate correctly?

Image

Posted on
Wed Jun 05, 2019 4:00 pm
DaveL17 offline
User avatar
Posts: 5011
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Bar Graph Question

So here's what I did to get it to work which may solve your issues as well. Set the number of bars equal to 3 and set the bar width to something other than zero (I used 0.1). You don't have to use this value, and you should be able to adjust to taste. I think the key is to make it a non-zero value. In my case, I also set the Y axis minimum at zero as well, which to me is more visually logical.

Please let me know how you get on.

chart_bar_test.png
chart_bar_test.png (8.35 KiB) Viewed 577 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Jun 05, 2019 5:01 pm
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Re: Bar Graph Question

Getting no where.

I still have 3 bars, but they are all from the same day
Image

Here are my settings. I've got each "day" set up in the CVS Engine, and each day as a different Bar, and a different color. But I can't get Bar 1 and Bar 2 to display in the graph.




Image

Posted on
Wed Jun 05, 2019 6:26 pm
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Re: Bar Graph Question

Hmmm

I think I found my error... Please Stand By... :roll:

Posted on
Wed Jun 05, 2019 9:20 pm
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Re: Bar Graph Question

So I had the some wrong info in the CVS Engine, but finally got that straightened out. I've also checked the CVS files themselves, and they are populated with the right data that looks like this(from one of the files):
2019-06-05 21:06:24.063967 20
2019-06-05 21:21:31.022239 20
2019-06-05 21:36:34.231042 20
2019-06-05 21:51:38.154496 20
2019-06-05 22:06:41.347201 20


All three files are present, and all 3 files have the right data. But my graph hasn't changed. I have 3 bars, but all 3 are identical, and all reflect the 3rd day's data, so I still don't have today's data or yesterday's data.

I keep thinking I have something set wrong, but can't figure out what.

Posted on
Thu Jun 06, 2019 3:43 am
DaveL17 offline
User avatar
Posts: 5011
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Bar Graph Question

A couple possibilities.

1. The example data you posted doesn't have the header line, but it may be that you just didn't include it in your post. The first line of the CSV file should be:
Code: Select all
Timestamp,ACRunTimeToday


2. The example data you posed doesn't have commas separating the data elements. It should be:
Code: Select all
Timestamp,ACRunTimeToday
2019-06-05 21:06:24.063967,20
2019-06-05 21:21:31.022239,20
2019-06-05 21:36:34.231042,20
2019-06-05 21:51:38.154496,20
2019-06-05 22:06:41.347201,20

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Jun 06, 2019 7:38 am
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Re: Bar Graph Question

You are right.. I just didn't copy all those things to post, but the data in the file is formatted as:

Timestamp,ACRunTimeToday
2019-06-05 12:03:33.648416,15
2019-06-05 12:18:37.534008,15
2019-06-05 12:33:50.661799,15
2019-06-05 12:48:55.116020,16
2019-06-05 13:03:58.435163,16
2019-06-05 13:19:02.489410,17
2019-06-05 13:34:05.849685,17
2019-06-05 13:49:09.831712,17
2019-06-05 14:04:13.122421,17
2019-06-05 14:19:17.088222,17
2019-06-05 14:34:19.741350,17
2019-06-05 14:49:22.834748,17
2019-06-05 15:04:26.589534,17
2019-06-05 15:19:29.727106,17
2019-06-05 15:34:33.534746,17
2019-06-05 15:49:36.684442,17
2019-06-05 16:04:40.491110,17
2019-06-05 16:19:43.611848,17
2019-06-05 16:34:47.433890,17
2019-06-05 16:49:50.546873,17
2019-06-05 17:04:54.388804,17
2019-06-05 17:19:57.530297,18
2019-06-05 17:35:01.329102,18
2019-06-05 17:50:04.418228,18
2019-06-05 18:05:08.453083,18
2019-06-05 18:20:11.851756,18
2019-06-05 18:35:15.882103,18
2019-06-05 18:50:19.220191,19
2019-06-05 19:05:23.610909,19
2019-06-05 19:20:27.382324,19
2019-06-05 19:35:57.207327,19


But still, three bars, only one day's data in the graph....

Posted on
Thu Jun 06, 2019 9:53 am
DaveL17 offline
User avatar
Posts: 5011
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Bar Graph Question

The data looks like it's formatted properly, so I suspect that it has something to do with the settings for the chart. Can you show me the settings for all three bar groups, please?

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Jun 06, 2019 6:27 pm
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Re: Bar Graph Question

Hey Dave... just not sure what's happening here, but here we go.

Given my mistakes of the past, I decided just to start over, so deleted all of the existing "cycle" tracking in the CVS engine, deleted all the .png files in the system library location, and deleted all of the existing CVS files.. again.. just to be sure. I'm only tracking some weather data for another graph(which works great BTW), so starting over just seemed like a good idea.

So first, here are the 4 variables I'm tracking:
Image

Here are 2 of the 4 entries in the Indigo Graph Device:
Image


Image

And finally, how I currently have the graph device setup
Image

And finally, this is the chart from just a few minutes ago.
Image

So I'm not sure if all the changes just take a few days to kick in, but it seems this should work, but I can't get more than one data set to display in a graph, seemingly, regardless of what I do. I'm sure there is an elemental mistake I'm making, but I've tried any number of things, but can't get past one data set in the graph.

Any ideas? ?

Posted on
Thu Jun 06, 2019 6:55 pm
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Re: Bar Graph Question

And this is from data from something entirely different, but I noticed that the bars are "stacked", so I'm wondering if the bar graph isn't really designed to display the data like in the battery graph... (which would be perfect if I could chose items over than batteries to track...)

Image

Posted on
Thu Jun 06, 2019 7:26 pm
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Re: Bar Graph Question

Sooo LASTLY. I reversed the order of the "Bars"... so bar 1 is 3 days ago, Bar 2 is 2 days ago, and Bar 3 is Yesterday, and Bar 4 is Today. Luckily, the way the data falls gives this:

Image

But if I go in and manually change the data, making the numbers not in descending order, I get this:

Image

Note the very LAST Bar has 4 numbers, but only 3 colors, because I changed the data... so I don't think the Bar Graph is going to display things the way I had hoped. But there are plenty of other ways to display this data in a meaningful way.

Posted on
Thu Jun 06, 2019 7:48 pm
DaveL17 offline
User avatar
Posts: 5011
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Bar Graph Question

Okay, I think we might be zeroing in on something. Your CSV Engine settings look fine. Your chart settings look fine. Your chart settings are to display four bars and you're getting four bars. What I think is happening is that the bars are being plotted on top of each other because their timestamps are so close together. Do me a solid and suppress all but one bar group in turn to see if they're plotting properly by themselves.

Unless I've done something really wrong, the other chart isn't stacked, but rather a demonstration of what I'm talking about. I believe the bars are being placed on top of each other.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Jun 06, 2019 7:51 pm
DaveL17 offline
User avatar
Posts: 5011
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Bar Graph Question

Yep, you just proved my theory. I agree, bar charts probably aren't the way to go here.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Jun 07, 2019 5:09 am
DaveL17 offline
User avatar
Posts: 5011
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Bar Graph Question

In thinking about this a little bit more, I think we can still do what you want to do with a bit of a hack.

Create an Indigo schedule to save your data at a set time interval. Have the schedule run this Python script (you'll need to edit it a bit for your environment):

Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-

csv_path = '/Users/username/Documents/Indigo Logs/archive/'  # put your CSV Engine data path here
values = {
    '001CycleTimesToday':     ('1970-01-01 00:00:00.000000,', indigo.variables[294582058].value),  # change these variable ids to match yours
    '002CycleTimesYesterday': ('1970-01-02 00:00:00.000000,', indigo.variables[1992762195].value),
    '003CycleTimes2DaysAgo':  ('1970-01-03 00:00:00.000000,', indigo.variables[1657535056].value),
    '004CycleTimes3DaysAgo':  ('1970-01-04 00:00:00.000000,', indigo.variables[1981656353].value)
}

for key in values.keys():

    with open(csv_path + key + ".csv", 'w') as outfile:
        outfile.write("Timestamp," + key + "\n")
        outfile.write(values[key][0] + values[key][1])
This will create four files with one observation per file which you can then plot. You'll have to put labels and such in manually using the control page editor. To add more days, replicate the lines in the values dictionary (matching the date pattern). Each time the schedule runs, the data files will be replaced with the latest values.

Code: Select all
Timestamp,001CycleTimesToday
1970-01-01 00:00:00.000000,123.4

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jun 10, 2019 4:50 pm
jltnol offline
Posts: 410
Joined: Oct 15, 2013

Re: Bar Graph Question

Wow!

I'll give it a try and let you know how it works out.

Thanks!

Who is online

Users browsing this forum: No registered users and 2 guests

cron