Jump to content

Stacked Bar Chart Function


Recommended Posts

Hi Seeq!

I am wondering if there is a simple way to create a stacked bar chart in Seeq if I have multiple signals that all have the same units. I am trying to figure out how to plot a normal stacked bar chart and also a 100% stacked bar chart if there is such functionality or if I can do a workaround in formulas?

Thanks,

Jason

Link to comment
Share on other sites

  • Seeq Team

Hi Jason, 

Great question!

You can achieve a stacked histogram by following the steps below. 

You'll see that in the screenshot below I have 3 temperature signals, all having the same units - I believe this mimics the scenario in your question.

image.png

 

Then I create a Histogram - note you can aggregate your signal properties as you like here, this is just an example. 

image.png

Then finally, once you Execute the Histogram, you can convert the Histogram by clicking the "Stack" box as circled in the image below. This configuration will appear when you click the Customize button in your details pane, as denoted by the red arrow.

image.png

The final result should look like a set of stacked histograms, as per my image below.

image.png

 

Please let me know if this addresses your question.

-Kjell

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
On 6/23/2020 at 1:30 PM, Kjell Raemdonck said:

Hi Jason, 

Great question!

You can achieve a stacked histogram by following the steps below. 

You'll see that in the screenshot below I have 3 temperature signals, all having the same units - I believe this mimics the scenario in your question.

image.png

 

Then I create a Histogram - note you can aggregate your signal properties as you like here, this is just an example. 

image.png

Then finally, once you Execute the Histogram, you can convert the Histogram by clicking the "Stack" box as circled in the image below. This configuration will appear when you click the Customize button in your details pane, as denoted by the red arrow.

image.png

The final result should look like a set of stacked histograms, as per my image below.

image.png

 

Please let me know if this addresses your question.

-Kjell

Hello Kjell,

I have been playing with this more and was wondering if you had a solution for the following:

1) I have 17 signals all with the same units.

2) I would like to make a stacked bar chart with all 17 signals, aggregating the data into hour sized bins.

Is that possible?

-Jason

Link to comment
Share on other sites

  • Seeq Team

Hi Jason, 

You can certainly aggregate by hour (we call it hour of the day - so your bins would become hour 0, 1, 2, 3, 4, 5, etc until you reach 23 - for a full 24h each day). You'll see that as a setting in the Histogram tool.

I've tossed together an example which I'm hoping will show how you can go about this for multiple signals. My example has 4 signals I want to aggregate - just think of expanding that to 17 for your case.

Step 1. Need to get all those samples from my 4 different signals into 1 common signal.

in Formula, I write the following:

$s1 = $t1.validValues().resample(1min).setMaxInterpolation(3s)
$s2 = $t2.validValues().resample(1min).setMaxInterpolation(3s).move(1s)
$s3 = $t3.validValues().resample(1min).setMaxInterpolation(3s).move(2s)
$s4 = $t4.validValues().resample(1min).setMaxInterpolation(3s).move(3s)

combineWith($s1,$s2,$s3,$s4)

I resample to 1min so that all my original signals now have a sample point at the same timestamp, and then I delay each sample by 1s, so that in the combined signal they are offset - this allows me to aggregate each of those samples from my original signal. Now if your original signal samples are all coming in at the same timestamp anyway, you don't need to use the resample(1min) function.

Visually, you can see the transformation in the snapshot below (the new combined signal is at the bottom):

image.png

Step 2. I duplicate the signal I just created - this is so that I can use the sample values from this signal as my second aggregation (recall, first aggregation is by hour of day, so second will be by values - can create 5 bins for instance by choice). 

Step 3. Create Histogram

Now I create a new Histogram via the tool, and I have configured it as you can see on the left of the snapshot below.

image.png

The x-axis of the histogram represents the "hour of the day", where 01 is hour 0, or the 1st hour (midnight to 1am), and 231 is hour 23 (11pm to midnight). Then the different bars inside each hour represent the 5 bins I chose to define my distribution (you can also choose based on set values by choosing the "size of bin" option).

Now you can make this stacked by opening the "Customize" pane and checking the "stacked" box. See below:

image.png

I also changed the display to just 1 day from midnight to midnight - as you can see we have the same total samples every hour (which makes sense as we resampled to a constant 1min frequency for each of the 4 signals), but the sample count within the value bins changes over time - I've changed the colors so you can see those bins more easily.

 

Let me know if this answers your question. It's a bit more in depth, so if you'd like, we can hop on a Zoom call and work through it for your data together.

Thanks,

Kjell

Link to comment
Share on other sites

  • 7 months later...

Hello,

How would you adopt that last method such that you're binning by the name of each signal? So you'd have Avg of Temp 1, Avg Temp 2, ..., as the bins rather than temperature ranges?

I started along the lines of a signal to capsule and making a property for the name but couldn't quite figure it all out.

thanks.

Link to comment
Share on other sites

  • Seeq Team

You're on the right track with the Capsule Property being the Signal name. So in the histogram, you could then first aggregate by "Condition" (instead of "Time" as shown in the above) - this condition would be a combineWith() condition with all your signal conditions with their associated properties. More info on capsules props here: 

 

I also wonder if you could use a method similar to this one to bin the signals? Maybe it could work for your use?

This example also shows how to bin (in this case via assets) 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...