I can't seem to spot if this is currently supported or how to implement it if it is. The attributes I'm referring to can be seen here. An example of this in the xml data would be as follows: -

<value xid="29">1979</value>
<value xid="30" event_start="war" event_text_color="#DADADA" event_description="Iran-Iraq war was a war between the armed forces of Iraq and Iran lasting from September 1980 to August 1988. " event_color="#000000" event_alpha="15">1980</value>
<value xid="31">1981</value>

Does charts and graphs currently support passing these attributes in and if so, could you please point me towards how to accomplish it?

Many thanks in advance.

Comments

hish’s picture

also I am using amChart and I wont to render a graph like this
I mean columns and lines it is support with chart and graph module
@ethiaa it is work with you ?

Thanks

ethiaa’s picture

After sifting through the charts and graphs code, it looks unsupported at present so I'm just doing my own amCharts implementation instead.

rsevero’s picture

Charts and Graphs already has support for arbitrary options since version 6.x-2.0-beta1. Please take a look at the "Arbitrary settings" sections in each charting library Advanced Help page for details.

hish’s picture

@rsevero can you provide me an example how to use chart_series and chart_graph variable in the amchart module
I wont to display 2 graph inside one canvas bar and line .

for example
the columns display the monthly income and outcome
and the line display the differences between income and outcome .

can I do it using chart_series and chart_graph variable ?

Many Thanks

ethiaa’s picture

The arbitrary settings are great but don't allow you to influence the data attributes which was why I posted the support request in the first place. Through digging at amCharts, it appears you can however put the data itself into the settings string in amCharts which in theory would allow you to implement the event_* attributes. It's rather long winded to do that way however. All in all, I found it quicker just to write my own amCharts handler which passed the data in the way I wanted it.

rsevero’s picture

Aren't you interested in producing a patch to implement event attributes support for Charts and Graphs?

hish’s picture

I read at the amChart documentation and I find we can define the types of chart at the settings file
depend on the chart id .
for example I have 3 series of data something like this

<?php
  $canvas->series       = array( 'one'     => array(9, 8, 7, 9, 7, 7, 6, 8, 7, 9, 8, 7.5, 9.8),
                                             'two'     => array(6, 7, 9, 5, 7, 6, 9, 7, 3, 2.5, 5, 15),
                                             'three'  => array(9, 1, 15, 4, 5, 9, 12, 2.9, 9, 11, 11.8, 1.5),
  ); 
?>

one and tow represented as column three as line, but when instantiate a new object of class charts_graphs_amcharts you can set only one type so the three series appear as column .
so I write a simple patch for the charts_graphs_amcharts class that give the chart id in the data file .
and then you can send the chart type and other settings using arbitrary settings .
and this is a full example using arbitrary settings .

<?php
  $canvas               = charts_graphs_get_graph('amcharts'); 
  $canvas->title     = "AmCharts Chart";
  $canvas->type    = "bar";
  $canvas->y_legend  = "Test Y Legend";
  $canvas->colour     = '#ffffff';
  $canvas->series     = array( 'Some Value'   => array(9, 8, 7, 9, 7, 7, 6, 8, 7, 9, 8, 7.5, 9.8),
                                           'Page Views'    => array(6, 7, 9, 5, 7, 6, 9, 7, 3, 2.5, 5, 15),
                                            'New Value'     => array(5, 1, 15, 4, 5, 9, 12, 2.9, 9, 11, 11.8, 1.5),
  ); 
  $canvas->width    = 800;
  $canvas->height   = 600;
  $canvas->x_labels = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve');

  $canvas->settings = array(
      array('#id'       => 'column',
            '#children' => array(
                 array('#id'  => 'sequenced_grow',   '#value' => 'true'),
                 array('#id'  => 'grow_time',  '#value' => 5),
                 array('#id'  => 'hover_brightness',  '#value' => -20),
                 array('#id'  => 'balloon_text', '#cdata' =>'{series}: {value}'), 
                 array('#id'  => 'border_color', '#value' =>'#999999'),
                 array('#id'  => 'border_alpha', '#value' =>3) 
            )
      ),
     
       array('#id'       => 'line',
            '#children' => array(
               array('#id'  => 'hover_brightness',  '#value' => -20),
               array('#id'  => 'bullet',  '#value' =>'round'),
               array('#id'  => 'balloon_text', '#cdata' =>'{series}: {value}') ,
               array('#id'  => 'connect', '#value' =>'true') ,
            )
      ),
     
       array('#id'       => 'balloon',
            '#children' => array(
               array('#id'  => 'alpha',  '#value' => 80),
               array('#id'  => 'text_color',  '#value' =>'#000000'),
               array('#id'  => 'corner_radius', '#value' => 5) ,
               array('#id'  => 'border_width', '#value' => 3) ,
               array('#id'  => 'border_alpha', '#value' => 50) ,
               array('#id'  => 'border_color', '#value' => '#000000') ,
            )
      ),

      array('#id'       => 'graphs',
            '#children' => array(
                 array('#id'         => 'graph',
                     '#attributes' => array('gid' => 0),
                     '#children'    => array(array('#id' => 'type', '#value'=>'line'), 
                                                        array('#id' => 'line_width', '#value'=>2), ) 
                 ),  
                 array('#id'         => 'graph',
                     '#attributes' => array('gid' => 1),
                     '#children'   => array(array('#id' => 'type', '#value'=>'column'),)
                 ),
                 array('#id'         => 'graph',
                     '#attributes' => array('gid' => 2),
                     '#children'   => array(array('#id' => 'type', '#value'=>'column'),)
                 ),
        
           )
      ),
                                                                                
  );  
  $out= $canvas->get_chart();
  print $out;
?>

see the screenshot and the patch

hish’s picture

yes after all this module really awesome thank you guys
but you can add more options, I can help if you interesting

Wisal-1’s picture

Hi, i am using amcharts (line) in my custom module, it works fine but now i want to display y-axis on both side (2 y-axis)......how to do this?......................Thanks

rsevero’s picture

Assigned: Unassigned » rsevero
Category: support » feature

hish solution implemented with http://drupalcode.org/project/charts_graphs.git/commit/7bdef4a

Thanks for the patch and sorry for the delay.

@hish: please send more ;)

kenorb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.