热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

xml文档转换工具,附图表例子

xml文档转换程序的一个小应用,几行代码生成饼图。源代码打包提供。源文档,饼图数据

 

 

 

xml文档转换程序的一个小应用,几行代码生成饼图。源代码打包提供。

 

源文档,饼图数据

xml version="1.0" encoding="utf-8"?>
<items>
<title>各指标所占比重title>
<unit>unit>
<item>
<name>指标一name>
<value>50value>
<description>1description>
item>
<item >
<name>指标二百五十二name>
<value>50value>
<description>2description>
item>
<item>
<name>指标三name>
<value>50value>
<description>3description>
item>
<item>
<name>指标四name>
<value>50value>
<description>4description>
item>
<item>
<name>指标五name>
<value>50value>
<description>5description>
item>
<item>
<name>指标六name>
<value>10value>
<description>6description>
item>
<item>
<name>指标七name>
<value>50value>
<description>7description>
item>
<item>
<name>指标八name>
<value>50value>
<description>8description>
item>
items>

 

 

模板文档

xml version&#61;"1.0" encoding&#61;"utf-8"?>
<template rootname&#61;"DIV">
<attribute name&#61;"style" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>


$System.Event.EventManager.attachEvent
(
$$("#ctrlid#") , "AfterRender",
function(sender)
{
var cMenu &#61; new $System.UI.ContextMenu($$("#ctrlid#").domid);
//alert(2);
$$("#ctrlid#").addChildNode(cMenu.guid , true);
$$("#ctrlid#").$$secret.codebehind.cMenuGUID &#61; cMenu.guid;
var srcDoc &#61; new $System.XML.XMLUtil.XDOC("root");
var tplDoc &#61; $System.XML.XMLUtil.loadXMLFile("res\\app\\module\\style\\contextmenu.tpl.xml");
cMenu.hide();
cMenu.render(srcDoc , tplDoc);
}
)


$$("#ctrlid#").$$secret.codebehind.showItemDetail &#61; function(itemName , itemValue , itemPercent)
{
//alert();
var cMenu &#61; $$($$(leftFrameGUID).$$secret.codebehind.cMenuGUID);
$(cMenu.guid &#43; "_detail").innerHTML &#61; $System.String.StringUtil.decodeURIComponent(detail);
//alert($(cMenu.guid &#43; "_detail").innerHTML);
cMenu.show(window.event.x , window.event.y);
}

$$("#ctrlid#").$$secret.codebehind.sectorOnMouseOver &#61; function(domid , startAngle , offsetAngle , angle , radius)
{
//$(domid).path &#61; "m0,0l0,0xe";
window.setTimeout("$(&#39;" &#43; domid &#43; "&#39;).path &#61; &#39;m0,0ae0,0,1000,1000," &#43; startAngle &#43;"," &#43; offsetAngle &#43; "xe&#39;" , 10 , "Javascript");
}
$$("#ctrlid#").$$secret.codebehind.sectorOnMouseOut &#61; function(domid , startAngle , offsetAngle , angle , radius)
{
//$(domid).path &#61; "m0,0l0,0xe";
window.setTimeout("$(&#39;" &#43; domid &#43; "&#39;).path &#61; &#39;m0,0ae0,0,850,850," &#43; startAngle &#43;"," &#43; offsetAngle &#43; "xe&#39;" , 10 , "Javascript");
}
//
//图表高、宽
var pContainer &#61; $$("#ctrlid#").getDomObject();
var w &#61; pContainer.style.pixelWidth;
var h &#61; pContainer.style.pixelHeight;
//alert(h);
if(h h &#61; h <(w * 5 / 6) ? h : Math.floor(w * 5 / 6);
}
else{
h &#61; Math.floor(w * 5 / 6);
}
var hv &#61; Math.min(w , h);

var rad &#61; Math.floor(2 * hv / 5);
//alert(rad);
var radius &#61; 1000;
$$("#ctrlid#").$$secret.codebehind.radius &#61; radius;
$$("#ctrlid#").$$secret.codebehind.rad &#61; rad;
//扇区数
var itemNodeList &#61; $$("#sdocguid#").getElementsByTagName("item");
$$("#ctrlid#").$$secret.codebehind.sectorCount &#61; itemNodeList.length;

var nameLengthArray &#61; [];
var maxItemNameLength , cNameLength;
if($$("#ctrlid#").$$secret.codebehind.sectorCount !&#61; 0){
for(iteri &#61; 0 ; iteri <$$("#ctrlid#").$$secret.codebehind.sectorCount; iteri &#43;&#43;){
cNameLength &#61; $System.String.StringUtil.getLengthInCn(itemNodeList.item(iteri).getElementsByTagName("name").item(0).text);
nameLengthArray.push(cNameLength);
}
maxItemNameLength &#61; nameLengthArray.sort
(
function(a , b){
if(a &#61;&#61; b){
return 0;
}
if(a > b){
return 1;
}
return -1;
}
)[nameLengthArray.length - 1];
}
$$("#ctrlid#").$$secret.codebehind.maxItemNameLength &#61; maxItemNameLength;
//图表背景尺寸
var bgLeft &#61; Math.floor((w - 2 * rad - Math.ceil(rad / 9) - Math.ceil(rad / 10) - (maxItemNameLength / 10) * rad) / 2);
//alert(bgLeft);
var bgTop &#61; Math.floor(rad / 7);
//alert(bgTop);
var bgWidth &#61; 2 * rad;
var bgHeight &#61; 2 * rad;
$$("#ctrlid#").$$secret.codebehind.bg &#61; {bgLeft : bgLeft , bgTop : bgTop , bgWidth : bgWidth , bgHeight : bgHeight};

//当前扇区起始角度
$$("#ctrlid#").$$secret.codebehind.cStartAngle &#61; 0;
$$("#ctrlid#").$$secret.codebehind.angleOffset &#61; 0;
$$("#ctrlid#").$$secret.codebehind.cSN &#61; null;
$$("#ctrlid#").$$secret.codebehind.cIndex &#61; 1000;
var strStyle;
strStyle &#61; "border:1px solid red;position:relative;left:0px;top:" &#43; Math.floor((pContainer.style.pixelHeight - h) / 2) &#43; "px;width:" &#43; w &#43; "px;height:" &#43; h &#43; "px;overflow:visible;";
//alert(strStyle);
]]>
statement>
expression>
attribute>
<foreach base&#61;"/item">
<element name&#61;"v:shape">
<attribute name&#61;"coordorigin" value&#61;"-1000,-1000" />
<attribute name&#61;"coordsize" value&#61;"2000,2000" />
<attribute name&#61;"stroked" value&#61;"false" />
<attribute name&#61;"fill" value&#61;"true" />
<element name&#61;"v:fill">
<attribute name&#61;"rotate" value&#61;"true" />
<attribute name&#61;"angle" value&#61;"180" />
<attribute name&#61;"focus" value&#61;"100%" />
<attribute name&#61;"type" value&#61;"gradient" />
<attribute name&#61;"color" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
paramlist>
<statement>

var sn;
if($$("#ctrlid#").$$secret.codebehind.cSN &#61;&#61; null){
$$("#ctrlid#").$$secret.codebehind.cSN &#61; 0;
}
else{
$$("#ctrlid#").$$secret.codebehind.cSN&#43;&#43;;
}
sn &#61; $$("#ctrlid#").$$secret.codebehind.cSN;
var totalCount &#61; $$("#ctrlid#").$$secret.codebehind.sectorCount;
//compute color.
var ar &#61; $System.UI.ColorUtil.genColorArrayOnItemNum(totalCount , 1 , 0.7);
sColor &#61; "rgb(" &#43; ar[sn].r &#43; " " &#43; ar[sn].g &#43; " " &#43; ar[sn].b &#43; ")";
]]>
statement>
expression>
attribute>
<attribute name&#61;"color2" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
paramlist>
<statement>

var sn;
sn &#61; $$("#ctrlid#").$$secret.codebehind.cSN;
var totalCount &#61; $$("#ctrlid#").$$secret.codebehind.sectorCount;
//compute color.
var ar &#61; $System.UI.ColorUtil.genColorArrayOnItemNum(totalCount , 0.5 , 1);
sColor &#61; "rgb(" &#43; ar[sn].r &#43; " " &#43; ar[sn].g &#43; " " &#43; ar[sn].b &#43; ")";
]]>
statement>
expression>
attribute>
element>
<attribute name&#61;"path" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var sn &#61; $$("#ctrlid#").$$secret.codebehind.cSN;
var cldNodeList &#61; $System.XML.XMLUtil.XElement.getElementChildsByTagName($$("#sdocguid#").documentElement , "item");
var totalCount &#61; $$("#ctrlid#").$$secret.codebehind.sectorCount;
var totalValue &#61; 0;
var valueArray &#61; [];
var cValue;
//compute startangle and endangle. degree * (2^16)
for(var ai &#61; 0 ; ai cValue &#61; parseFloat($System.XML.XMLUtil.XElement.getFirstElementChildByTagName(cldNodeList[ai] , "value").firstChild.nodeValue);
valueArray.push(cValue);
totalValue &#43;&#61; cValue;
}
var startAngle &#61; 0;
var angleOffset &#61; 0;
for(var ai &#61; 0 ; ai if(sn !&#61; ai){
startAngle &#43;&#61; (ai % 2 &#61;&#61; 0) ? Math.floor(valueArray[ai] / totalValue * 360 * 65536) : Math.ceil(valueArray[ai] / totalValue * 360 * 65536);
}
else{
angleOffset &#61; ((ai % 2 &#61;&#61; 0) ? Math.floor(valueArray[ai] / totalValue * 360 * 65536) : Math.ceil(valueArray[ai] / totalValue * 360 * 65536));
break;
}
}
if(sn &#61;&#61; (totalCount - 1)){
angleOffset &#61; 360 * 65536 - startAngle;
}

$$("#ctrlid#").$$secret.codebehind.cStartAngle &#61; startAngle;
$$("#ctrlid#").$$secret.codebehind.angleOffset &#61; angleOffset;
//construct the path attribute value.
var sPath;
sPath &#61; "m0,0ae0,0,850,850," &#43; startAngle &#43;"," &#43; angleOffset &#43; "xe";
]]>
statement>
expression>
attribute>

<element name&#61;"v:extrusion">
<attribute name&#61;"on" value&#61;"t" />
<attribute name&#61;"type" value&#61;"parallel" />
<attribute name&#61;"backdepth" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var str;
str &#61; Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 8);
]]>
statement>
expression>
attribute>
<attribute name&#61;"type" value&#61;"parallel" />
<attribute name&#61;"color" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var sn;
sn &#61; $$("#ctrlid#").$$secret.codebehind.cSN;
var totalCount &#61; $$("#ctrlid#").$$secret.codebehind.sectorCount;
//compute color.
var ar &#61; $System.UI.ColorUtil.genColorArrayOnItemNum(totalCount , 1 , 0.7);
sColor &#61; "rgb(" &#43; ar[sn].r &#43; " " &#43; ar[sn].g &#43; " " &#43; ar[sn].b &#43; ")";
]]>
statement>
expression>
attribute>
<attribute name&#61;"metal" value&#61;"t" />
<attribute name&#61;"rotationangle" value&#61;"20,0" />
<attribute name&#61;"skewangle" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var skewangle;
skewangle &#61; 90;
]]>
statement>
expression>
attribute>
element>
<attribute name&#61;"style" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var strStyle;
strStyle &#61; "border:0px solid red;position:absolute;left:" &#43; $$("#ctrlid#").$$secret.codebehind.bg.bgLeft &#43; "px;top:" &#43; $$("#ctrlid#").$$secret.codebehind.bg.bgTop &#43; "px;width:" &#43; $$("#ctrlid#").$$secret.codebehind.bg.bgWidth &#43; "px;height:" &#43; $$("#ctrlid#").$$secret.codebehind.bg.bgHeight &#43; "px;";
//alert(strStyle);
var startAngle &#61; $$("#ctrlid#").$$secret.codebehind.cStartAngle / 65536;

if(startAngle &#61;&#61; 0){
strStyle &#43;&#61; "z-index:" &#43; $$("#ctrlid#").$$secret.codebehind.cIndex;
}
else if(startAngle <90 && startAngle > 0){
strStyle &#43;&#61; "z-index:" &#43; (--$$("#ctrlid#").$$secret.codebehind.cIndex);
}
else if(startAngle >&#61;90 && startAngle <270){
$$("#ctrlid#").$$secret.codebehind.cIndex &#43;&#61; 2;
strStyle &#43;&#61; "z-index:" &#43; $$("#ctrlid#").$$secret.codebehind.cIndex;
}
else{
strStyle &#43;&#61; "z-index:" &#43; (--$$("#ctrlid#").$$secret.codebehind.cIndex);
}
]]>
statement>
expression>
attribute>
<attribute name&#61;"id" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var domid &#61; $System.genGUID();
domid;
]]>
statement>
expression>
attribute>
<attribute name&#61;"onmouseover" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#titleid#" path&#61;"." attr&#61;"id" tdoc&#61;"t" />
paramlist>
<statement>

var startAngle &#61; $$("#ctrlid#").$$secret.codebehind.cStartAngle;
var offsetAngle &#61; $$("#ctrlid#").$$secret.codebehind.angleOffset;
var angleLine &#61; ($$("#ctrlid#").$$secret.codebehind.cStartAngle &#43; $$("#ctrlid#").$$secret.codebehind.angleOffset / 2) / 65536;
var str;
str &#61; "$$(&#39;#ctrlid#&#39;).$$secret.codebehind.sectorOnMouseOver(&#39;#titleid#&#39; , " &#43; startAngle &#43; " , " &#43; offsetAngle &#43; " , " &#43; angleLine &#43; " , " &#43; $$("#ctrlid#").$$secret.codebehind.rad &#43; ")";
//alert(str);
]]>
statement>
expression>
attribute>
<attribute name&#61;"onmouseout" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#titleid#" path&#61;"." attr&#61;"id" tdoc&#61;"t" />
paramlist>
<statement>

var angleLine &#61; ($$("#ctrlid#").$$secret.codebehind.cStartAngle &#43; $$("#ctrlid#").$$secret.codebehind.angleOffset / 2) / 65536;
var str;
str &#61; "$$(&#39;#ctrlid#&#39;).$$secret.codebehind.sectorOnMouseOut(&#39;#titleid#&#39; , " &#43; startAngle &#43; " , " &#43; offsetAngle &#43; " , " &#43; angleLine &#43; " , " &#43; $$("#ctrlid#").$$secret.codebehind.rad &#43; ")";
]]>
statement>
expression>
attribute>
element>
foreach>

<element name&#61;"div">
<attribute name&#61;"style" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var pContainer &#61; $$("#ctrlid#").getDomObject();
var strStyle;
var h &#61; pContainer.style.pixelHeight - Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 4) - Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 8);
var l &#61; $$("#ctrlid#").$$secret.codebehind.bg.bgLeft &#43; $$("#ctrlid#").$$secret.codebehind.bg.bgWidth &#43; Math.ceil($$("#ctrlid#").$$secret.codebehind.rad / 10);
var w &#61; Math.ceil($$("#ctrlid#").$$secret.codebehind.maxItemNameLength / 8) * $$("#ctrlid#").$$secret.codebehind.rad &#43; Math.ceil($$("#ctrlid#").$$secret.codebehind.rad / 12);
strStyle &#61; "border:solid 0px #FF0000;position:absolute;left:" &#43; l &#43; "px;top:" &#43; Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 4) &#43; "px;width:" &#43; w &#43; "px;height:" &#43; h &#43; "px;";
]]>
statement>
expression>
attribute>
<element name&#61;"table">
<attribute name&#61;"height" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var pContainer &#61; $$("#ctrlid#").getDomObject();
var h;
h &#61; pContainer.style.pixelHeight - Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 4) - Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 8);
]]>
statement>
expression>
attribute>
<attribute name&#61;"border" value&#61;"0" />
<attribute name&#61;"align" value&#61;"right" />
<element name&#61;"tr">
<element name&#61;"td">
<attribute name&#61;"align" value&#61;"left" />
<attribute name&#61;"valign" value&#61;"middle" />
<element name&#61;"table">
<attribute name&#61;"border" value&#61;"0" />
<attribute name&#61;"height" value&#61;"1" />
<attribute name&#61;"cellpadding" value&#61;"0" />
<attribute name&#61;"cellspacing" value&#61;"0" />
<foreach base&#61;"/item">
<element name&#61;"tr">
<element name&#61;"td">
<attribute name&#61;"align" value&#61;"center" />
<attribute name&#61;"valign" value&#61;"middle" />
<attribute name&#61;"height" value&#61;"1" />
<element name&#61;"div">
<attribute name&#61;"style" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var strStyle;
var hw &#61; Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 10);
strStyle &#61; "margin:0px;position:relative;top:0px;left:0px;border:0px solid #FF0000;width:" &#43; hw &#43; "px;height:" &#43; hw &#43; "px;padding:0px;";
]]>
statement>
expression>
attribute>
<element name&#61;"v:shape">
<attribute name&#61;"style" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var strStyle;
var hw &#61; Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 10);
strStyle &#61; "margin:0px;position:absolute;top:0px;left:0px;width:" &#43; hw &#43; "px;height:" &#43; hw &#43; "px;";
]]>
statement>
expression>
attribute>
<attribute name&#61;"path" value&#61;"m 0,0 l 0,100 100,100 100,0 x e" />
<attribute name&#61;"coordorigin" value&#61;"0,0" />
<attribute name&#61;"coordsize" value&#61;"100,100" />
<element name&#61;"v:fill">
<attribute name&#61;"rotate" value&#61;"true" />
<attribute name&#61;"angle" value&#61;"180" />
<attribute name&#61;"focus" value&#61;"100%" />
<attribute name&#61;"type" value&#61;"gradient" />
<attribute name&#61;"color" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

if($$("#ctrlid#").$$secret.codebehind.sampleI &#61;&#61; null){
$$("#ctrlid#").$$secret.codebehind.sampleI &#61; 0;
}
var sColor;
var sn &#61; $$("#ctrlid#").$$secret.codebehind.sampleI;
var totalCount &#61; $$("#ctrlid#").$$secret.codebehind.sectorCount;
//compute color.
var ar &#61; $System.UI.ColorUtil.genColorArrayOnItemNum(totalCount , 1 , 0.7);
//$$("#ctrlid#").$$secret.codebehind.cColumnFillColor &#61; ar[sn].r &#43; "," &#43;ar[sn].g &#43; "," &#43;ar[sn].b;
sColor &#61; "rgb(" &#43; ar[sn].r &#43; " " &#43; ar[sn].g &#43; " " &#43; ar[sn].b &#43; ")";
]]>
statement>
expression>
attribute>
<attribute name&#61;"color2" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var sColor;
var sn &#61; $$("#ctrlid#").$$secret.codebehind.sampleI;
var totalCount &#61; $$("#ctrlid#").$$secret.codebehind.sectorCount;
//compute color.
var ar &#61; $System.UI.ColorUtil.genColorArrayOnItemNum(totalCount , 0.5 , 1);
//$$("#ctrlid#").$$secret.codebehind.cColumnFillColor &#61; ar[sn].r &#43; "," &#43;ar[sn].g &#43; "," &#43;ar[sn].b;
$$("#ctrlid#").$$secret.codebehind.sampleI&#43;&#43;;
sColor &#61; "rgb(" &#43; ar[sn].r &#43; " " &#43; ar[sn].g &#43; " " &#43; ar[sn].b &#43; ")";

]]>
statement>
expression>
attribute>
element>
element>
element>
element>
<element name&#61;"td">
<attribute name&#61;"height" value&#61;"1" />
<attribute name&#61;"width" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var ww;
ww &#61; Math.max(Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 30) , 5);
]]>
statement>
expression>
attribute>
<attribute name&#61;"style" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var strStyle;
var hw &#61; Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 8);
strStyle &#61; "margin:0px;padding:0px;height:" &#43; hw &#43; "px;line-height:1px;";
]]>
statement>
expression>
attribute>
<element name&#61;"br" />
element>
<element name&#61;"td">
<attribute name&#61;"height" value&#61;"1" />
<attribute name&#61;"align" value&#61;"left" />
<attribute name&#61;"valign" value&#61;"middle" />
<attribute name&#61;"nowrap" value&#61;"true" />
<attribute name&#61;"style" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var fs &#61; Math.ceil($$("#ctrlid#").$$secret.codebehind.rad / 15) > 9 ? Math.ceil($$("#ctrlid#").$$secret.codebehind.rad / 15) : 9;
strStyle &#61; "padding:0px;margin:0px;height:1px;line-height:" &#43; fs &#43; "px;font-size:" &#43; fs &#43;"px;font-weight:bold;font-family: &#39;Microsoft YaHei&#39;,SimHei,Helvetica,STHeiti,Georgia, &#39;Times New Roman&#39;, Times, serif;";
]]>
statement>
expression>
attribute>
<text path&#61;"./name" />
element>
element>
foreach>
element>
element>
element>
element>
element>

<element name&#61;"div">
<attribute name&#61;"style" expression&#61;"true">
<expression>
<paramlist>
<param name&#61;"#ctrlid#" path&#61;"/" attr&#61;"controlguid" />
<param name&#61;"#sdocguid#" path&#61;"/" attr&#61;"guid" />
paramlist>
<statement>

var w &#61; $$("#ctrlid#").getDomStyle("pixelWidth");
var h &#61; Math.floor($$("#ctrlid#").$$secret.codebehind.rad / 6);
var fs &#61; h > 14 ? h : 14;
strStyle &#61; "padding-top:" &#43; Math.floor(fs / 4) &#43; "px;font-size:" &#43; fs &#43; "px;text-align:center;border:solid 0px #FF0000;position:absolute;left:0px;top:0px;width:" &#43; w &#43; "px;height:" &#43; (fs &#43; Math.floor(fs / 4)) &#43; "px;line-height" &#43; (fs &#43; Math.floor(fs / 4)) &#43; "px;font-weight:bold;font-family: &#39;Microsoft YaHei&#39;,SimHei,Helvetica,STHeiti,Georgia, &#39;Times New Roman&#39;, Times, serif;";
]]>
statement>
expression>
attribute>
<text path&#61;"/title" />
element>
template>

 

 

 

 

转换代码

var ctrl1 &#61; new $System.UI.Control("div005");
var srcdoc &#61; $System.XML.XMLUtil.loadXMLFile("ria09\\style\\xmls\\graph_src.xml");
var tpldoc &#61; $System.XML.XMLUtil.loadXMLFile("ria09\\style\\xmls\\graph_3dpie_tpl.xml");
ctrl1.renderE(srcdoc , tpldoc);

 

 

 

转换结果

 

 

 代码下载

转:https://www.cnblogs.com/hanzhiyang/archive/2010/11/17/1879473.html



推荐阅读
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 在重复造轮子的情况下用ProxyServlet反向代理来减少工作量
    像不少公司内部不同团队都会自己研发自己工具产品,当各个产品逐渐成熟,到达了一定的发展瓶颈,同时每个产品都有着自己的入口,用户 ... [详细]
  • 本文介绍了Android 7的学习笔记总结,包括最新的移动架构视频、大厂安卓面试真题和项目实战源码讲义。同时还分享了开源的完整内容,并提醒读者在使用FileProvider适配时要注意不同模块的AndroidManfiest.xml中配置的xml文件名必须不同,否则会出现问题。 ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • 预备知识可参考我整理的博客Windows编程之线程:https:www.cnblogs.comZhuSenlinp16662075.htmlWindows编程之线程同步:https ... [详细]
  • iOS超签签名服务器搭建及其优劣势
    本文介绍了搭建iOS超签签名服务器的原因和优势,包括不掉签、用户可以直接安装不需要信任、体验好等。同时也提到了超签的劣势,即一个证书只能安装100个,成本较高。文章还详细介绍了超签的实现原理,包括用户请求服务器安装mobileconfig文件、服务器调用苹果接口添加udid等步骤。最后,还提到了生成mobileconfig文件和导出AppleWorldwideDeveloperRelationsCertificationAuthority证书的方法。 ... [详细]
  • Whatsthedifferencebetweento_aandto_ary?to_a和to_ary有什么区别? ... [详细]
  • 本文介绍了Oracle存储过程的基本语法和写法示例,同时还介绍了已命名的系统异常的产生原因。 ... [详细]
  • Activiti7流程定义开发笔记
    本文介绍了Activiti7流程定义的开发笔记,包括流程定义的概念、使用activiti-explorer和activiti-eclipse-designer进行建模的方式,以及生成流程图的方法。还介绍了流程定义部署的概念和步骤,包括将bpmn和png文件添加部署到activiti数据库中的方法,以及使用ZIP包进行部署的方式。同时还提到了activiti.cfg.xml文件的作用。 ... [详细]
  • Spring框架《一》简介
    Spring框架《一》1.Spring概述1.1简介1.2Spring模板二、IOC容器和Bean1.IOC和DI简介2.三种通过类型获取bean3.给bean的属性赋值3.1依赖 ... [详细]
  • 本文介绍了如何使用Express App提供静态文件,同时提到了一些不需要使用的文件,如package.json和/.ssh/known_hosts,并解释了为什么app.get('*')无法捕获所有请求以及为什么app.use(express.static(__dirname))可能会提供不需要的文件。 ... [详细]
  • JavaScript和HTML之间的交互是经由过程事宜完成的。事宜:文档或浏览器窗口中发作的一些特定的交互霎时。能够运用侦听器(或处置惩罚递次来预订事宜),以便事宜发作时实行相应的 ... [详细]
author-avatar
泽宇的精彩人生
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有