$progstr = "<html>
<head>
<script type='text/javascript'
src='http://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1',
{'packages':['annotatedtimeline']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new
google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', '$iname');
data.addColumn('string', 'title1');
data.addColumn('string', 'text1');";
$progstr .= "\n data.addRows([";
# Do middle section.
$max = -10000000;
$min = 10000000;
$data = '';
$i = 0;
$j = 0;
foreach $perln (@perdata) { # Load behavior/performance data.
if ($oemind ne 'm') {
($yr, $state, $stride, $invest, $dem) = split (':',$perln);
} else {
if ($i == 0) {
$i = 1;
next;
}
($yr, $valx, $ratx, $state, $stride, $wtdstri) = split
(':',$perln);
}
if ($oemind eq 'o' || $oemind eq 'e') {
if ($ditem == 1) {
$data = $state;
} elsif ($ditem == 2) {
$data = $stride;
} else {
$data = $invest;
}
} else {
if ($ditem == 1) {
$data = $valx;
} elsif ($ditem == 2) {
$data = $ratx;
} elsif ($ditem == 3) {
$data = $state;
} elsif ($ditem == 4) {
$data = $stride;
} else {
$data = $wtdstri;
}
} # Measure.
if ( (($oemind eq 'o' || $oemind eq 'e') && $ditem < 3) || ($oemind
eq 'm' && $ditem > 2) ) {
$data = 100 * $data;
$data = sprintf("%.1f",$data);
}
# Need to set range for stride, investment, and wt stride.
if ( (($oemind eq 'o' || $oemind eq 'e') && $ditem > 1) || ($oemind
eq 'm' && $ditem > 3) ) {
if ($data > $max) {
$max = $data;
}
if ($data < $min) {
$min = $data;
}
}
$datex = $yr . ',6,1';
$progstrs{$datex} = ' [new Date(' . $yr .
',6,1), '; # Month indicator seems to begin with 0 in the Google API
example.
$progstrs{$datex} .= $data . ', undefined, undefined],';
if ($j == 0) { # Get first performance indicator value for below.
$defrst = $data;
$j = 1;
}
# Save this part to add to any marks below - same year = same values.
$progstrs2{$datex} = $data . ', undefined,
undefined';
}
$progstrs{$datex} =
substr($progstrs{$datex},0,length($progstrs{$datex})-1); # Get rid of last
comma.
if ( (($oemind eq 'o' || $oemind eq 'e') && $ditem == 1) || ($oemind eq
'm' && $ditem == 3) ) { # State range.
$max = 100;
}
$j = 0;
foreach $tln (@tlnmrks) { # Interrogate marks and integrate the mark
into the timeline.
if (index(lc($tln),'analysis:') > -1) {
last;
}
($datex,$titlex,$textx) = split (':',$tln);
$datex =~ tr/ //ds; # Eliminate spaces.
$i = 0; # New date indicator.
if (index($datex,',') > -1) { # Date of mark includes month and day ->
new entry.
($yr,$mn,$da) = split (',',$datex);
$mn = $mn - 1; # Month adjustment.
$datex = $yr . ',' . $mn . ',' . $da;
$i = 1;
} else {
$yr = $datex; # Marker date is an existing data year.
$datex = $yr . ',6,1';
}
$odatex = $yr . ',6,1'; # Date of existing behavior/performance
record.
# Add mark information to the right line.
@sstrs = ();
if (exists $progstrs2{$odatex}) {
@sstrs = split (',', $progstrs2{$odatex});
} else {
if ($j) {
$sstrs[0] = $delast; # Been through once - take previous value.
} else {
$sstrs[0] = $defrst; # First time through - take first above.
}
}
$sstrs[1] = "'" . $titlex . "'";
$sstrs[2] = "'" . $textx . "'";
$progstrs2{$datex} = join (',', @sstrs);
# Dates are the same for an existing year.
$progstrs{$datex} = ' [new Date(' . $datex .
'), ' . $progstrs2{$datex} . '],';
$delast = $sstrs[0]; # Save last performance indicator value.
$j = 1; # Been through once.
}
# Sort the hash by the index into an array and add it to the program str.
foreach $key (sort (keys(%progstrs))) {
$progstr .= $progstrs{$key};
}
$progstr = substr($progstr,0,length($progstr)-1) . ']'; # Get rid of
last comma.
# Add the last part.
my @colors = ();
$colors[0] = "#$banrcolr";
$progstr .= " ]);
var chart = new
google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
chart.draw(data, {displayAnnotations: true,
displayZoomButtons: false, allValuesSuffix: '$suf', fill: 40, thickness: 1,
colors: ".@colors.", displayRangeSelector: false});
}
</script>
</head>
<body>
<div id='chart_div' style='width: 800px; height:
380px;'></div>
</body>
</html>";
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/c3bbff6d-9f29-418c-9d72-006a180ec4d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.