I was setting up some charts that call data from the database and some of the proportions were off. Right now there's a pie chart with 5 different metrics and one exceeded 1200 for the count and another has 200, they each show up as the same proportional slice on the chart. Is there some limit in the module I should change?

CommentFileSizeAuthor
#2 chart1.png33.92 KBfakeplastic

Comments

tjholowaychuk’s picture

Status: Active » Postponed (maintainer needs more info)

hmmm, that should not be happening, can you paste a print_r of the chart array, I will take a look and reference my code

fakeplastic’s picture

StatusFileSize
new33.92 KB

So I basically just went into the system_charts.module file and changed all the variables in the watchdog_counts chart to a generic report_counts as follows:


    case 'report_counts':                 
      $results = db_query("       
          SELECT COUNT(*) as count, field_reporttype_value 
          FROM {content_field_report} 
          GROUP BY field_reporttype_value 
          ORDER BY field_reporttype_value
        ");                     
        
      while ($result = db_fetch_array($results)){
        $chart['#data'][]        = $result['count'];
        $chart['#labels'][]      = $result['field_reporttype_value'] . ': ' . $result['count'];     
        $chart['#data_colors'][] = chart_unique_color($result['field_reporttype_value']);
      }  
       
      $chart['#chart_id'] = 'reporttype_counts';
      $chart['#title']    = chart_title(t('Report Breakdown'));
      $chart['#type']     = CHART_TYPE_PIE;
      $chart['#size']     = chart_size(840, 300);
      break;

The result is the attached image file (i blurred out the field names that are called), but essentially what happens is the one field that has 1779 appears proportional to the field that has 270 or 194. However I created a chart using the same code method and it comes up proportional but the values are much smaller.

tjholowaychuk’s picture

Interesting that is certainly odd, even the others seem to be very similar as well.

At the bottom of chart_build(); just above

Line 278: $charts[$chart['#chart_id']] = drupal_query_string_encode($data);

if you have devel installed just print out the data, remove anything confidential, just so I can see the numbers and try to figure out what is going on

dpm($data);
$charts[$chart['#chart_id']] = drupal_query_string_encode($data);
fakeplastic’s picture

Here's the array the dpm($data); gave for this specific chart:

Array
(
[chd] => t:194,223,17,270,432,252,1779
[cht] => p
[chs] => 840x300
[chtt] => Report Breakdown
[chts] => 000000,14
[chl] => instance 1: 194|instance 2: 223|instance 3: 17|instance 4: 270|instance 5: 432|instance 6: 252|instance 7: 1779
[chco] => ecf8ff,00ccff,4086AA,91C3DC,87907D,AAB6A2,555555
[chf] => bg,s,FFFFFF
)

Hope that helps.

tjholowaychuk’s picture

hmmm, I would almost try $chart['#adjust_resolution'] = TRUE; I cannot remember if I limited the resolution scaling to specific chart types or not, but it may work for pie charts as well.

fakeplastic’s picture

It worked! Thanks so much TJ.

tjholowaychuk’s picture

Status: Postponed (maintainer needs more info) » Fixed

Fewf! haha, good to hear :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.