Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Stacked column chart
Stacked column chart [message #48557] Mon, 24 July 2017 12:52 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
is there a way to create a stacked column chart (something like this)? I had a look at the Scatter functions but it seems that only basic column chart (one value) is supported.
Thanks,
Gio
Re: Stacked column chart [message #48574 is a reply to message #48557] Sun, 30 July 2017 11:58 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Giorgio

Probably the easiest way is to overlap the column charts, preparing them so that if they are a, b and c, to plot:
a'=a
b'=a+b
c'=a+b+c

Anyway if you propose a simple way to include this in actual interface, it could be implemented immediately.


Best regards
Iñaki
Re: Stacked column chart [message #48575 is a reply to message #48574] Mon, 31 July 2017 12:33 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi Koldo,
I did it manually similarly as you proposed: it was not much work, I was only wondering if something already existed and I missed it; for me the current library it is ok.
Thanks,
Gio
Re: Stacked column chart [message #48577 is a reply to message #48575] Mon, 31 July 2017 22:57 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Giorgio

May it be done by defining some data series as "stacked" so that when painted into a ScatterDraw/ScatterCtrl, the plots would be drawn one over the next one (stacked)?


Best regards
Iñaki

[Updated on: Mon, 31 July 2017 22:58]

Report message to a moderator

Re: Stacked column chart [message #48587 is a reply to message #48577] Wed, 02 August 2017 15:11 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi Koldo,
I have in mimd something as the following.

This structure contains, the x position where to place each stacked columns and a list of the values to be stacked; for instance if values contains 3; 2.5; 1.2; 0; 3.1 the column will have the first segment that goes (in the y axis) from 0 to 3, the second from 3 to 5.5, the third from 5.5 to 6.7 etc.

struct StackedValues {
double x_position;
Vector<double> values;
};

Then a method that places the stacked column in the control.

scattercontrol.AddStacked(StackedValues stcv)

The above method has to be invoked for each of the stacked columns. The case in which values are in different number (e.g. first time the use calls the method passing a vector of 5 elements, second time the vector has 6 elements) should be managed in some way e.g. if values are missing it assumes they are zeros. Nice to have are a method to control the color of the segment and a method to add a legend and give a name to the segments (e.g. the legend will show the color of each segment and close to it a description of what the segment represents http:// 6.anychart.com/products/anychart/docs/users-guide/img/Sample s/sample-stacked-column-chart.png).
Re: Stacked column chart [message #48588 is a reply to message #48587] Thu, 03 August 2017 10:24 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Giorgio

It is not possible to use struct StackedValue without doing major changes because ScatterDraw is based in DataSeries to insert series of data to be plotted.
I propose you to add BeginStacked() and EndStacked() to indicate that next series added are going to be stacked. This way the same plot could mix stacked series with any other.
Is it OK?


Best regards
Iñaki
Re: Stacked column chart [message #48590 is a reply to message #48588] Thu, 03 August 2017 10:32 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
I see... if that is the case, it is OK for me.
Re: Stacked column chart [message #49175 is a reply to message #48590] Sun, 31 December 2017 17:29 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hi Giorgio

Stacked plots are now included. Please see ScatterCtrl_demo.

The way to do it is different. It is based in the new DataStackedY DataSeries.


Best regards
Iñaki
Re: Stacked column chart [message #49271 is a reply to message #49175] Mon, 15 January 2018 09:27 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi Koldo,
thank you for the effort you put on this, here some feedback from my side.

My goal was to have something like this:

https://pasteboard.co/H30HFny.png

At the beginning I was a little bit confused because there is probably a typo in your code; you wrote:

scatter.AddSeries(stacked.Get(2)).Legend("s1").Fill();
scatter.AddSeries(stacked.Get(1)).Legend("s2").Fill();
scatter.AddSeries(stacked.Get(0)).Legend("s3").Fill();


while should be

  
scatter.AddSeries(stacked.Get(2)).Legend("s3").Fill();
scatter.AddSeries(stacked.Get(1)).Legend("s2").Fill();
scatter.AddSeries(stacked.Get(0)).Legend("s1").Fill();


After fixing that everything is much clearer. It is much easier now to create a bar graph. It would be nice if it was possible to add the value/percentage of each section inside the section itself, as in the pie chart.

Regards,
Gio
Re: Stacked column chart [message #49288 is a reply to message #49271] Tue, 16 January 2018 08:48 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hi Giorgio

I agree with your fix.

Quote:
It would be nice if it was possible to add the value/percentage of each section inside the section itself, as in the pie chart.
Could you include an example?


Best regards
Iñaki
Re: Stacked column chart [message #49290 is a reply to message #49288] Tue, 16 January 2018 11:05 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Could be the same example as in the pie chart but stacked.
Re: Stacked column chart [message #49297 is a reply to message #49290] Wed, 17 January 2018 11:06 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Giorgio wrote on Tue, 16 January 2018 11:05
Could be the same example as in the pie chart but stacked.
Sorry Giorgio. Could you include a picture?


Best regards
Iñaki
Re: Stacked column chart [message #49299 is a reply to message #49297] Thu, 18 January 2018 09:45 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi Koldo,
currently the application we developed creates a CSV file and then, using excel, we create a graph as follows.

https://pasteboard.co/H3t7Glw.png

The goal is to avoid using excel.
Regards,
Gio
Re: Stacked column chart [message #49307 is a reply to message #49299] Sun, 21 January 2018 16:54 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
OK, I understand.
I will try to do something to include it.


Best regards
Iñaki
Previous Topic: StreamRasterEncoder?
Next Topic: again... use if deleted function :?
Goto Forum:
  


Current Time: Thu Mar 28 19:11:47 CET 2024

Total time taken to generate the page: 0.01002 seconds