Categories > OpenTBS with PPTX >

Embedded stacked bar in PPT

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: merav
Date: 2014-07-23
Time: 13:29

Embedded stacked bar in PPT

Hi,

I am trying to build a stacked bar in PPT and I am having some issues, hopefully someone here can help me.
I am reading the data from a database and then building the arrays.

I have 3 series and building the arrays as following:
    for ( $i = 0 ; $i < sizeof($analysis_name) ; $i++ ) {
        if ( $i == $num_of_progress ) {
            $ser_new[] = '"'.$analysis_name[$i].'"'.'=>'.$new_tasks[$i];
            $ser_open[] = '"'.$analysis_name[$i].'"'.'=>'.$open_tasks[$i];
            $ser_closed[] = '"'.$analysis_name[$i].'"'.'=>'.$closed_tasks[$i];
        } else {
            $ser_new[] = '"'.$analysis_name[$i].'"'.'=>'.$new_tasks[$i].',';
            $ser_open[] = '"'.$analysis_name[$i].'"'.'=>'.$open_tasks[$i].',';
            $ser_closed[] = '"'.$analysis_name[$i].'"'.'=>'.$closed_tasks[$i].',';
        }
    }

Then I use this code to build the report:
$TBS->PlugIn(OPENTBS_CHART, $ChartRef, 1, $ser_new, 'New Task');
$TBS->PlugIn(OPENTBS_CHART, $ChartRef, 2, $ser_open, 'Open Task');
$TBS->PlugIn(OPENTBS_CHART, $ChartRef, 3, $ser_closed, 'Closed Task');

When I run it like this it is not working (it replaces the actual slide in the presentation with a blank slide.

I then printed the content of the arrays that I am building and created 3 hard coded arrays with the data in the array:
$ser_new = array("28-Jun-13"=>4158,"29-Jul-13"=>4692,"15-Aug-13"=>4182,"15-Aug-13"=>2516);
$ser_open = array("28-Jun-13"=>0,"29-Jul-13"=>85,"15-Aug-13"=>116,"15-Aug-13"=>525);
$ser_closed = array("28-Jun-13"=>0,"29-Jul-13"=>237,"15-Aug-13"=>309,"15-Aug-13"=>1189);

When I send these arrays the graph is being build okay.

Any idea why when I build the  arrays dynamically it is not working?

Thanks for your help,
Merav
By: Skrol29
Date: 2014-07-23
Time: 15:51

Re: Embedded stacked bar in PPT

Hi,

This is PHP problem, you have much to learn about PHP arrays my young padawan.

You should replace
   $ser_new[] = '"'.$analysis_name[$i].'"'.'=>'.$new_tasks[$i];
with :
   $ser_new[$analysis_name[$i]] = $new_tasks[$i];


The first line will add an new item with a numerical key and the value is the string : '"28-Jun-13"=>4158'.
This is not good.
By: merav
Date: 2014-07-23
Time: 22:46

Re: Embedded stacked bar in PPT

Thank you so much for the quick response.
It solved the issue!

I have another question maybe you know ...
When updating graphs in PPT - after I generate the PPT and I right click the graph and select the Edit Data option, the graph is being initialized to the default data in the original presentation.
Is it the expected behavior?

Thanks again!
Merav
By: Skrol29
Date: 2014-07-24
Time: 03:38

Re: Embedded stacked bar in PPT

Hi,

> Is it the expected behavior?

Ms Office save the user data twice: the actual data for the chart, and a small Excel sheet for entering data.
OpenTBS replace only the actual data. Editing the Excel sheet may be quite complicated ; deleting it may bring problems if it used for another chart.
By: merav
Date: 2014-07-24
Time: 11:39

Re: Embedded stacked bar in PPT

Thanks for all your answers.
You have been very helpful!