Comments

mikl’s picture

Status: Active » Needs work

It could be awesome if we had Views styles for gRaphaël, but making this would be no small task. If anyone is willing to take this one, please be my guest :)

amitaibu’s picture

I guess it should be easier with #797364: Drupal theme function API and jQuery bindings for gRaphael in place. One can also already create a theme override and pass the values into theme('raphael'...).

jgraham’s picture

We are currently taking a look at writing this integration.

I'm thinking building the chart based on the the existing labeling ui this way the chart can pull in necessary information relative to field labels and build the chart accordingly.

There would be display options to choose the chart type initially targetting, pie, bar and line.

Initial supported features would be; legend, labels, and links.

We will be posting code shortly once it is in a better place to collaborate.

mikl’s picture

#3/jgraham: That sounds awesome. I seem to have found a weakness, though, into the current theme('graphael' implementation, namely that it assumes only one pair of coordinates (which is true for bar charts, but not for line). This probably needs to be rectified before the views integration goes ahead.

I’m most inclined to add another parameter to the theme function, although that would break the existing API. Any opinions?

R.J. Steinert’s picture

Hi all, I ran across this module as I'm about to dive in and try to get the Flot module to display data correctly with time on the y axis http://drupal.org/node/843748#comment-3228460.

You could take the structure of the Flot module's Views integration as a starting point. Then you would only need to worry about refactoring some of the data output to make gRaphael happy.

jasonh’s picture

Also, it may make sense to plug into the work w/ Charts and Graphs (http://drupal.org/project/charts_graphs) and tie in gRaphael as an additional plug in.

But hey really, Views integration will be fantastic in any flavor, mega advance kudos to the first one to the top of the hill.

jgraham’s picture

#4/miki: Yeah there seem to be some assumptions about the incoming data in the current jquery bindings. Pie = 1 set of coordinates, Bar = 1 to many sets of coordinates, Line/Scatter = 1 to many sets of *pairs* of data.

I don't think another parameter is necessary as with the combination of chart type and the incoming data it should be possible to know how to interpret the data.

  • pie: incoming data is a single array of values
  • bar: incoming data is one or more array(s) of values
  • line/scatter: incoming data is one or more array(s) of paired data

Sounds like that should be opened up as a separate issue.

jgraham’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
FileSize
28.18 KB
24.05 KB
18.5 KB
17.67 KB
9.24 KB

Attached is a patch against raphael-HEAD that adds views integration against views 3.x-dev. Which defines "graphael chart" as a views plugin style.

Attached are a couple screenshots of the config too.

Known Issues:
- The x column should not be displayed when either pie or bar is selected. This is a problem as the x data is ignored on pie and bar, and only pertinent for line chart but there is the auto-x feature which conditionally displays the x-column when chart type is line and auto-x is unselected.
- dot/scatter chart type is not implemented.
- multi-value fields are ignored only the first value is taken

I think this is a solid proof of concept and framework to move some of the discussion forward. Remaining issues I see to solve are;

  1. How or if we should handle handle multi-valued CCK fields. This seems like there should be an option to "interpret rows as series" or "interpret columns as series" this would transpose how the data arrays are built. Right now rows are data.
  2. reworking some of the jquery bindings/options to support proper multi-series data

This is a rough patch, and as discussed above could be further improved with work relative to adding support for multiple series data.
Keep in mind the testing has been very minimal on this.

I'm willing to work to refine this patch and get it merged into the raphael/graphael project. I'm also open to helping rework the jquery bindings to be a bit more flexible.

Let's figure out where this should be headed and get it there.

batje’s picture

great work. i'd still opt for #6 though. if not only for the amount of exposure to new users.

jgraham’s picture

I understand the want to integrate with charts and graphs, but IMO what really sets graphael apart is the inclusion of clickable chart elements with hover effects.

It seems that charts and graphs is lacking support these features. Am I missing something?

Also, I think the views integration posted above needs a complete rework. While it works, it could be a whole lot better.

mikl’s picture

Sorry for not following up on this earlier, but I have been rather busy with DrupalCon, since I’m part of the local CPH team. I will be doing a presentation on gRaphaël, and as part of my work on preparing a session, I will be rolling another beta-release of the code.

As for this patch, I’m definitely in favour of having Views integration directly in this module instead of having to go through another module. I am not fond of long dependency chains. When DrupalCon is over, I will have some more time to take a look at it and see how/if it can be merged. Thanks :)

Wim Leers’s picture

Subscribing! :)

youkho’s picture

Subscribe

DanilaD’s picture

Subscribing

4v4l0n42’s picture

Subscribing.

jpstrikesback’s picture

subscribe

jgraham’s picture

I hope the presentation went well. I'm willing to work with you on a rework/rewrite of the above patch. I've been thinking about it a bit more and while it *works* it does need considerable improvement. Let me know what you're thinking and if/where I can help out.

There is also the update of the API to allow for the full set of parameters of Raphaël/gRaphaël I say branch to 2.0 and break away. ;-)

Thanks for the awesome work!

dawehner’s picture

Just a small comment: Everything you want to store as options has to be defined with option_definition. If it's not there it will not be stored.

btopro’s picture

subscribe

googletorp’s picture

#8/jgraham: I muched your patch a bit to make it work to the current head and tried to improve it a bit. I haven't done views integration before so it was fun trying some different things out. I managed to make it possible to use multiple series for bar charts. There's still some work that needs to be done, to make this ready for commit, but I thought you might want to take a look and help bring it there.

dawehner’s picture

+  function options(&$options) {
+    $options['chart_type'] = 'pie';
+  }
+

This should be option_definition, see views for thousands of examples how to use it.

jedihe’s picture

Issue tags: +views, +views3
FileSize
9.6 KB

Had quite a hard time trying to apply these patches against HEAD... to later find out that the one by googletorp (#20) has no problem to apply against 1.0-beta3.

I also decided to play around and improved it just a bit:

  • Changed options() into option_definition(), as suggested by dereine.
  • Added new conditional parameter: type of bar.
  • Left a few notes around for some options that were quite hard for me to figure out how to control from the plugin.

Just my two cents. Remember it's against 1.0-beta3; if I find time later I will try to get it applying against HEAD.

jedihe’s picture

Component: Drupal API » Miscellaneous
Issue tags: -VIEWS2
FileSize
3.93 KB
5.77 KB

A couple screenshots can be helpful, I think :)

BTW, does anyone know if it's possible to put labels on the base of each bar? (I'm needing that for the project that I checked this for).


Grienauer’s picture

subscribe

thijsvdanker’s picture

subscribing

adraskoy’s picture

subscribing

mikl’s picture

Component: Miscellaneous » Drupal API

Okay, given that I've just pushed out 6.x-1.0-RC1 to serve as basis for the Drupal 7 port, I am going to postpone this to the 6.x-1.1 release (given that someone is willing to put in the work to get it done).

jedihe’s picture

FileSize
3.93 KB

I refactored the code into a separate module, for use with Views 2.

Almost for sure there are many things that can be cleaned-up or improved, but I think having it separated from the main module is a good idea.

R.J. Steinert’s picture

Issue tags: -views3 +VIEWS2

@jedihe - I'm trying to graph numeric values over time. I just tested out your views_graphael module and was not able to get it to work. Is there support for unix timestamps? I had to do a few tricks to get timestamps to work with the Flot Timemode Views module https://github.com/rj-steinert/flot-timemode-views

jedihe’s picture

Issue tags: +views3

@rjstatic: AFAIK, there is no support for timestamps for the X axis of graphs.

I'm restoring the tags to have both views2 and views3, since there are parts of the conversation related to each.

acrollet’s picture

subscribe

k3n3dy’s picture

Hi!
First of all, congratulations for the original module and the views support module. Great piece of work.

I have just discovered Raphael and views_graphael, so please don't take me wrong if my questions are too basic. I could not find much documentation to help get started with gRaphael/Drupal, however it wasn't too difficult to start and get good results.

I can generate the charts I need from my data, but there is something wrong when I have more than 10 bars in the graph. Only the first 10 bars have colors, all the others are shown in white against white background. The bars are there, since when I roll the mouse over the text appears.

Could anyone point me to the direction to have this fixed? I don't know if this is a configuration problem, views_graphael problem, or raphael problem.

Many thanks in advance.

m3n0R’s picture

You should get an array of colors of the same length of your data. I usually do that using a function. Here you are:

$pie_colors = array_slice (getColours(),0,count($data));

//you can put more colors if you want
function getColours() {
return array(
'#5BC7D6',
'#FFF9CC',
'#2E3634',
'#B5A436',
'#F2E66E',
'#E85C93',
'#F5986A',
'#FFF59C',
'#8A9485',
'#52C4B2',
'#38555E',
'#50705C',
'#878553',
'#878553',
'#FFBC16'
);
}

k3n3dy’s picture

That's fantastic.
Thanks for the prompt reply.

I'm still trying to get how Raphael works so, using it by this Drupal module how/where do I put this code? Do I have to write a small custom module to have this function? Will this function use any hook?

Thanks a lot in advance.

m3n0R’s picture

I use views and i get the results on a template!

Then, use the functions and prints in the template

k3n3dy’s picture

Got it. I will try this path.

Thanks!

silkogelman’s picture

@jasonh / #6 (at this point in time) maybe even more to integrate with http://drupal.org/project/charts
It has D7, Views integration, API and a nice data schema so people can switch easily between chart providers.

fabianderijk’s picture

subscribing

Grayside’s picture

I second Charts (or Charts and Graphs, whichever is going forward) integration. It might not do everything graphael can do, but my sense is that libraries like raphael are the way of the future, which means any gaps are really feature requests for Charts, not deal breaking functionality.

Sinan Erdem’s picture

Any chance of Drupal 7 views integration soon?

mikl’s picture

#40: As also pointed out in comment #27, this feature will only be done if someone volunteers to do it. I have no interest in it myself.