Chart widget

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
Spixi
Posts: 91
Joined: August 23rd, 2010, 7:22 pm

Chart widget

Post by Spixi »

As mentioned in https://wiki.wesnoth.org/NotSoEasyCoding#Gold_graph it is desired to have a chart widget to show several variables.

This is a concept for the chart widget (at the moment without legend) written for GUI2. At the moment it is just a stub with dummy data, but you can find a first insight right here.
chart.png
If you are interested in the implementation, have a look at my GitHub: https://github.com/spixi/wesnoth/tree/chart_engine

The proposed WML syntax is:

Code: Select all

[chart]
	scaling=linear|logarithmic
	[data]
		label= _ "turn number"
		[dataset]
			color=0,255,0,255
			label= _ "gold"
			values=1,3,5,7
		[/dataset]
		[dataset]
			color=255,0,0,255
			label= _ "units killed"
			values=0,0,1,3,4
		[/dataset]
	[/data]
[/chart]
Do you have any tips for the implementation or any other ideas?
Spixi
Posts: 91
Joined: August 23rd, 2010, 7:22 pm

Re: Chart widget

Post by Spixi »

I made a big update to the chart widget. See my original post above.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Chart widget

Post by gfgtdf »

Can this widget also show bar charts like in the attack prediction dialog?
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Spixi
Posts: 91
Joined: August 23rd, 2010, 7:22 pm

Re: Chart widget

Post by Spixi »

gfgtdf wrote:Can this widget also show bar charts like in the attack prediction dialog?
Hello gtgtdf,
this should be easy to implement.

This requires new key type= in the data tag to switch between line and bar chart. The only difference is that I have to draw rectangles instead of lines. We could even allow mixed charts with a bar chart in the background and a line chart in the foreground with multiple data tags. Currently I am very busy and the weather is great outside, so I am going to implement your idea, if I find some time for this. (At the moment the data tag is not yet read; I use hard-coded values in the proof of concept.)
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Chart widget

Post by gfgtdf »

Ok, i was asking becaue we want to port the attack prediction dialog to gui2 and we still need a widget to show the chart there. The have not decided yet which type of chart would fit best.

Does this widget now work fine already for line charts?
Do you intend ot make a pull request on github with this?
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Spixi
Posts: 91
Joined: August 23rd, 2010, 7:22 pm

Re: Chart widget

Post by Spixi »

gfgtdf wrote:Ok, i was asking becaue we want to port the attack prediction dialog to gui2 and we still need a widget to show the chart there. The have not decided yet which type of chart would fit best.

Does this widget now work fine already for line charts?
Do you intend ot make a pull request on github with this?
As said, this widget uses hard-coded values at the moment. The config data is already available, but the parser part is still missing. The legend is also not implemented yet. Unfortunately I have not much time for the implementation. I'll try to do what I can when I get some free time. The line chart is better to show progressions and trends, bar charts are better to compare absolute values. I feel that a bar chart would be the better way for the attack prediction dialog.
User avatar
Celtic_Minstrel
Developer
Posts: 2195
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Chart widget

Post by Celtic_Minstrel »

I agree on a bar chart being better for attack prediction. Note that there are two orientations for a bar chart, and supporting both could be useful.

Anyway, the concept image looks great, so I'll look forward to seeing this finished.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply