I have a content type with the following date fields:

  1. Start Date
  2. Deadline Date
  3. End Date

Deadline date is programmatically calculated, where as Start and End are based on user input.

There is a page with a table view for open nodes, ones without an End Date. In it, I would like to have a graphical representation of nodes alongside a graphical representation of time left from now until End Date.

I made a chart block view with serials as labels and dates as data, but the only result I got was a flat line with 0. Then tried every format combination listed under the date field without any luck. Although that, post date as a field seems to return correct results(?).

For a specific node Devel listed the following:

created (String, 10 characters ) 1451882207

field_end_date (Array, 1 element)
    und (Array, 1 element)
        0 (Array, 4 elements)
            value (String, 19 characters ) 2016-10-27 00:00:00
            timezone (String, 11 characters ) Asia/Riyadh
            timezone_db (String, 11 characters ) Asia/Riyadh
            date_type (String, 8 characters ) datetime

Creating timestamp fields gave the same flat line. So, I am unsure about what the exact issue is. Help would be appreciated on how to reach the desired outcome or about how to debug this if it is not a feature.

I'm using Charts version 7.x-2.x-dev.

2 Answers 2


I found a partial workaround for this by using hook_views_pre_render.

function hook_views_pre_render(&$view) {
   if($view->name == 'stuff'){
      $results = &$view->result;
      foreach ($results as $key => $result) {
      $now = time();
      $end = strtotime($result->field_field__end_date_[0]['raw']['value']);
      $daysuntil = date("j", $end-$now);
      $result->field_field_end_date[0]['rendered']['#markup'] = $daysuntil;

The previous function is for a chart that displays node serials as x-axis labels and number of days for yaxis, which is calculated as the difference between now and a end date.


Within the Charts module, there is an interesting "feature request" (not "bug" ...) about Graph node input over time (support date formatting on a continuous axis).

In Comment #3 of that issue is stated: 'The trouble here is that neither Views nor Date modules provide aggregation options for date-based fields.'.

Have a look at this issue, which I believe is similar to what you're asking here. Maybe also the patch(es) included in this issue.

Disclosure: I'm a co-maintainer of this module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.