Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radar/Spider/Net Charts #288

Closed
ccoupe opened this issue Nov 2, 2016 · 64 comments
Closed

Radar/Spider/Net Charts #288

ccoupe opened this issue Nov 2, 2016 · 64 comments
Assignees
Milestone

Comments

@ccoupe
Copy link

ccoupe commented Nov 2, 2016

Here's the latest view on radar charts. Just draws the radial axes and the label of max value of that column. It draws the label poorly but we talk about 'better' after the image.
radar-2

In gruft and other source code I've looked at, our chart_series is equivalent to a row and the value inside the rows are columns. Radar and the like, like to draw/compute down columns. Shoes currently has no API to specify some things for that orientation that users might find useful. In the example above, the labels shown are the computed max (down the columns) but before we can scale and and draw some data points and connected lines, they need to be scaled between min and max. What's the value at the center for each? Compute min? 0? Something else? Can it be specified by the user and if so, how?

@ccoupe ccoupe added this to the 3.3.2 milestone Nov 2, 2016
@ccoupe ccoupe self-assigned this Nov 2, 2016
ccoupe pushed a commit that referenced this issue Nov 2, 2016
* far from acceptable. WIP.
@ccoupe
Copy link
Author

ccoupe commented Nov 3, 2016

Sadly, we do need add an extra arg to plot creation when creating a radar. The most natural is an array of arrays. Ick! Do I have good name - of course not! Let's call it "column_settings:" until someone suggests a better name and it only applies to certain chart types and it is mandatory for radar (and perhaps some new chart types in the future).

plot {...., chart: "radar", column_settings: [ <column 0 settings>, <column 1 settings>, ...]}
What's in a 'column setting'? I think it should be another array or a hash - users choice. Hash is more descriptive but it gets wordy so both should be acceptable { label: <string>, min: <number>, max: <number>, format: <printf_format_string> } .You might wonder about the format: string. If not given then it defaults to "%4.2f" which is not optimal for anyone who cares about their graph. I could even imagine other options like alpha: 0.5 if you want the damn things dimmer (I would).

seeking opinions @backorder , @passenger94 .

@IanTrudel
Copy link
Collaborator

What this new parameters for? It is normally possible to create radar graph with same kind of plot data as any other graphs. For example, see this tutorial for Microsoft Office.

Now it might be a good idea to support optional parameters for plot. I'm just confused why it would be mandatory for radar graph...

@IanTrudel
Copy link
Collaborator

Also as reference another tutorial.

@ccoupe
Copy link
Author

ccoupe commented Nov 3, 2016

Excel and the like have the labels for rows and columns (because they have to be there, or you have to add them later in the wizard) Shoes does not have a wizard for creating charts. Suppose the two values in column 0 are [80, 180]. Are those 0 based? Or should that 80 be the dot in the center? What if another radial/column on the same chart ranges from 20 to -10. Since Shoes adds and draws (chart_series) row by row and does not know how many rows will be added later. It draws what it has and for radar/spider it needs to know the min/max of the radial axis to draw. Review some of those example you posted on the old thread and your see some very "unigue" things about the labels/xaxis/radials.

@IanTrudel
Copy link
Collaborator

My understanding is that radar graph is based on its given values, using minimum and maximum values and evenly stepped. Minimum value is the centre. We may offer optional parameters (unit, scale, step, etc.) for customization. Does it make sense to you?

@ccoupe
Copy link
Author

ccoupe commented Nov 3, 2016

It make sense in some cases. And lacking for others. In the [80, 180] case, you only get two dots when it gets around to drawing the lines and dots - center and the outer radius. What to do if you know that 180 is not the max score on the test and 80 isn't the worst. Maybe 250 is the best (outer ting and 50 is the worst (center) . How to specify that?

@IanTrudel
Copy link
Collaborator

Would you mind sharing a sample code of radar graph in Gruff or any other related API (slash language)? Maybe we could learn something from it.

@ccoupe ccoupe removed this from the 3.3.2 milestone Nov 3, 2016
@ccoupe
Copy link
Author

ccoupe commented Nov 3, 2016

Crux => matter. Excel is an interactive tool for creating charts. Shoes is declarative. So is gruff (clone it and look at the test cases) or pycha and look at the test cases (hard to find). Look at what gnuplot uses for a DSL (bonus points if if you can find a radar/net/spider example that makes sense). Matlib? Wolfram? Some Adobe Thing?. Shoes can't be all of the above. Use them if Shoes is too much trouble.

@IanTrudel
Copy link
Collaborator

Take a look at Chart.js and rgraph. They both have a very clean API. Please, notice Chart.js has an options argument for the special case(s) you are referring to. Otherwise, they both proceed as I stated before.

@ccoupe
Copy link
Author

ccoupe commented Nov 4, 2016

There's no doubt that my bottoms up approach is problematic. Originally, all I wanted was the timeseries chart that I could append RT data to and add and delete series. And then it grew from there. It's not a goal for Shoes to replace dedicated charting applications (or spreadsheets). Just something simple. Now, it's not so simple.

I'm considering (just thinking aloud) that the existing Time series chart and RT stuff should be a different widget (and api) from all the other charts or perhaps an alternative api for all the other other chart types. For now, I'll probably bumble ahead just to finish up and learn some things.

@IanTrudel
Copy link
Collaborator

It would ideally be implemented in Ruby/Shoes level for maximum extensibility but this approach has its challenges.

Regardless of the current flaws or original intents, I assure you this is a very desirable feature. Charting feature is surpringly difficult to find in any language.

@ccoupe
Copy link
Author

ccoupe commented Nov 4, 2016

It would ideally be implemented in Ruby/Shoes level for maximum extensibility but this approach has its challenges.

#266 + gruff for a template. Maybe we can talk @passenger94 into implementing the text_shape.He know more about that place inside Shoe than I.

Regardless of the current flaws or original intents, I assure you this is a very desirable feature. Charting feature is surpringly difficult to find in any language.

I also observed that empty spot in the OSS desktop universe. It's why I'd like to get this feature 'good enough' for fun and exploration without getting too complex or detailed.

  @values1 = [80,        160,          145,     75,          80] # in k$
  @values2 = [180,        90,           95,     90,          90]
  @columns = [ ["Internet", 0, 250, "%4.0f k"], 
               ["Television", 0, 200],
               {label: "Radio", min: 0, max: 200, format: "%3.3f"},
               #["radio", 0, 200],
               ["Newspaper", 0, 200],
               ["Magazine", 0, 200]
             ]

...
       @grf = plot widget_width, widget_height, title: "Advertising", caption: 
          "Budget Spend" , font: "Helvetica", auto_grid: true,
          default: "skip", background: white, chart: "radar", column_settings: @columns
      end

Not completely awful. Extensible at the C level (sort of).

[updated sample on 2016-11-05]

@ccoupe
Copy link
Author

ccoupe commented Nov 6, 2016

Getting closer.
radar-3

There are many things to improve but basics are not awful.

ccoupe pushed a commit that referenced this issue Nov 6, 2016
* remove useless code or comments - (still more to do)
@IanTrudel
Copy link
Collaborator

Looking good!

ccoupe pushed a commit that referenced this issue Nov 8, 2016
* don't need radar_pole or radar_slice structures.
* axis and value are drawn in grey (70% black) - less ugly.
* draws text labels - imperfectly
@ccoupe
Copy link
Author

ccoupe commented Nov 8, 2016

Slightly more appealing. Incorrect label positions but improving.
radar-4

@IanTrudel
Copy link
Collaborator

Are measurement lines also implemented? It seems to go really well so far.

Good news is that features you have implemented lately, radar graph included, will allow me to port one of my prototypes on Shoes and implement a fully functional prototype. Thanks for your continuous efforts!

@ccoupe
Copy link
Author

ccoupe commented Nov 10, 2016

Many, many and more details need to be added. I assume measurement lines are the lines drawn round the axis connecting the xaxis labels. In the tiny chart above there is room for an outer ring connecting all 200 end points and say one 'ring' at 100' since the examples all start with 0 at the center point.

Remember, all five of the above axis can have different scales so you need value labels on each of those points which can make for a very busy chart. And of course, someone will want options to not do that or only draw two when the room for 10. Or maybe they just want little 'tick' marks instead of labels. Another API challenge! There really is no end to possible enhancements and feature creep to this and many others charts all of which are very difficult to (re)implement incrementally in C. (wouldn't be that much easier in Ruby)

If you can provide a screen shot of what you really need (and the test date), that would help.

@IanTrudel
Copy link
Collaborator

IanTrudel commented Nov 11, 2016

Statistics Feature for Humintell Products is how I use radar chart in general. This is how OpenOffice/LibreOffice generate basic radar charts.

You may notice the scale is in percent from 0% (center of the chart) to 100% (outward). The scale is the same for every item (7 universal emotions in this case). Each coloured line represent percentage obtained at a precise moment in time (pre-test score, practice score, post-test score). In this document, the pre-test never change once taken, practice is updated as practice goes, post-test is created once post-test in taken (and possibly updated if taken again).

In a nutshell, basic features are fully sufficient for most case scenarios. The extra features you are suggested are fine but as long as the basic ones are fully implemented, I can use your radar graphs.

Let me check if I could get some data for you... stay tunes.

@IanTrudel
Copy link
Collaborator

image

@ccoupe
Copy link
Author

ccoupe commented Nov 11, 2016

Thanks. I'll use that for a for another test case (gr7.rb). We can get pretty close today. South of your border, an number of people appear to need help handling their emotions after the recent election.

ccoupe pushed a commit that referenced this issue Nov 11, 2016
* much still needs to be done.
@ccoupe
Copy link
Author

ccoupe commented Nov 11, 2016

I do like other peoples tests. This one demonstrates just how much work remains.
radar-5

There is a Windows beta that (hopefully) can draw that if you get the Tests/plot/gr7.rb from github.

@IanTrudel
Copy link
Collaborator

Here is another alignment you might be interested in. Hopefully it inspires you.

image

@ccoupe
Copy link
Author

ccoupe commented Nov 17, 2016

Currently, you last example is close to what I'm attempting. I'm using the quad calculations from the pie chart where things look ok. One issue is that the first, top most Anger is quad 0, as is Contempt but they connect to the imaginary text box in different locations. I can special case that.

@ccoupe
Copy link
Author

ccoupe commented Nov 17, 2016

This one looks good enough (for Shoes)
radar-9

There are issues exposed with Test/lplot/gr6.rb which needs some quadrant hints for positioning inner labels.

@ccoupe ccoupe closed this as completed Nov 17, 2016
@ccoupe ccoupe reopened this Nov 17, 2016
@ccoupe ccoupe added this to the 3.3.2 milestone Nov 17, 2016
@ccoupe
Copy link
Author

ccoupe commented Nov 17, 2016

Tests/plot/gr6 requires multiple inner labels at the because not all things are scaled the the same. This is damn close to as much as I'm willing to do for Shoes 3.3.2 release.
radar-10

@IanTrudel
Copy link
Collaborator

Very good! Take note the space between anger and the radar graph vs space between joy/fear and the radar graph seems different on Test/lplot/gr6.rb. Most likely joy/fear are too close. Other than that, the rest seems on point.

@ccoupe
Copy link
Author

ccoupe commented Nov 18, 2016

Funny you should mention that. The code is

// TODO: user specified radius multipler
double radius = chart->radius * 1.15; // extend it to draw outside

I think it was set to 1.10 for the gr7 plot. So, another something: has to be added to the API. sigh.

@IanTrudel
Copy link
Collaborator

By the way, I also notice labels/data are drawn clockwise. It seems every engine draw counter-clockwise. What do you think?

ccoupe pushed a commit that referenced this issue Nov 18, 2016
* its a multiplier (default is 1.15) which is mostly OK for
  the tests we have.
* 1.20 is probably as high as one would try to use. You can go small
  like 0.5 too if you like them drawn inside. I don't but it's
  users choice.
@ccoupe
Copy link
Author

ccoupe commented Nov 18, 2016

labels/data are drawn clockwise

We've been here before - dueling conventions.
Oddly enough, I use the most common C idiom of for (i = 0; i < max; i++) instead of the error prone for (i= max; i > 1; i--) or is it for (i = max-1; i >=0; i--)?

What do you think?

I think I'll wait for someone else to cross that mine field and show me their C code.

@IanTrudel
Copy link
Collaborator

for (i = max-1; i >=0; i--) seems to be correct.

@IanTrudel
Copy link
Collaborator

What is label_radius ? It seems to mean label margin, as in the margin around the label, which would be consistent with other Shoes styling names.

@ccoupe
Copy link
Author

ccoupe commented Nov 18, 2016

Read the commit comment . It is not a margin (measured in pixels). It's subtle and debatable which is better - a radius* multiplier or a radius+margin. I'm fairly certain that people that need this tweaking of position can handle a multiplier. Using a margin would on depend their font choice size (a future feature it we keep digging deeper and deeper) Inconvenient. Drawing a larger chart size would require tweaking of label_radius to get them where wanted, Inconvenient.

Perhaps we can have both with a few extra days of work.. At the moment, I'd prefer to ship something soon, and find out if anyone cares enough to complain with practical usage.

ccoupe pushed a commit that referenced this issue Nov 18, 2016
@IanTrudel
Copy link
Collaborator

I did read the commit comment but it only made sense after you explain it here. Always some concern about future backward compatibility and naming convention but label_radius could do for now.

It should be noted that we should have a label_margin in the future that is actually independent of chart size as you mention larger chart means tweaking label_radius. It could be inconvenient if one simply maximize a window, Shoes code redrawing bigger but then also need to adjust label_radius.

At the moment, I'd prefer to ship something soon, and find out if anyone cares enough to complain with practical usage.

Agreed.

@ccoupe
Copy link
Author

ccoupe commented Nov 19, 2016

Updated the wiki. Getting everything into the manual will be challenge.

@IanTrudel
Copy link
Collaborator

Updated the wiki.

The wiki page is very good.

Getting everything into the manual will be challenge.

Maybe someday #213 will see the day of light and we can use markdown directly, where wiki and manual will be totally compatible. 🍔

@ccoupe
Copy link
Author

ccoupe commented Nov 20, 2016

Considering, #293, it would be nice if we did have the e-book thing. We can get more a modern mingw for Windows so we can get better full_text gem, if we give up RubyInstaller /devkit compatibility. RubyInstaller is a pretty low key project.

We've got to face Ruby 2.3 and ruby 2.4 changes at the C level and the relentless march of updated dependent libraries. Probably Shoes 3.3.3.

@IanTrudel
Copy link
Collaborator

IanTrudel commented Nov 20, 2016

Considering, #293, it would be nice if we did have the e-book thing.

I've been busy and no free time to work on this. It's actually not overly difficult. Though some concerns about the Picky: it is working well but not actively maintained. One of the many problems with so many API these days, isn't it?

We can get more a modern mingw for Windows so we can get better full_text gem, if we give up RubyInstaller /devkit compatibility. RubyInstaller is a pretty low key project.

My understanding is that RubyInstaller has alternatives as far as using Ruby goes but it is the only one to provide a fully working devkit on Windows. It would come to sense that if we would not rely on RubyInstaller Devkit, we come with a solution that can survive us, ensuring Shoes future (or at least easy for anyone to pick up where Shoes will be left off).

If you feel strongly against RubyInstaller, open an issue and let's talk about pros, cons, and potential solutions.

@ccoupe
Copy link
Author

ccoupe commented Nov 21, 2016

Actually, there is an earlier about Rubyinstaller, #281.

@dredknight
Copy link
Contributor

dredknight commented Nov 27, 2016

Here is a fun custom chart that I did by using progress bar. Is there a way to make progress bar go vertical instead of horizontal?

Shoes.app do

	def bar bar, dif
		anim=every(0.025) do |count|
			bar.fraction=count*(dif/(20-(15-0.75*count)))
			count == 20 ? anim.stop : nil
		end
	end
	
	flow width: 30, height: 200 do
		subtitle "Y", top: 90
	end
	for i in 0..9 do
		bar ( progress left: 30, top: 20+20*i, width: 150, height: 5 ), (rand(100).to_f/100)
	end
	stack top: 200, left: 0, width: 200 do
		subtitle "X", align: "center"
	end
end

@passenger94
Copy link
Contributor

Yes !! Cool !!
No vertical progress bar that i'm aware of but you can probably create some funky ones from scratch with shapes for example

@IanTrudel
Copy link
Collaborator

@dredknight very nice sample!

What do you need vertical progress bar for? If you feel strongly about it, open a new issue with a detailed description and tag it with enhancement. Otherwise you may give a try to @passenger94 's idea. Shouldn't be too hard - it's a box in a box. :)))

@dredknight
Copy link
Contributor

Thanks @backorder and @passenger94 ! I was just messing with it nothing too special for the moment.
I will definitely check the forms sometimes.

@ccoupe
Copy link
Author

ccoupe commented Jan 21, 2017

Closed in Shoes 3.3.2

@ccoupe ccoupe closed this as completed Jan 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants