CREATE OR REPLACE PACKAGE BODY EFT_NOM.svg IS
-- Author : PRIESTJ
-- Created : 05/12/2005 17:24:19
-- Purpose : used to create svg objects like graphs and charts
-- Public constant declarations
pi constant number := 3.14159265; --slice of pie anyone?
--JP hacking
--need to stick the circle_pointx & circle_pointy in as proper
--functions (could even get rid of diameter parameter)
--will also need to set up variables.
--get the value of x on the circle
FUNCTION circle_pointx ( degrees number
, diameter number
) RETURN NUMBER IS
--
mydegrees NUMBER := 0;
--
BEGIN
--
-- Avoid problems with doubles
--
mydegrees := degrees + 0.5;--0.0001;
return cos(mydegrees * (pi / 180)) *(diameter / 2);
--
END circle_pointx;
--
-- Get the value of y on the circle
--
function circle_pointy(degrees number, diameter number) return number is
mydegrees number := 0;
begin
--avoid problems with doubles
mydegrees := degrees + 0.5;--0.0001;
return sin(mydegrees * (pi / 180)) *(diameter / 2);
end circle_pointy;
FUNCTION colour_palette ( p_index IN NUMBER ) RETURN VARCHAR2 IS
--
l_return VARCHAR2(6);
--
BEGIN
--
IF p_index = 1 THEN
--
l_return := '003D62';
--
ELSIF p_index = 2 THEN
--
l_return := 'FFFF00';
--
ELSIF p_index = 3 THEN
--
l_return := '00FF00';
--
ELSE
--
l_return := '555555';
--
END IF;
--
RETURN l_return;
--
END colour_palette;
--procedure used to display the cheese wedges for our pie chart, exports 3 svg
--path tags with attributes
PROCEDURE codedpiechart ( p_availcapacity IN NUMBER
, p_gasflowed IN NUMBER
, p_remainflow IN NUMBER
) IS
--
degrees number;
charttotal number;
currentvalue number;
arcx number;
arcy number;
StartDegrees number;
EndDegrees number;
wedgesize number;
wedgecolor varchar2(7);
largearcflag integer := 0;
svgtext varchar2(4000);
--
BEGIN
--
--ensure the first line is vertical
--
degrees := 270;
--
charttotal := p_availcapacity + p_gasflowed + p_remainflow;
for i in 1 .. 3 loop
--get the data for our chart depending on which cycle of the loop
if i = 1 then
currentvalue := p_availcapacity; --availcapcity
wedgecolor := '#336699';
elsif i = 2 then
currentvalue := p_gasflowed; --gasflowed
wedgecolor := '#6699CC';
elsif i = 3 then
currentvalue := p_remainflow; --remainflow
wedgecolor := '#99CCFF';
end if;
StartDegrees := round(degrees);
--figure out the angle (in degrees) of our current cheese
wedgesize := (currentvalue / charttotal) * 360;
degrees := degrees + wedgesize;
EndDegrees := round(degrees);
--if one of our cheeses is 180 or bigger we need to set the large arc flag
--other with the arc (A) won't draw it correctly
if wedgesize >= 180 then
largearcflag := 1;
else
largearcflag := 0;
end if;
svgtext :='';
--print out the svg path tag
htp.p(svgtext);
end loop;
end codedpiechart;
procedure piechart ( p_availcapacity IN NUMBER DEFAULT g_availcapacity
, p_gasflowed IN NUMBER DEFAULT g_gasflowed
, p_remainflow IN NUMBER DEFAULT g_remainflow
) IS
begin
--'Content-type: image/svg+xml'
owa_util.mime_header('image/svg+xml', true, 'iso-8859-4');
htp.print('');
htp.print('');
htp.print('');
end piechart;
procedure barchart is
begin
--'Content-type: image/svg+xml'
owa_util.mime_header('image/svg+xml', true, 'iso-8859-4');
htp.print('');
htp.print('');
htp.print('');
htp.print('');
--
END barchart;
--
/* PROCEDURE barchart2 IS
--
-- l_tab_inv is table of:
-- l_date
-- l_inventory
-- l_max_cap
-- l_min_cap
--
l_tab_inv lihp_home_page.t_tab_inv;
--
-- Fudged the number just a little...
--
l_max_qty NUMBER := 900000000;
--
l_x_start NUMBER := 80;
l_width NUMBER := 18;
l_x_step NUMBER := 8;
--
l_y_start NUMBER := 9.1;
l_y_step NUMBER := 14;
l_height NUMBER := 138;
--
BEGIN
--
owa_util.mime_header('image/svg+xml', true, 'iso-8859-4');
--
htp.print('');
htp.print('');
htp.print('');
htp.print('');
--
END barchart2;*/
--
--
--
PROCEDURE piechart2 ( p_pie_tab IN t_pie_tab ) IS
--
l_degrees NUMBER;
l_arcx NUMBER;
l_arcy NUMBER;
l_x_startdegrees NUMBER;
l_enddegrees NUMBER;
l_wedgesize NUMBER;
l_largearcflag INTEGER := 0;
l_svgtext VARCHAR2(4000);
--
l_x_origin NUMBER := 100;
l_y_origin NUMBER := 110;
l_radius NUMBER := 80;
--
BEGIN
--'Content-type: image/svg+xml'
owa_util.mime_header('image/svg+xml', true, 'iso-8859-4');
htp.print('');
htp.print('');
htp.print('');
--
END piechart2;
--
--
--
/*PROCEDURE barchart3(p_type IN VARCHAR2 DEFAULT 'A') IS
--
-- l_tab_inv is table of:
-- l_date
-- l_inventory
-- l_max_cap
-- l_min_cap
--
l_tab_inv lihp_home_page.t_tab_inv;
--
-- Fudged the number just a little...
--
l_max_qty NUMBER := 900000000;
--
l_x_start NUMBER := 80;
l_width NUMBER := 18;
l_x_step NUMBER := 8;
--
l_y_start NUMBER := 9.1;
l_y_step NUMBER := 14;
l_height NUMBER := 146;
--
l_idx NUMBER;
--
BEGIN
--
owa_util.mime_header('image/svg+xml', true, 'iso-8859-4');
--
htp.print('');
htp.print('');
htp.print('');
htp.print('');
--
END barchart3;*/
--
--
--
PROCEDURE piechart3 IS
--
l_degrees NUMBER;
l_arcx NUMBER;
l_arcy NUMBER;
l_x_startdegrees NUMBER;
l_enddegrees NUMBER;
l_wedgesize NUMBER;
l_largearcflag INTEGER := 0;
l_svgtext VARCHAR2(4000);
--
l_x_origin NUMBER := 100;
l_y_origin NUMBER := 70;
l_radius NUMBER := 50;
--
l_height NUMBER := 197;
l_width NUMBER := 199;
--
l_description VARCHAR2(200);
l_procedure VARCHAR2(200);
--
BEGIN
--
-- Determine procedure due to problems with 10g
--
BEGIN
SELECT hoev.element_value
,hoev.element_procedure
INTO l_description
,l_procedure
FROM user_homepage usho
,homepage_element hoel
,homepage_element_value hoev
WHERE hoel.hoel_id = usho.hoel_id
AND hoev.hoev_id = usho.hoev_id
AND hoev.hoel_id = usho.hoel_id
AND UPPER(hoel.element_name) = UPPER('Piechart')
AND usho.syus_id = caco_utilities.get_syus_id;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
--
IF l_procedure IS NOT NULL THEN
--
execute immediate 'begin svg.g_pie_tab := '||l_procedure||'; end;';
--
END IF;
--
IF g_pie_tab.COUNT > 0 THEN
--'Content-type: image/svg+xml'
owa_util.mime_header('image/svg+xml', true, 'iso-8859-4');
htp.print('');
htp.print('');
htp.print('');
--
END IF;
--
END piechart3;
--
END svg;
/