Hi,
The quiz statistics gives us the graph which displays the results in the form of range i.e. 0-20%, 20-40% in 'X' axis. The image attached describes my requirement, I'm trying to achieve the same functionality for a custom view which displays statistics where the 'year' is on 'X' axis and some valid value on the 'Y' axis. I am trying to get the values for 'year' to display in ranges i.e. 2001-2002.

Can anyone help achieving the above functionality?

CommentFileSizeAuthor
Range graph.png13.15 KBshwethash
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pierre.Vriens’s picture

Did you ever find the answer / solution for this issue? If not please review the (new) documentation about Steps to create charts using the views UI, which includes this "Bonus tip": You may find it easier to start with a "Table" display and convert it to a chart display after setting up the data. It can be easier to visualize what the result of the chart will be if it's been laid out in a table first..

Please get back with a status update on this issue, OK?

Pierre.Vriens’s picture

Status: Active » Postponed (maintainer needs more info)
shwethash’s picture

Hi,
As i have shown in the uploaded picture, I may wish to add ranges to the graphs like 0-20%. 20-40% and so on...just like the quiz statistics module displays, but how to acheive it through a custom view?

Pierre.Vriens’s picture

Title: How to get the score distribution in the chart in percentages » How to show X-axis values using year ranges like 2001-2002?
Component: Chart API » Views integration

Hi Shwetha, thanks for this extra info you provided. It helps to already get some meta-data about this issue corrected (as I do now), i.e. that this question is about the Views integration (not the Charts API).

But with the extra info in #3, I still don't have enough information about what you WANT to do (not just "may wish" I assume). After you answer these additional questions I might be able to actually find the real answer your are looking for:

  1. I'm confused by the title of the issue. Based on how I seem to understand your question so far, I believe a better description would be like "How to show X-axis values using year ranges like 2001-2002?" (your custom chart is not about percentages but years I believe ...). I'm going to adapt the title of this issue already like so. If that's NOT what the real question is, please further correct the title.
  2. It would help me if you can (and are willing to) share the relevant code to produce the view (containing the chart). In this case, an EXPORT of your 'custom view'. To do so, just paste it in a comment, surrounded by the PHP-code tag, using the PHP editor icon.
  3. You mentioned "quiz statistics": do you mean the Quiz Stats submodule of the quiz module? If not, please post a link to the module you are referring to. If my guess is correct, please checkout bullet 1 within Modules facilitating charting via the Charts module. After doing so, browse the patch attached to #2278695-1: Convert scores chart to "charts". Just a wild guess: could it be that the answer to your question is included in some of the lines added via that patch?
shwethash’s picture

Hi,
Sorry for entering the wrong title, I have added all the information below.

shwethash’s picture

Hi,
1) The title seems to be fine now.

2) Here is my php code i.e. the export of my custom view.

$view = new view();
$view->name = 'my_stats';
$view->description = 'Statistics Reports for the list of students based on the QP ID';
$view->tag = 'default';
$view->base_table = 'quiz_node_results';
$view->human_name = 'My stats';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Statistics Report';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['group_by'] = TRUE;
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
  2 => '2',
);
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Submit';
$handler->display->display_options['exposed_form']['options']['reset_button'] = TRUE;
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Reset Filter';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'chart';
$handler->display->display_options['style_options']['type'] = 'column';
$handler->display->display_options['style_options']['library'] = 'highcharts';
$handler->display->display_options['style_options']['label_field'] = 'field_student_degre_year_of_pass';
$handler->display->display_options['style_options']['data_fields'] = array(
  'nid' => 'nid',
  'field_student_degre_year_of_pass' => 0,
  'title' => 0,
);
$handler->display->display_options['style_options']['field_colors'] = array(
  'field_student_degre_year_of_pass' => '#2f7ed8',
  'nid' => '#0d233a',
  'title' => '#8bbc21',
);
$handler->display->display_options['style_options']['width'] = '';
$handler->display->display_options['style_options']['height'] = '';
$handler->display->display_options['style_options']['xaxis_title'] = 'Year of Passout';
$handler->display->display_options['style_options']['xaxis_labels_rotation'] = '0';
$handler->display->display_options['style_options']['yaxis_title'] = 'Number of Students';
$handler->display->display_options['style_options']['yaxis_labels_rotation'] = '0';
/* Header: Global: Text area */
$handler->display->display_options['header']['area']['id'] = 'area';
$handler->display->display_options['header']['area']['table'] = 'views';
$handler->display->display_options['header']['area']['field'] = 'area';
$handler->display->display_options['header']['area']['content'] = '<h1>Based on Year of Passout</h1>
<h2>Note: If this "question paper" assigned to the multiple college, filter the statistics based on college name .</h2>';
$handler->display->display_options['header']['area']['format'] = 'full_html';
/* Relationship: Quiz result: Uid */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'quiz_node_results';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Relationship: User: Profile */
$handler->display->display_options['relationships']['profile']['id'] = 'profile';
$handler->display->display_options['relationships']['profile']['table'] = 'users';
$handler->display->display_options['relationships']['profile']['field'] = 'profile';
$handler->display->display_options['relationships']['profile']['relationship'] = 'uid';
$handler->display->display_options['relationships']['profile']['bundle_types'] = array(
  'student_registration_form' => 'student_registration_form',
);
/* Field: Profile: Degree Year of Pass Out */
$handler->display->display_options['fields']['field_student_degre_year_of_pass']['id'] = 'field_student_degre_year_of_pass';
$handler->display->display_options['fields']['field_student_degre_year_of_pass']['table'] = 'field_data_field_student_degre_year_of_pass';
$handler->display->display_options['fields']['field_student_degre_year_of_pass']['field'] = 'field_student_degre_year_of_pass';
$handler->display->display_options['fields']['field_student_degre_year_of_pass']['relationship'] = 'profile';
/* Field: COUNT(Quiz result: Nid) */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'quiz_node_results';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['group_type'] = 'count';
$handler->display->display_options['fields']['nid']['label'] = 'Number of Students';
$handler->display->display_options['fields']['nid']['separator'] = '';
/* Contextual filter: Quiz result: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'quiz_node_results';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Profile: Degree College Name (field_student_college_name) */
$handler->display->display_options['filters']['field_student_college_name_tid']['id'] = 'field_student_college_name_tid';
$handler->display->display_options['filters']['field_student_college_name_tid']['table'] = 'field_data_field_student_college_name';
$handler->display->display_options['filters']['field_student_college_name_tid']['field'] = 'field_student_college_name_tid';
$handler->display->display_options['filters']['field_student_college_name_tid']['relationship'] = 'profile';
$handler->display->display_options['filters']['field_student_college_name_tid']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_student_college_name_tid']['expose']['operator_id'] = 'field_student_college_name_tid_op';
$handler->display->display_options['filters']['field_student_college_name_tid']['expose']['label'] = 'Degree College Name';
$handler->display->display_options['filters']['field_student_college_name_tid']['expose']['operator'] = 'field_student_college_name_tid_op';
$handler->display->display_options['filters']['field_student_college_name_tid']['expose']['identifier'] = 'field_student_college_name_tid';
$handler->display->display_options['filters']['field_student_college_name_tid']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
  5 => 0,
  6 => 0,
  7 => 0,
);
$handler->display->display_options['filters']['field_student_college_name_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_student_college_name_tid']['vocabulary'] = 'add_colleges';
$handler->display->display_options['filters']['field_student_college_name_tid']['hierarchy'] = 1;
/* Filter criterion: Profile: Degree Year of Pass Out (field_student_degre_year_of_pass) */
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['id'] = 'field_student_degre_year_of_pass_value';
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['table'] = 'field_data_field_student_degre_year_of_pass';
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['field'] = 'field_student_degre_year_of_pass_value';
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['relationship'] = 'profile';
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['expose']['operator_id'] = 'field_student_degre_year_of_pass_value_op';
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['expose']['label'] = 'Degree Year of Pass Out';
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['expose']['operator'] = 'field_student_degre_year_of_pass_value_op';
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['expose']['identifier'] = 'field_student_degre_year_of_pass_value';
$handler->display->display_options['filters']['field_student_degre_year_of_pass_value']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
  5 => 0,
  6 => 0,
  7 => 0,
);
/* Filter criterion: Profile: Gender (field_student_gender) */
$handler->display->display_options['filters']['field_student_gender_value']['id'] = 'field_student_gender_value';
$handler->display->display_options['filters']['field_student_gender_value']['table'] = 'field_data_field_student_gender';
$handler->display->display_options['filters']['field_student_gender_value']['field'] = 'field_student_gender_value';
$handler->display->display_options['filters']['field_student_gender_value']['relationship'] = 'profile';
$handler->display->display_options['filters']['field_student_gender_value']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_student_gender_value']['expose']['operator_id'] = 'field_student_gender_value_op';
$handler->display->display_options['filters']['field_student_gender_value']['expose']['label'] = 'Gender';
$handler->display->display_options['filters']['field_student_gender_value']['expose']['operator'] = 'field_student_gender_value_op';
$handler->display->display_options['filters']['field_student_gender_value']['expose']['identifier'] = 'field_student_gender_value';
$handler->display->display_options['filters']['field_student_gender_value']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
  5 => 0,
  6 => 0,
  7 => 0,
);
/* Filter criterion: Profile: Degree (field_student_degree) */
$handler->display->display_options['filters']['field_student_degree_value']['id'] = 'field_student_degree_value';
$handler->display->display_options['filters']['field_student_degree_value']['table'] = 'field_data_field_student_degree';
$handler->display->display_options['filters']['field_student_degree_value']['field'] = 'field_student_degree_value';
$handler->display->display_options['filters']['field_student_degree_value']['relationship'] = 'profile';
$handler->display->display_options['filters']['field_student_degree_value']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_student_degree_value']['expose']['operator_id'] = 'field_student_degree_value_op';
$handler->display->display_options['filters']['field_student_degree_value']['expose']['label'] = 'Degree';
$handler->display->display_options['filters']['field_student_degree_value']['expose']['operator'] = 'field_student_degree_value_op';
$handler->display->display_options['filters']['field_student_degree_value']['expose']['identifier'] = 'field_student_degree_value';
$handler->display->display_options['filters']['field_student_degree_value']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
  5 => 0,
  6 => 0,
  7 => 0,
);
/* Filter criterion: Quiz result: Score */
$handler->display->display_options['filters']['score']['id'] = 'score';
$handler->display->display_options['filters']['score']['table'] = 'quiz_node_results';
$handler->display->display_options['filters']['score']['field'] = 'score';
$handler->display->display_options['filters']['score']['operator'] = 'between';
$handler->display->display_options['filters']['score']['value']['min'] = '0';
$handler->display->display_options['filters']['score']['value']['max'] = '100';
$handler->display->display_options['filters']['score']['exposed'] = TRUE;
$handler->display->display_options['filters']['score']['expose']['operator_id'] = 'score_op';
$handler->display->display_options['filters']['score']['expose']['label'] = 'Score';
$handler->display->display_options['filters']['score']['expose']['operator'] = 'score_op';
$handler->display->display_options['filters']['score']['expose']['identifier'] = 'score';
$handler->display->display_options['filters']['score']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
  5 => 0,
  6 => 0,
  7 => 0,
);
/* Filter criterion: User: Roles */
$handler->display->display_options['filters']['rid']['id'] = 'rid';
$handler->display->display_options['filters']['rid']['table'] = 'users_roles';
$handler->display->display_options['filters']['rid']['field'] = 'rid';
$handler->display->display_options['filters']['rid']['relationship'] = 'uid';
$handler->display->display_options['filters']['rid']['value'] = array(
  4 => '4',
);

/* Display: Year of Passout */
$handler = $view->new_display('page', 'Year of Passout', 'page');
$handler->display->display_options['defaults']['header'] = FALSE;
/* Header: Global: Text area */
$handler->display->display_options['header']['area']['id'] = 'area';
$handler->display->display_options['header']['area']['table'] = 'views';
$handler->display->display_options['header']['area']['field'] = 'area';
$handler->display->display_options['header']['area']['content'] = '<h1>Question Paper: <span class="change">[title]</span></h1>
<h2>Note: If this "question paper" is assigned to multiple colleges, filter the statistics based on college name .</h2>

';
$handler->display->display_options['header']['area']['format'] = 'full_html';
$handler->display->display_options['header']['area']['tokenize'] = TRUE;
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: Quiz result: Uid */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'quiz_node_results';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Relationship: User: Profile */
$handler->display->display_options['relationships']['profile']['id'] = 'profile';
$handler->display->display_options['relationships']['profile']['table'] = 'users';
$handler->display->display_options['relationships']['profile']['field'] = 'profile';
$handler->display->display_options['relationships']['profile']['relationship'] = 'uid';
$handler->display->display_options['relationships']['profile']['bundle_types'] = array(
  'student_registration_form' => 'student_registration_form',
);
/* Relationship: User: Quiz result */
$handler->display->display_options['relationships']['quiz_node_results']['id'] = 'quiz_node_results';
$handler->display->display_options['relationships']['quiz_node_results']['table'] = 'users';
$handler->display->display_options['relationships']['quiz_node_results']['field'] = 'quiz_node_results';
$handler->display->display_options['relationships']['quiz_node_results']['relationship'] = 'uid';
/* Relationship: Quiz result: Nid */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'quiz_node_results';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Profile: Degree Year of Pass Out */
$handler->display->display_options['fields']['field_student_degre_year_of_pass']['id'] = 'field_student_degre_year_of_pass';
$handler->display->display_options['fields']['field_student_degre_year_of_pass']['table'] = 'field_data_field_student_degre_year_of_pass';
$handler->display->display_options['fields']['field_student_degre_year_of_pass']['field'] = 'field_student_degre_year_of_pass';
$handler->display->display_options['fields']['field_student_degre_year_of_pass']['relationship'] = 'profile';
/* Field: COUNT(Quiz result: Nid) */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'quiz_node_results';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['group_type'] = 'count';
$handler->display->display_options['fields']['nid']['label'] = 'Number of Students';
$handler->display->display_options['fields']['nid']['separator'] = '';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['relationship'] = 'nid';
$handler->display->display_options['fields']['title']['exclude'] = TRUE;
$handler->display->display_options['fields']['title']['link_to_node'] = FALSE;
$handler->display->display_options['path'] = 'mystats/%';

3) Yes, I did mean the Quiz Stats submodule of the quiz module. I am refering the same module. It displays the ranges in 'X' axis as shown in the image uploaded in my previous comments, I would like to implement the same in my custom view.

Thank you.

Pierre.Vriens’s picture

Hi Shwetha, thanks for the extra info, and the exported view. We're getting closer, but I still cannot solve your request.

Here are additional questions for you:

  1. Because of what I saw in the patch I referred to in #4, and because of what I see as labels, etc in the original image you posted, I wonder which version of the quiz module module (and hence its related Quiz Stats submodule) you used to produce that image. Can you post a link (or exact release ID) of your quiz module please? After you do so, I would want to use it for (a) checking if it's done using the chart or charts module and (b) if it is charts (already), then I want to investigate how the coding looks like for the chart that created the original chart as you mentioned in this issue. If that doesn't solve your question, then I suggest we continue with the next step as in my next bullet in this comment.
  2. In the exported view in bullet 2. in #6, I see that your view ONLY includes 1 line containing ... ['style_plugin'] = .... And the value of it is 'chart';. That implies to me that you should first try the "bonus tip" as mentioned in #1, i.e. (temporary) add another 'Table' display of the view. Doing so will help us narrow down your question to creating that table with some headers in that table that will become the labels of your chart later on. In doing so, I'm wondering if you should use something like rewrite results or something similar.
shwethash’s picture

Hi,
I have provided the details of my quiz module

Information added by Drupal.org packaging script on 2014-09-11
version = "7.x-5.0-alpha3+2-dev"
core = "7.x"
project = "quiz"
datestamp = "1410446360"

The range graph comes from the core 'quiz stats' module.

Pierre.Vriens’s picture

Hi Swetha (again),

I think in your last comment it should say " ... here are the details ..." instead of "... I have provided the details ...". Because I cannot find any such details in any prior comment in this issue (or am I missing something?).

Anyway, why are you still using an "alfa3" version of that module, which is from about 6 months ago? Is it possible for you to upgrade to the alfa9 version of that module, and then verify if this issue here is still unresolved? After you upgraded that module and confirmed that the issue here is still unresolved, I'd be happy to try to get it moving forward as suggested in my prior comment. However I hope you understand "I" consider it as a waste of time (for me) to go digging in an outdated alfa version of some other module ...

Regards, Pierre

PS: What about bullet "2." in my previous comment? Any progress on that (cfr the 'Bonus Tip')?

shwethash’s picture

Hi,
Thank you for correcting the statements, I will update my quiz and try adding the chart display and see if it works.

andileco’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)