Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

v1.4.0 updated scripts

  • Loading branch information...
commit 954c46c7be84b33eea21d4fdb366d2320ef67650 1 parent 7c77716
@davidberneda authored
View
4 lib/teechart-animations-min.js
@@ -1,7 +1,7 @@
/*
TeeChart(tm) for JavaScript(tm)
@fileOverview TeeChart for JavaScript(tm)
- v1.3 October 2012
+ v1.4 December 2012
Copyright(c) 2012 by Steema Software SL. All Rights Reserved.
http://www.steema.com
@@ -14,7 +14,7 @@ var Tee=Tee||{};
(function(){"undefined"!==typeof exports&&(exports.Tee=Tee);Tee.FadeAnimation=function(g){Tee.Animation.call(this,g);this.kind="in";var f=this,c;this.fade={};this.setTransp=function(a){"out"==f.kind&&(a=1-a);c.legend&&(f.chart.legend.format.transparency=a);c.walls&&(f.chart.walls.transparency=a);c.series&&f.chart.series.each(function(d){d.format.transparency=a});c.marks&&f.chart.series.each(function(d){d.marks.transparency=a});c.title&&(f.chart.title.format.transparency=a);c.axes&&(f.chart.axes.transparency=
a);c.panel&&(f.chart.panel.format.transparency=a)};this.start=function(){c=this.fade;this.setTransp(1)};this.stop=function(){this.setTransp(0)};this.doStep=function(a){f.setTransp(1-a)}};Tee.FadeAnimation.prototype=new Tee.Animation;Tee.SeriesAnimation=function(g){function f(d,a,c){a.automatic=!1;var f=0.5*(d.oldmin+d.oldmax),d=0.5*(d.oldmax-d.oldmin);a.maximum=f+c*d;a.minimum=f-c*d}Tee.Animation.call(this,g);g instanceof Tee.Series?(this.series=g,this.chart=g.chart):this.series=null;this.oldmax=
this.oldmin=0;this.oldauto=!0;var c=1,a=this;this.kind="axis";this.getAxis=function(){var a=this.series||this.chart.series.firstVisible();return a?a.mandatoryAxis:null};this.doStep=function(d){var b=a.getAxis();b&&(b.automatic=!1);"axis"==a.kind?f(a,b,1+100*(1-d)):a.chart.series.each(function(b){if(!(a.series&&a.series!==b)){var f=b.data.values,g=b.data._old,e=f.length;if(b instanceof Tee.Pie)b.rotation=360*(1-d),c=d;else if("each"==a.kind){for(var h=e*d|0,b=0;b<h;b++)f[b]=g[b];h<e&&(f[h]=g[h]*(e*
-d-h))}else if("all"==a.kind)for(b=0;b<e;b++)f[b]=g[b]*d;else"axis"!=a.kind&&(c=d)}})};this.stop=function(){var d=a.getAxis();d&&(d.maximum=a.oldmax,d.minimum=a.oldmin,d.automatic=a.oldauto);a.chart.series.each(function(b){b.transform&&(b.transform=null);if(("each"==a.kind||"all"==a.kind)&&b.data._old)b.data.values=b.data._old,b.data._old=null})};this.start=function(){var a=this.getAxis(),b=this.chart,g=b.series.items,k=b.chartRect.width,l=b.chartRect.height,e,h=b.bounds.width,i=b.bounds.height;if(0==
+d-h))}else if("all"==a.kind)for(b=0;b<e;b++)f[b]=g[b]*d;else"axis"!=a.kind&&(c=d)}})};this.stop=function(){var d=a.getAxis();d&&(d.maximum=a.oldmax,d.minimum=a.oldmin,d.automatic=a.oldauto);a.chart.series.each(function(b){b.transform&&(b.transform=null);if(("each"==a.kind||"all"==a.kind)&&b.data._old)b.data.values=b.data._old,b.data._old=null})};this.start=function(){var a=this.getAxis(),b=this.chart,g=b.series.items,k=b.chartRect.width,l=b.chartRect.height,e,h=b.bounds.width,i=b.bounds.height;if(0===
g.length)return!1;this.oldmin=a.minimum;this.oldmax=a.maximum;this.oldauto=a.automatic;for(b=0;b<g.length;b++)if(e=g[b],!(this.series&&this.series!==e))if(e instanceof Tee.Pie)e.transform=function(){this.chart.ctx.scale(c,c)};else if("each"==this.kind||"all"==this.kind){var j=e.data.values,m=j.length;e.data._old=j.slice(0);for(e=0;e<m;e++)j[e]=0;a.automatic=!1}else"left"==this.kind?e.transform=function(){this.chart.ctx.translate(-k*(1-c),0)}:"right"==this.kind?e.transform=function(){this.chart.ctx.translate(k*
(1-c),0)}:"x"==this.kind?e.transform=function(){this.chart.ctx.scale(c,1)}:"y"==this.kind?e.transform=function(){this.chart.ctx.scale(1,c)}:"top"==this.kind?e.transform=function(){this.chart.ctx.translate(0,-l*(1-c))}:"bottom"==this.kind?e.transform=function(){this.chart.ctx.translate(0,l*(1-c))}:"zoomin"==this.kind?e.transform=function(){var a=this.chart.ctx;a.translate(0.5*h,0.5*i);a.scale(c,c);a.translate(0.5*-h,0.5*-i)}:(this.kind="zoomout",e.transform=function(){var a=this.chart.ctx;a.translate(0.5*
h,0.5*i);a.scale(2-c,2-c);a.translate(0.5*-h,0.5*-i)});"axis"==this.kind&&f(this,a,100)}};Tee.SeriesAnimation.prototype=new Tee.Animation;Tee.MarksAnimation=function(g){function f(b,c,d){return c<=a.current?d:""}Tee.Animation.call(this,g);g&&g instanceof Tee.Series?(this.series=g,this.chart=g.chart):this.series=null;this.current=-1;var c=this.series.marks,a=this,d;this.start=function(){d=c.ongettext;c.ongettext=f};this.stop=function(){c.ongettext=d;this.current=-1};this.doStep=function(b){a.current=
View
24 lib/teechart-data-min.js
@@ -1,7 +1,7 @@
/*
TeeChart(tm) for JavaScript(tm)
@fileOverview TeeChart for JavaScript(tm)
- v1.3 October 2012
+ v1.4 December 2012
Copyright(c) 2012 by Steema Software SL. All Rights Reserved.
http://www.steema.com
@@ -14,15 +14,15 @@ var Tee=Tee||{};
(function(){function u(t,r,e){var a,b,c=r,d,g,f;do if(d=c.links){g=d.length;for(b=0;b<g;b++){a=d[b].dimension;do{f=t;do if(a==f)return d[b].searchDimension=d[b].dimension,e.push(d[b]),d[b];while(f=f.parent);if((f=u(t,a,e))||(f=u(a,t,e)))return e.unshift(d[b]),f}while(a=a.parent)}}while(c=c.parent);d=r.subDimensions;for(b=0;b<d.length;b++)if(f=u(t,d[b],e))return f;return null}"undefined"!==typeof exports&&(exports.Tee=Tee);Tee.Data=function(){function t(e,a){if(a)for(var b=0,c=a.length,b=0;b<c;b++)e.push({id:a[b],
value:0,count:0})}this.datasets=[];this.addDataSet=function(e,a,b,c){a&&a.implementation&&(a=r(a));e=new Tee.Data.Dimension(e,b,c);e.object=a;e.dataset=e;e.dimensions=[];e.engine=this;this.datasets.push(e);return e};this.addJSON=function(e,a,b,c){return this.addDataSet(e,JSON.parse(a),b,c)};this.applyStyle=function(e,a){switch(a){case 0:e.panel.transparent=!1,e.panel.format.round.x=0,e.panel.format.round.y=0,e.panel.format.stroke.size=2,e.panel.format.stroke.fill="darkgray"}};this.groupOther=function(e,
a,b){var c,d=e.values.length,g,f;if(d>a){f=0;g=d-a;for(c=a;c<d;c++)f+=e.values[c];e.values[a-1]=f;e.labels[a-1]=b;e.values.splice(a,g);e.labels.splice(a,g);e.code.splice(a,g);return g}return-1};this.slider=function(e,a,b,c,d,g){var f=new Tee.Slider(e);f.min=0;f.max=a.length-1;f.step=1;f.position=f.min;f.useRange=!1;f.thumbSize=12;f.horizontal=!0;f.bounds.x=b;f.bounds.y=c;f.bounds.width=d;f.bounds.height=g;e.tools.add(f);return f};var r=function(e){var a={},b;if(1==e.nodeType){if(0<e.attributes.length)for(var c=
-0;c<e.attributes.length;c++)b=e.attributes.item(c),a[b.nodeName]=b.value}else 3==e.nodeType&&(a=e.nodeValue);if(e.hasChildNodes())for(c=0;c<e.childNodes.length;c++){b=e.childNodes.item(c);var d=b.nodeName;if("undefined"==typeof a[d])"#text"===d?b.hasChildNodes()?a[d]=r(b):(b=b.nodeValue.trim(),""!=b&&(a=b)):"xml"==d?a=r(b):a[d]=r(b);else{if("undefined"==typeof a[d].push){var g=a[d];a[d]=[];a[d].push(g)}a[d].push(r(b))}}return a};this.loadXMLDoc=function(e){var a=window.XMLHttpRequest?new XMLHttpRequest:
+0;c<e.attributes.length;c++)b=e.attributes.item(c),a[b.nodeName]=b.value}else 3==e.nodeType&&(a=e.nodeValue);if(e.hasChildNodes())for(c=0;c<e.childNodes.length;c++){b=e.childNodes.item(c);var d=b.nodeName;if("undefined"==typeof a[d])"#text"===d?b.hasChildNodes()?a[d]=r(b):(b=b.nodeValue.trim(),""!==b&&(a=b)):"xml"==d?a=r(b):a[d]=r(b);else{if("undefined"==typeof a[d].push){var g=a[d];a[d]=[];a[d].push(g)}a[d].push(r(b))}}return a};this.loadXMLDoc=function(e){var a=window.XMLHttpRequest?new XMLHttpRequest:
new ActiveXObject("Microsoft.XMLHTTP");a.open("GET",e,!1);a.send();return a.responseXML};this.loadXMLString=function(e){window.DOMParser?(parser=new DOMParser,xmlDoc=parser.parseFromString(e,"text/xml")):(xmlDoc=new ActiveXObject("Microsoft.XMLDOM"),xmlDoc.async=!1,xmlDoc.loadXML(e));return xmlDoc};this.queryDim=function(e,a,b){var c=e.dimension.getLinksTo(a),d,g;if(c){var f=c[0];e.initDims();var i="function"===typeof e.name?e.name:null;e.dimension.traverse(function(d,l){var m=null;if(!e.name||e.consider(d))if(a?
-null==f.field&&a==f.dimension?m=a.hasID?a.parent?a.data[a.id]:d[a.id]:a==e.dimension?l||b.length:a.field?d[a.field]:l:(m=a.searchAcross(c,d))&&a.hasID&&(m=m[a.id]):(m=e.dimension.title,m||(m=e.dimension.dataset.object,e.dimension.field&&(m=m[e.dimension.field]))),null!=m&&(!a||a.nulls||""!==m)){var g=-1,s,h=i?i(d):e.name?d[e.name]:d;"undefined"===typeof h?h=null:("number"!==typeof h&&(h=parseFloat(h)),h!==h&&(h=null));if(null!==h){a&&a.datetime&&(m=a.datePart(m));for(s=0;s<b.length;s++)if(b[s].id==
-m){g=s;if(0==b[g].count)b[g].count=1,b[g].value=h;else{s=e.measure;var k=h,j=b[g];j.count++;switch(s){case "sum":case "average":j.value+=k;break;case "high":if(1==j.count||k>j.value)j.value=k;break;case "low":if(1==j.count||k<j.value)j.value=k}}break}-1==g&&b.push({id:m,value:h,count:1})}}return!0});if("count"==e.measure)for(d=0;d<b.length;d++)g=b[d],g.value=g.count;else if("average"==e.measure)for(d=0;d<b.length;d++)g=b[d],0<g.count&&(g.value/=g.count);return!0}return!1};this.query=function(e,a){var b,
-c,d,g,f,i=[],n,l,m,v;c=a instanceof Array?a:[a];g=e instanceof Array?e:[e];v=g.length;if(0<v){var s=g[0];n=s?s.selected:null;m=[];if(n)m=n instanceof Array?n:[n];else if(s&&(s.id||s.field))m=s.getIds()}for(n=0;n<c.length;n++)if(b=c[n]){for(l=v-1;0<=l;l--)if(d=g[l],0<l){if(d){var h=d.selected,k;if(h)if(h instanceof Array||(h=[h]),d.selectedInclude)k=h;else{k=d.getIds();for(f=0;f<h.length;f++)k.splice(k.indexOf(h[f]),1)}else k=d.getIds();for(var j=0;j<k.length;j++)if(d.selected=k[j],d.nulls||""!=d.selected)if(f=
-[],t(f,m),this.queryDim(b,g[l-1],f,d)){var p;if(!(p=d.nulls)){p=0;for(var q=void 0,q=0;q<f.length;q++)p+=f[q].count;p=0<p}p&&i.push({metric:b,dimension:d,values:f,master:d.selected,masterdim:g[l-1]})}d.selected=h;break}}else f=[],t(f,m),this.queryDim(b,d,f)&&i.push({metric:b,dimension:d,values:f,master:null});if(0<v&&s&&!s.nulls)for(d=0;d<i[0].values.length;){for(b=l=0;b<i.length;b++)l+=i[b].values[d].count;if(0==l)for(b=0;b<i.length;b++)i[b].values.splice(d,1);else d++}}return i};this.Chart=function(e,
+null===f.field&&a==f.dimension?m=a.hasID?a.parent?a.data[a.id]:d[a.id]:a==e.dimension?l||b.length:a.field?d[a.field]:l:(m=a.searchAcross(c,d))&&a.hasID&&(m=m[a.id]):(m=e.dimension.title,m||(m=e.dimension.dataset.object,e.dimension.field&&(m=m[e.dimension.field]))),null!==m&&(!a||a.nulls||""!==m)){var g=-1,s,h=i?i(d):e.name?d[e.name]:d;"undefined"===typeof h?h=null:("number"!==typeof h&&(h=parseFloat(h)),h!==h&&(h=null));if(null!==h){a&&a.datetime&&(m=a.datePart(m));for(s=0;s<b.length;s++)if(b[s].id==
+m){g=s;if(0===b[g].count)b[g].count=1,b[g].value=h;else{s=e.measure;var k=h,j=b[g];j.count++;switch(s){case "sum":case "average":j.value+=k;break;case "high":if(1==j.count||k>j.value)j.value=k;break;case "low":if(1==j.count||k<j.value)j.value=k}}break}-1==g&&b.push({id:m,value:h,count:1})}}return!0});if("count"==e.measure)for(d=0;d<b.length;d++)g=b[d],g.value=g.count;else if("average"==e.measure)for(d=0;d<b.length;d++)g=b[d],0<g.count&&(g.value/=g.count);return!0}return!1};this.query=function(e,a){var b,
+c,d,g,f,i=[],n,l,m,v,s;c=a instanceof Array?a:[a];g=e instanceof Array?e:[e];v=g.length;if(0<v)if(n=(s=g[0])?s.selected:null,m=[],n)m=n instanceof Array?n:[n];else if(s&&(s.id||s.field))m=s.getIds();for(n=0;n<c.length;n++)if(b=c[n]){for(l=v-1;0<=l;l--)if(d=g[l],0<l){if(d){var h=d.selected,k;if(h)if(h instanceof Array||(h=[h]),d.selectedInclude)k=h;else{k=d.getIds();for(f=0;f<h.length;f++)k.splice(k.indexOf(h[f]),1)}else k=d.getIds();for(var j=0;j<k.length;j++)if(d.selected=k[j],d.nulls||""!==d.selected)if(f=
+[],t(f,m),this.queryDim(b,g[l-1],f,d)){var p;if(!(p=d.nulls)){p=0;for(var q=void 0,q=0;q<f.length;q++)p+=f[q].count;p=0<p}p&&i.push({metric:b,dimension:d,values:f,master:d.selected,masterdim:g[l-1]})}d.selected=h;break}}else f=[],t(f,m),this.queryDim(b,d,f)&&i.push({metric:b,dimension:d,values:f,master:null});if(0<v&&s&&!s.nulls)for(d=0;d<i[0].values.length;){for(b=l=0;b<i.length;b++)l+=i[b].values[d].count;if(0===l)for(b=0;b<i.length;b++)i[b].values.splice(d,1);else d++}}return i};this.Chart=function(e,
a){function b(a,b){var c=0,d;for(d=0;d<a.length;d++)c+=a[d].data.values[b];return c}var c=new Tee.Chart(e);c.engine=this;c.panel.margins.left=0;var d=new Tee.ToolTip(c);d.render="dom";c.tools.add(d);d.ongettext=function(a,b,c,d){var a="",f=c.data.labels;1<c.chart.series.count()&&(a="<br/>"+c.title);c.data.x&&(a+="<br/>"+c.data.x[d]);return b+" "+(0<f.length?f[d]:"")+a};var g=new Tee.Animation;g.onstart=function(){this.s.fill="yellow"};g.onstop=function(){this.s.fill=this.old};g.duration=100;g.animateHover=
function(a){this.s=a.series.items[0].hover.stroke;this.old=this.s.fill;this.animate(a)};c.title.text=a;c.guessStyle=function(a){return this.defaultStyle?this.defaultStyle:30<a.length?Tee.Line:Tee.Bar};c.newSeries=function(a,b){var d=b.values,f=b.dimension,g=b.master;b.masterdim||(g=g&&f&&f.id?g[f.id]:b.master||b.metric.title);var e=c.guessStyle(d),h=c.addSeries(new e),k=h.data;h.title=""+(g||"(none)");h.marks.style="value";h.cursor="pointer";k.values=[];k.labels=[];k.code=[];var j;j=c.series.items.length;
-var g=[],p;f&&f.titles&&u(f.titles,f,g);if(1<j){var q,r=c.series.items[j-2].data;for(q=0;q<r.values.length;q++)k.values.push(0),k.labels.push(r.labels[q]),k.code.push(r.code[q]);for(q=0;q<d.length;q++)j=d[q],p=r.code.indexOf(j.id),-1==p?(k.values.push(j.value),p=f&&f.titles?(p=f.searchAcross(g,j.id))?p[f.titles.id]:"":j.id[f.id],k.labels.push(p),k.code.push(j.id)):k.values[p]=j.value}else for(q=0;q<d.length;q++)j=d[q],k.values.push(j.value),p=f&&f.titles?(p=f.searchAcross(g,j.id))?p[f.titles.id]:
+var g=[],p,q;f&&f.titles&&u(f.titles,f,g);if(1<j){var r=c.series.items[j-2].data;for(q=0;q<r.values.length;q++)k.values.push(0),k.labels.push(r.labels[q]),k.code.push(r.code[q]);for(q=0;q<d.length;q++)j=d[q],p=r.code.indexOf(j.id),-1==p?(k.values.push(j.value),p=f&&f.titles?(p=f.searchAcross(g,j.id))?p[f.titles.id]:"":j.id[f.id],k.labels.push(p),k.code.push(j.id)):k.values[p]=j.value}else for(q=0;q<d.length;q++)j=d[q],k.values.push(j.value),p=f&&f.titles?(p=f.searchAcross(g,j.id))?p[f.titles.id]:
"":""+j.id,k.labels.push(p),k.code.push(j.id);e==Tee.CircularGauge&&h.setValue(h.data.values[0]);if(this.onnewseries)this.onnewseries(this,h);return h};c.defaultStyle=null;c.animateChanges=!1;c.setSeriesStyle=function(a){if(!a||""===a||"auto"===a)this.defaultStyle=null;else{var b=this.series,c,d;this.defaultStyle=d="string"===typeof a?eval(a):a;for(var f=0;f<b.items.length;f++)c=b.items[f].data,a=new d,a.setChart(a,this),a.format.fill=b.items[f].format.fill,a.data=c,b.items[f]=a;this.draw()}};c.fill=
function(a,b,c){this.fillQuery(this.engine.query(a,b),a,b,c)};c.fillQuery=function(a,b,d,f){var g,e,h,k=c.series.items;c.series.items=[];if(a){for(g=0;g<a.length;g++){e=a[g];h=e.metric;this.newSeries(h,e).onclick=c.engine._onclickseries;if(""===c.title.text||"undefined"===typeof c.title.text)c.title.text=h.dimension.title;d instanceof Array||(c.legend.title.text=h.title+"\n"+h.measure,c.legend.title.format.font.textAlign="right");if((e=b instanceof Array?b[0]:b)&&e!=h.dataset)c.axes.bottom.title.text=
e.datetime?e.title+" "+e.dateKeys[e.datetime.selected]:e.title}0<a.length&&(c.axes.left.title.text=a[0].metric.title)}a=this.sort;""!==a.sortBy&&this.sortData(a.sortBy,"ascending"===a.order);""!==a.series&&this.sortSeries("ascending"==a.series);if(c.animateChanges&&k.length==c.series.items.length){var a=c.series.items[0],j=a.data.values;if(k[0].prototype==a.prototype&&k[0].data.values.length==j.length){var p=j.slice(0),q,a=new Tee.Animation(c,function(a){for(var b=0;b<j.length;b++)q=k[0].data.values[b],
@@ -30,15 +30,15 @@ j[b]=q+(p[b]-q)*a}),b=c.axes.left.automatic;c.axes.left.automatic=!1;a.duration=
function(a,c){var d,f=this.series.count(),g=this.series.items[0];if(0<f){if(1<f&&"values"==a){var f=g.data.values.length,e=this.series.items;d=Array(f);for(g=0;g<f;g++)d[g]=g;d.sort(function(a,d){var f=b(e,a),g=b(e,d);return c?f-g:g-f})}else d=this.series.items[0].doSort(a,c);this.series.each(function(a){for(var b={values:[],labels:[],code:[]},c=a.data,f,g=0;g<c.values.length;g++)f=d[g],b.values.push(c.values[f]),b.labels.push(c.labels[f]),b.code.push(c.code[f]);a.data=b})}};c.sortSeries=function(a){var b=
this.series.items,c=b.length;if(!(2>c)){for(var d=Array(c),f,g,e=a?-1:1,k=a?1:-1,a=0;a<c;a++)d[a]=a;d.sort(function(a,c){f=b[a].title.toLowerCase();g=b[c].title.toLowerCase();return f<g?e:f==g?0:k});for(var j=Array(c),a=0;a<c;a++)j[a]=b[d[a]];this.series.items=j}};c.groupOther=function(a){this.series.each(function(b){var c=Engine.groupOther(b.data,a,"Other");-1<c&&(b.data.code[c]=null,b.data.code.splice(0,c))})};c.totalPoints=function(){var a=0;this.series.each(function(b){a+=b.data.values.length});
return a};c.sort={sortBy:"",order:"descending",series:"ascending"};c.setPositionPercent=function(a,b,c,d){var f=self.innerHeight?self.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body?document.body.clientHeight:0,g=self.innerHeight?self.innerWidth:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientWidth:document.body?document.body.clientWidth:0,e=this.canvas,c=c*0.01*g|0,d=d*0.01*
-f|0;e.style.position="absolute";e.style.left=0.01*a*g+"px";e.style.top=0.01*b*f+"px";e.style.width=c+"px";e.style.height=d+"px";e.setAttribute("width",c+"px");e.setAttribute("height",d+"px");this.bounds.width=c;this.bounds.height=d;this.draw()};if(Tee.SeriesAnimation){d=c.animation=new Tee.SeriesAnimation(c);d.kind="zoomin";d.duration=300;var f=new Tee.FadeAnimation(c);f.fade.series=!0;d.items.push(f)}return c}};Tee.Data.Metric=function(t,r,e){this.name=e;this.title=r||e;this.dimension=t;var a=(this.dataset=
+f|0;e.style.position="absolute";e.style.left=0.01*a*g+"px";e.style.top=0.01*b*f+"px";e.style.width=c+"px";e.style.height=d+"px";e.setAttribute("width",c);e.setAttribute("height",d);this.bounds.width=c;this.bounds.height=d;this.draw()};if(Tee.SeriesAnimation){d=c.animation=new Tee.SeriesAnimation(c);d.kind="zoomin";d.duration=300;var f=new Tee.FadeAnimation(c);f.fade.series=!0;d.items.push(f)}return c}};Tee.Data.Metric=function(t,r,e){this.name=e;this.title=r||e;this.dimension=t;var a=(this.dataset=
t.dataset).engine;this.measure="sum";this.initDims=function(){var b,c=a.datasets.length,d,g,f,e,n=this.dimension;this.allDims=[];for(b=0;b<c;b++){g=a.datasets[b].dimensions;f=g.length;for(d=0;d<f;d++)e=g[d],n!=e&&(!n.hasParent(e)&&e.anySelected())&&(e._link=e.dataset==n.dataset?null:n.getLinksTo(e),this.allDims.push(e))}};this.consider=function(a){var c,d=this.allDims.length,g,f;for(c=0;c<d;c++){g=this.allDims[c];if(g._link){f=a;for(var e=0;e<g._link.length;e++)f=g.search(g._link[e],f);f&&g.id&&(f=
f[g.id])}else f=a[g.field];if("undefined"===typeof f||null===f)return!1;g.datetime&&(f=g.datePart(f));if(!g.inSelected(f))return!1}return!0}};Tee.Data.Dimension=function(t,r,e){this.engine=this.parent=this.dataset=null;this.subDimensions=[];this.field=r;this.id=e;this.title=t||r;this.nulls=!0;this.hasID="undefined"!==typeof e&&null!==e&&""!==e;this.metrics=[];this.links=[];this.select=this.selected=null;this.selectedInclude=!0;this.dateKeys={c:"Century",x:"Decade",y:"Year",m:"Month",w:"Weekday",d:"Day"};
this.addDimension=function(a,b,c){return this.addSubDimension(this,a,b,c)};this.addSubDimension=function(a,b,c,d){b=new Tee.Data.Dimension(b,c,d);b.engine=this.engine;if(b.parent=a)b.dataset=a.dataset,b.dataset&&(b.index=b.dataset.dimensions.push(b)),a.subDimensions.push(b);return b};this.addMetric=function(a,b,c){a=new Tee.Data.Metric(this,a,b);c&&(a.measure=c);this.metrics.push(a);return a};this.addLink=function(a,b,c){a={field:a,dimension:b,datasetField:c,parent:this};this.links.push(a);return a};
this.hasParent=function(a){for(var b=this.parent;b;){if(b==a)return!0;b=b.parent}return!1};this.inSelected=function(a){return this.select?this.select(a):this.selected instanceof Array?this.selectedInclude?-1!=this.selected.indexOf(a):-1==this.selected.indexOf(a):this.selectedInclude?this.selected==a:this.selected!=a};this.get=function(a){var b=this.id,c,d=this.datetime,e=this;this.traverse(function(f){d&&(f=e.datePart(f));return a==(b?f[b]:f)?(c=f,!1):!0});return c};this.datePart=function(a){var b=
-this.datetime,c=b.selected;if("string"==typeof a){var d=a.match(/(\d+)/g);if("y"==c)return d[b.yearField||2];if("m"==c)return d[b.monthField||0];if("x"==c)return 10*(parseInt(d[2])/10|0);if("d"==c)return d[b.dayField||1];if("w"==c)return(new Date(a)).getDay()}else if(a instanceof Date){if("y"==c)return a.getFullYear();if("m"==c)return a.getMonth()+1;if("x"==c)return 10*(a.getFullYear()/10|0);if("d"==c)return a.getDate();if("w"==c)return a.getDay()}return a};this.getValues=function(){var a=[],b=this.field,
-c=this.id,d=this;this.traverse(function(e){c&&(e=b?e[b]:e[c]);d.datetime&&(e=d.datePart(e));-1==a.indexOf(e)&&a.push(e);return!0});return a};this.getIds=function(){var a=[],b,c=this.id,d=this.field,e=this;(this.parent?this.parent:this).traverse(function(f){b=c?f[c]:d?f[d]:f;e.datetime&&(b=e.datePart(b));(e.nulls||b)&&-1==a.indexOf(b)&&a.push(b);return!0});return a};this.isSelected=function(a){return this.select?this.select(a):this.selected?this.inSelected(a):!0};this.anySelected=function(){if(this.select)return!0;
-var a=this.selected;if(null!==a&&"undefined"!=typeof a)if(a instanceof Array)for(var b=0;b<a.length;b++){if(a[b])return!0}else return!0;return!1};this.toggleSelected=function(a,b){this.selected||(this.selected=[]);var c=a.data.code[b],d=this.selected.indexOf(c);-1==d?this.selected.push(c):(this.selected.splice(d,1),0==this.selected.length&&(this.selected=null));a.chart.setSeriesPalette(a,this)};this.traverse=function(a){function b(d,e){var i,n;i=c[e];n=i.anySelected();var l=i.field?d[i.field]:d,m=
-i.parent?d:l;if(!n||i.isSelected(i.id?m[i.id]:m))if(i.data=m,l instanceof Array)if(n=l.length,0<e)for(i=0;i<n;i++){if(!b(l[i],e-1))return!1}else for(i=0;i<n;i++){if(!a(l[i],i))return!1}else if(0<e){a:if(l&&"object"===typeof l){var r=Object.keys(l),s=r.length,h=c[0],k=h.anySelected();for(i=0;i<s;i++)if(m=r[i],!k||h.isSelected(m))if(n=l[m],h.data=n,!a(n,m)){l=!1;break a}l=!0}else l=a(l,void 0);if(!l)return!1}else if(!a(m))return!1;return!0}var c=[],d=this;do c.push(d);while(d=d.parent);(d=this.dataset.object)&&
+this.datetime,c=b.selected;if("string"==typeof a){var d=a.match(/(\d+)/g);if("y"==c)return d[b.yearField||2];if("m"==c)return d[b.monthField||0];if("x"==c)return 10*(parseInt(d[2],10)/10|0);if("d"==c)return d[b.dayField||1];if("w"==c)return(new Date(a)).getDay()}else if(a instanceof Date){if("y"==c)return a.getFullYear();if("m"==c)return a.getMonth()+1;if("x"==c)return 10*(a.getFullYear()/10|0);if("d"==c)return a.getDate();if("w"==c)return a.getDay()}return a};this.getValues=function(){var a=[],b=
+this.field,c=this.id,d=this;this.traverse(function(e){c&&(e=b?e[b]:e[c]);d.datetime&&(e=d.datePart(e));-1==a.indexOf(e)&&a.push(e);return!0});return a};this.getIds=function(){var a=[],b,c=this.id,d=this.field,e=this;(this.parent?this.parent:this).traverse(function(f){b=c?f[c]:d?f[d]:f;e.datetime&&(b=e.datePart(b));(e.nulls||b)&&-1==a.indexOf(b)&&a.push(b);return!0});return a};this.isSelected=function(a){return this.select?this.select(a):this.selected?this.inSelected(a):!0};this.anySelected=function(){if(this.select)return!0;
+var a=this.selected;if(null!==a&&"undefined"!=typeof a)if(a instanceof Array)for(var b=0;b<a.length;b++){if(a[b])return!0}else return!0;return!1};this.toggleSelected=function(a,b){this.selected||(this.selected=[]);var c=a.data.code[b],d=this.selected.indexOf(c);-1===d?this.selected.push(c):(this.selected.splice(d,1),0===this.selected.length&&(this.selected=null));a.chart.setSeriesPalette(a,this)};this.traverse=function(a){function b(d,e){var i,n;i=c[e];n=i.anySelected();var l=i.field?d[i.field]:d,
+m=i.parent?d:l;if(!n||i.isSelected(i.id?m[i.id]:m))if(i.data=m,l instanceof Array)if(n=l.length,0<e)for(i=0;i<n;i++){if(!b(l[i],e-1))return!1}else for(i=0;i<n;i++){if(!a(l[i],i))return!1}else if(0<e){a:if(l&&"object"===typeof l){var r=Object.keys(l),s=r.length,h=c[0],k=h.anySelected();for(i=0;i<s;i++)if(m=r[i],!k||h.isSelected(m))if(n=l[m],h.data=n,!a(n,m)){l=!1;break a}l=!0}else l=a(l,void 0);if(!l)return!1}else if(!a(m))return!1;return!0}var c=[],d=this;do c.push(d);while(d=d.parent);(d=this.dataset.object)&&
b(d,c.length-1)};this.searchAcross=function(a,b){for(var c=b,d=this,e=0;e<a.length;e++)c=d.search(a[e],c,0<e),e<a.length-1&&(d=a[e+1].parent,a[e+1].searchDimension=d);c&&this.engine.cache&&(b.cache||(b.cache=[]),b.cache[this.index]||(b.cache[this.index]=c));return c};this.search=function(a,b,c){if(b.cache&&b.cache[this.index])return b.cache[this.index];var d=null,e,f,i=a.search,n=c?a.field:a.datasetField,c=c?a.datasetField:a.field,l=c instanceof Array;if(l){e=[];for(f=0;f<c.length;f++)e.push(b[c[f]])}else e=
b[c];a=a.searchDimension||a.dimension;do if(a.traverse(function(a){if(i){if(i(a,b))return d=a,!1}else if(l){var c=!0;for(f=0;f<e.length;f++)if(a[n[f]]!==e[f]){c=!1;break}if(c)return d=a,!1}else if(a[n]==e)return d=a,!1;return!0}),d){if(a.dataset!==this.dataset)return d;if(a!==this)if(a.parent)a=a.parent,d=a.data;else break}else break;while(a!==this);return d?this.id?d:d[this.field]:null};this.getLinksTo=function(a){if(!a||a==this.dataset||a.dataset==this.dataset)return[{field:null,dimension:a,datasetField:null,
parent:this}];var b=[],c=u(a,this,b);c||(c=u(this,a,b));return c?b:null}}}).call(this);
View
36 lib/teechart-extras-min.js
@@ -1,8 +1,8 @@
/*
TeeChart(tm) for JavaScript(tm)
@fileOverview TeeChart for JavaScript(tm)
- v1.3 October 2012
- Copyright(c) 2012 by Steema Software SL. All Rights Reserved.
+ v1.5 January 2013
+ Copyright(c) 2012-2013 by Steema Software SL. All Rights Reserved.
http://www.steema.com
Licensed with commercial and non-commercial attributes,
@@ -12,21 +12,19 @@
*/
var Tee=Tee||{};
(function(){function m(c,a){return"rgba( "+c[0]+", "+c[1]+", "+c[2]+", "+a+" )"}function p(){try{return new XMLHttpRequest}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(g){}throw Error("Could not create HTTP request object.");}Tee.Chart.prototype.drawReflection=function(){var c=this.ctx,a=this.bounds.height;c.scale(1,-1);c.translate(0,2*-a);this.ondraw=null;this.draw();c.translate(0,2*a);c.scale(1,-1);var g=this.canvas.height-
-a,e=c.createLinearGradient(0,a,0,a+g),b=this.reflectionColor;e.addColorStop(0,m(b,0.5));e.addColorStop(1,m(b,1));c.fillStyle=e;c.beginPath();c.shadowColor="transparent";c.rect(0,a,this.bounds.width,g);c.fill();this.ondraw=this.drawReflection};Tee.drawSpline=function(c,a,g,e,b){function f(b,h,a,d,c,f,e){var g=Math.sqrt((a-b)*(a-b)+(d-h)*(d-h)),g=e*g/(g+Math.sqrt((c-a)*(c-a)+(f-d)*(f-d))),e=e-g;return[a+g*(b-c),d+g*(h-f),a-e*(b-c),d-e*(h-f)]}var d=[],h=a.length;if(b){e&&c.moveTo(a[0],a[1]);a.push(a[0],
+a,e=c.createLinearGradient(0,a,0,a+g),b=this.reflectionColor;e.addColorStop(0,m(b,0.5));e.addColorStop(1,m(b,1));c.fillStyle=e;c.beginPath();c.shadowColor="transparent";c.rect(0,a,this.bounds.width,g);c.fill();this.ondraw=this.drawReflection};Tee.drawSpline=function(c,a,g,e,b){function f(b,h,a,d,f,c,g){var e=Math.sqrt((a-b)*(a-b)+(d-h)*(d-h)),e=g*e/(e+Math.sqrt((f-a)*(f-a)+(c-d)*(c-d))),g=g-e;return[a+e*(b-f),d+e*(h-c),a-g*(b-f),d-g*(h-c)]}var d=[],h=a.length;if(b){e&&c.moveTo(a[0],a[1]);a.push(a[0],
a[1],a[2],a[3]);a.unshift(a[h-1]);a.unshift(a[h-1]);for(b=0;b<h;b+=2)d=d.concat(f(a[b],a[b+1],a[b+2],a[b+3],a[b+4],a[b+5],g));d=d.concat(d[0],d[1]);for(b=2;b<h+2;b+=2)c.bezierCurveTo(d[2*b-2],d[2*b-1],d[2*b],d[2*b+1],a[b+2],a[b+3])}else{for(b=0;b<h-4;b+=2)d=d.concat(f(a[b],a[b+1],a[b+2],a[b+3],a[b+4],a[b+5],g));e&&c.moveTo(a[0],a[1]);c.quadraticCurveTo(d[0],d[1],a[2],a[3]);for(b=2;b<h-5;b+=2)c.bezierCurveTo(d[2*b-2],d[2*b-1],d[2*b],d[2*b+1],a[b+2],a[b+3]);c.quadraticCurveTo(d[2*h-10],d[2*h-9],a[h-
-2],a[h-1])}};Tee.Chart.prototype.applyTheme=function(c){!c||""==c?this.applyTheme("default"):"default"==c?(this.title.format.font.style="18px Verdana",this.walls.visible=!0,this.panel.format.shadow.visible=!0,this.panel.format.round.x=8,this.panel.format.round.y=8,this.panel.format.gradient.visible=!0,this.panel.format.stroke.fill="black",this.axes.left.grid.visible=!0,this.axes.top.grid.visible=!0,this.axes.right.grid.visible=!0,this.axes.bottom.grid.visible=!0):"minimal"==c?(this.title.transparent=
-!0,this.walls.visible=!1,this.legend.transparent=!0,this.footer.transparent=!0,this.panel.format.shadow.visible=!1,this.panel.format.stroke.fill="",this.panel.format.round.x=0,this.panel.format.round.y=0,this.panel.format.gradient.visible=!1,this.panel.format.fill="white",this.series.each(function(a){a.notmandatory.grid.visible=!1})):"excel"==c&&(this.palette.colors="#FF9999 #663399 #CCFFFF #FFFFCC #660066 #8080FF #CC6600 #FFCCCC #800000 #FF00FF #00FFFF #FFFF00 #800080 #000080 #808000 #FF0000 #FFCC00 #FFFFCC #CCFFCC #00FFFF #FFCC99 #CC99FF".split(" "));
-this.draw()};Tee.doHttpRequest=function(c,a,g,e){var b=p();b&&(b.onreadystatechange=function(){4==b.readyState&&(200==b.status?g(c,b.responseText):e&&e(b.status,b.statusText))},b.open("GET",a,!0),b.send(null))};Tee.Slider=function(c,a){function g(b,a){return a.x>=b.x&&a.x<=b.x+b.width&&a.y>=b.y&&a.y<=b.y+b.height}Tee.Tool.call(this,c);var e=this.thumb=new Tee.Format(c);e.round={x:4,y:4};e.stroke.size=0.5;e.gradient.visible=!0;e.gradient.direction="bottomtop";e.shadow.visible=!0;e=this.back=new Tee.Format(c);
-e.fill="white";e.gradient.visible=!0;e.stroke.fill="darkgrey";e.round={x:4,y:4};e=this.grip=new Tee.Format(c);e.round={x:4,y:4};e.stroke.fill="rgb(20,20,20)";this.gripSize=3;var b=this.bounds={x:10,y:10,width:200,height:20};this.transparent=!1;this.margin=16;this.min=0;this.max=100;this.position="undefined"==typeof a?50:a;this.useRange=!1;this.thumbSize=8;this.horizontal=!0;this.cursor="pointer";this.delta=0;this.thumbRect=function(h){var a=this.max-this.min,a=0<a?(this.position-this.min)/a:0;this.horizontal?
-(h.width=this.thumbSize,h.x=b.x+a*b.width-0.5*h.width,h.y=b.y,h.height=b.height):(h.height=this.thumbSize,h.y=b.y+a*b.height-0.5*h.height,h.x=b.x,h.width=b.width)};var f={};this.gripRect=function(b){if(this.horizontal){var a=0.2*b.height;return{x:b.x-this.gripSize,y:b.y+0.5*b.height-a,width:2*this.gripSize,height:2*a}}a=0.2*b.width;return{x:b.x+0.5*b.width-a,y:b.y-this.gripSize,width:2*a,height:2*this.gripSize}};this.draw=function(){if(!this.transparent){var a=this.horizontal?b.height:b.width,d=0.01*
-a*this.margin;this.horizontal?this.back.rectangle(b.x,b.y+d,b.width,a-2*d):this.back.rectangle(b.x+d,b.y,a-2*d,b.height)}if(this.onDrawThumb)this.onDrawThumb(this);this.thumbRect(f);this.invertThumb?(a=this.thumb,this.horizontal?(a.rectangle(b.x,b.y+d,f.x,b.height-2*d),a.rectangle(b.x+f.x+f.width,b.y+d,b.width,b.height-2*d)):(a.rectangle(b.x+d,b.y,b.width-2*d,f.y),a.rectangle(b.x+d,b.y+f.y+f.height,b.width-2*d,b.height))):this.thumb.rectangle(f);this.useRange&&this.horizontal&&(d=this.gripRect(f),
-this.grip.rectangle(d),d.x+=f.width,this.grip.rectangle(d))};this.clickAt=function(a){a=this.min+Math.max(0,(a+this.delta-(this.horizontal?b.x:b.y))*(this.max-this.min)/(this.horizontal?b.width:b.height));a>this.max&&(a=this.max);this.onChanging&&(a=this.onChanging(this,a));a<this.min?a=this.min:a>this.max&&(a=this.max);this.chart.newCursor=this.cursor;this.position!=a&&(this.position=a,this.chart.draw())};this.resized=function(){if(this.onChanging)this.onChanging(this,this.position);this.chart.draw();
-this.chart.newCursor="col-resize"};this.mousemove=function(a){var d=this.horizontal?b.width:b.height,c=this.horizontal?a.x:a.y,e=this.max-this.min;this.thumbRect(f);this.resizeBegin&&c<f.x+f.width?(a=this.thumbSize,c=f.x-c,this.thumbSize+=c,this.position-=0.5*(c*e/d),this.position<this.min&&(this.position=this.min,this.thumbSize=a),this.resized()):this.resizeEnd&&c>f.x?(c=f.x+f.width-c,this.thumbSize-=c,this.position-=0.5*(c*e/d),this.resized()):this.dragging?this.clickAt(c):(d=!1,this.useRange&&
-(e=this.gripRect(f),d=g(e,a),d||(e.x+=f.width,d=g(e,a))),d?this.chart.newCursor="col-resize":g(f,a)&&(this.chart.newCursor=this.cursor))};var d={x:0,y:0};this.mousedown=function(a){this.thumbRect(f);this.chart.calcMouse(a,d);a=this.gripRect(f);this.resizeBegin=this.useRange&&g(a,d);a.x+=f.width;this.resizeEnd=this.useRange&&!this.resizeBegin&&g(a,d);this.dragging=!this.resizeBegin&&!this.resizeEnd&&g(f,d);!this.resizeBegin&&!this.resizeEnd&&(this.dragging?this.delta=this.horizontal?f.x+0.5*f.width-
-d.x:f.y+0.5*f.height-d.y:g(b,d)&&(a=this.horizontal?0.5*f.width:0.5*f.height,this.delta=-a,this.clickAt(a+(this.horizontal?d.x:d.y))));return this.dragging||this.resizeBegin||this.resizeEnd};this.clicked=function(){var a=this.dragging||this.resizeBegin||this.resizeEnd;this.resizeBegin=this.resizeEnd=this.dragging=!1;this.delta=0;return a}};Tee.Slider.prototype=new Tee.Tool;Tee.Scroller=function(c,a){Tee.Chart.call(this,c);this.target=a;this.aspect.clip=!1;this.panel.transparent=!0;this.title.visible=
-!1;var g=this.scroller=new Tee.Slider(this);g.useRange=!0;g.thumbSize=100;var e=g.thumb;e.shadow.height=0;e.transparency=0.6;e.stroke.fill="black";e.shadow.visible=!1;g.horizontal=!0;var b=g.bounds;b.x=0;b.y=0;b.width=this.bounds.width;b.height=this.bounds.height;g.margin=0;g.lock=!1;this.tools.add(g);var f=this;a.ondraw=function(){g.lock||f.draw()};a.onscroll=function(){var a=this.axes.bottom,b=this.series,c=b.minXValue(),b=b.maxXValue(),e=a.maximum-a.minimum;a.minimum<c&&(a.minimum=c,a.maximum=
-a.minimum+e);a.maximum>b&&(a.maximum=b,a.minimum=a.maximum-e)};this.useRange=function(a){g.useRange=a;this.draw()};this.invertThumb=function(a){g.invertThumb=a;this.draw()};g.onChanging=function(b,c){var e=0.5*(b.thumbSize*(b.max-b.min)/b.bounds.width),g=a.series,n=g.minXValue(),g=g.maxXValue();c-e<n?c=n+e:c+e>g&&(c=g-e);a.axes.bottom.setMinMax(c-e,c+e);this.lock=!0;a.draw();this.lock=!1;if(f.onChanging)f.onChanging(f,c-e,c+e);return c};this.setBounds=function(a,c,e,f){this.bounds.x=a;this.bounds.y=
-c;this.bounds.width=e;this.bounds.height=f;b.x=a;b.y=c;b.width=e;b.height=f};g.onDrawThumb=function(b){function c(a,b){var d={mi:a.minimum,ma:a.maximum,sp:a.startPos,ep:a.endPos};e(a,b);return d}function e(a,b){a.minimum=b.mi;a.maximum=b.ma;a.startPos=b.sp;a.endPos=b.ep;a.scale=(b.ep-b.sp)/(b.ma-b.mi)}var m=a.chartRect,n=a.ctx;a.chartRect=g.bounds;a.ctx=g.chart.ctx;var j=g.bounds,i=a.series,k;b.min=i.minXValue();b.max=i.maxXValue();k=c(a.axes.bottom,{sp:j.x,ep:j.x+j.width,mi:b.min,ma:b.max});var j=
-c(a.axes.left,{sp:j.y,ep:j.y+j.height,mi:i.minYValue(),ma:i.maxYValue()}),i=0.5*(k.mi+k.ma),l=k.ma-k.mi;if(b.position!=i){b.thumbSize=l*b.bounds.width/(b.max-b.min);l*=0.5;if(f.onChanging)f.onChanging(f,i-l,i+l);b.position=i}a.series.each(function(a){a.visible&&a.useAxes&&a.draw()});e(a.axes.bottom,k);e(a.axes.left,j);a.chartRect=m;a.ctx=n}};Tee.Scroller.prototype=new Tee.Chart;Tee.SliderControl=function(c){c=new Tee.Chart(c);c.panel.transparent=!0;c.title.visible=!1;var a=new Tee.Slider(c);a.bounds.width=
-c.canvas.width-2*a.thumbSize;a.bounds.y=0.5*(c.canvas.height-a.bounds.height);c.tools.add(a);return a};Tee.CheckBox=function(c,a,g){Tee.Annotation.call(this,c);this.transparent=!0;this.text=a;this.checked=g||!0;this.margins.left=10;this.cursor="pointer";this.check=new Tee.Format(c);this.check.fill="white";this.draw=function(){Tee.Annotation.prototype.draw.call(this);var a=this.chart.ctx,b=this.position.x+2,a=0.6*this.bounds.height,c=this.position.y+0.4*(this.bounds.height-a);this.check.rectangle(b,
-c,a,a);this.checked&&(a=this.chart.ctx,a.beginPath(),a.moveTo(b+3,c+5),a.lineTo(b+4,c+8),a.lineTo(b+7,c+2),this.check.stroke.prepare(),a.stroke())};this.onclick=function(){this.checked=!this.checked;if(this.onchange)this.onchange(this);return!0}};Tee.CheckBox.prototype=new Tee.Annotation}).call(this);
+2],a[h-1])}};Tee.doHttpRequest=function(c,a,g,e){var b=p();b&&(b.onreadystatechange=function(){4==b.readyState&&(200===b.status||0===b.status?g(c,b.responseText):e&&e(b.status,b.statusText))},b.open("GET",a,!0),b.send(null))};Tee.Slider=function(c,a){function g(b,a){return a.x>=b.x&&a.x<=b.x+b.width&&a.y>=b.y&&a.y<=b.y+b.height}Tee.Tool.call(this,c);var e=this.thumb=new Tee.Format(c);e.round={x:4,y:4};e.stroke.size=0.5;e.gradient.visible=!0;e.gradient.direction="bottomtop";e.shadow.visible=!0;e=this.back=
+new Tee.Format(c);e.fill="white";e.gradient.visible=!0;e.stroke.fill="darkgrey";e.round={x:4,y:4};e=this.grip=new Tee.Format(c);e.round={x:4,y:4};e.stroke.fill="rgb(20,20,20)";this.gripSize=3;var b=this.bounds={x:10,y:10,width:200,height:20};this.transparent=!1;this.margin=16;this.min=0;this.max=100;this.position="undefined"==typeof a?50:a;this.useRange=!1;this.thumbSize=8;this.horizontal=!0;this.cursor="pointer";this.delta=0;this.thumbRect=function(h){var a=this.max-this.min,a=0<a?(this.position-
+this.min)/a:0;this.horizontal?(h.width=this.thumbSize,h.x=b.x+a*b.width-0.5*h.width,h.y=b.y,h.height=b.height):(h.height=this.thumbSize,h.y=b.y+a*b.height-0.5*h.height,h.x=b.x,h.width=b.width)};var f={};this.gripRect=function(b){if(this.horizontal){var a=0.2*b.height;return{x:b.x-this.gripSize,y:b.y+0.5*b.height-a,width:2*this.gripSize,height:2*a}}a=0.2*b.width;return{x:b.x+0.5*b.width-a,y:b.y-this.gripSize,width:2*a,height:2*this.gripSize}};this.draw=function(){var a=this.horizontal?b.height:b.width,
+d=0.01*a*this.margin;this.transparent||(this.horizontal?this.back.rectangle(b.x,b.y+d,b.width,a-2*d):this.back.rectangle(b.x+d,b.y,a-2*d,b.height));if(this.onDrawThumb)this.onDrawThumb(this);this.thumbRect(f);this.invertThumb?(a=this.thumb,this.horizontal?(a.rectangle(b.x,b.y+d,f.x,b.height-2*d),a.rectangle(b.x+f.x+f.width,b.y+d,b.width,b.height-2*d)):(a.rectangle(b.x+d,b.y,b.width-2*d,f.y),a.rectangle(b.x+d,b.y+f.y+f.height,b.width-2*d,b.height))):this.thumb.rectangle(f);this.useRange&&this.horizontal&&
+(d=this.gripRect(f),this.grip.rectangle(d),d.x+=f.width,this.grip.rectangle(d))};this.clickAt=function(a){a=this.min+Math.max(0,(a+this.delta-(this.horizontal?b.x:b.y))*(this.max-this.min)/(this.horizontal?b.width:b.height));a>this.max&&(a=this.max);if(this.onChanging){var d=this.onChanging(this,a);"undefined"!==typeof d&&(a=d)}a<this.min?a=this.min:a>this.max&&(a=this.max);this.chart.newCursor=this.cursor;this.position!=a&&(this.position=a,this.chart.draw())};this.resized=function(){if(this.onChanging)this.onChanging(this,
+this.position);this.chart.draw();this.chart.newCursor="col-resize"};this.mousemove=function(a){var d=this.horizontal?b.width:b.height,c=this.horizontal?a.x:a.y,e=this.max-this.min;this.thumbRect(f);this.resizeBegin&&c<f.x+f.width?(a=this.thumbSize,c=f.x-c,this.thumbSize+=c,this.position-=0.5*(c*e/d),this.position<this.min&&(this.position=this.min,this.thumbSize=a),this.resized()):this.resizeEnd&&c>f.x?(a=f.x+f.width-c,this.thumbSize-=a,this.position-=0.5*(a*e/d),this.resized()):this.dragging?this.clickAt(c):
+(d=!1,this.useRange&&(e=this.gripRect(f),d=g(e,a),d||(e.x+=f.width,d=g(e,a))),d?this.chart.newCursor="col-resize":g(f,a)&&(this.chart.newCursor=this.cursor))};var d={x:0,y:0};this.mousedown=function(a){this.thumbRect(f);this.chart.calcMouse(a,d);a=this.gripRect(f);this.resizeBegin=this.useRange&&g(a,d);a.x+=f.width;this.resizeEnd=this.useRange&&!this.resizeBegin&&g(a,d);this.dragging=!this.resizeBegin&&!this.resizeEnd&&g(f,d);!this.resizeBegin&&!this.resizeEnd&&(this.dragging?this.delta=this.horizontal?
+f.x+0.5*f.width-d.x:f.y+0.5*f.height-d.y:g(b,d)&&(a=this.horizontal?0.5*f.width:0.5*f.height,this.delta=-a,this.clickAt(a+(this.horizontal?d.x:d.y))));return this.dragging||this.resizeBegin||this.resizeEnd};this.clicked=function(){var a=this.dragging||this.resizeBegin||this.resizeEnd;this.resizeBegin=this.resizeEnd=this.dragging=!1;this.delta=0;return a};this.mouseout=function(){this.resizeBegin=this.resizeEnd=this.dragging=!1}};Tee.Slider.prototype=new Tee.Tool;Tee.Scroller=function(c,a){Tee.Chart.call(this,
+c);this.target=a;this.aspect.clip=!1;this.panel.transparent=!0;this.title.visible=!1;var g=this.scroller=new Tee.Slider(this);g.useRange=!0;g.thumbSize=100;var e=g.thumb;e.shadow.height=0;e.transparency=0.6;e.stroke.fill="black";e.shadow.visible=!1;g.horizontal=!0;var b=g.bounds;b.x=0;b.y=0;b.width=this.bounds.width;b.height=this.bounds.height;g.margin=0;g.lock=!1;this.tools.add(g);var f=this;a.ondraw=function(){g.lock||f.draw()};a.onscroll=function(){var a=this.axes.bottom,b=this.series,c=b.minXValue(),
+b=b.maxXValue(),f=a.maximum-a.minimum;a.minimum<c&&(a.minimum=c,a.maximum=a.minimum+f);a.maximum>b&&(a.maximum=b,a.minimum=a.maximum-f)};this.useRange=function(a){g.useRange=a;this.draw()};this.invertThumb=function(a){g.invertThumb=a;this.draw()};g.onChanging=function(b,c){var e=0.5*(b.thumbSize*(b.max-b.min)/b.bounds.width),g=a.series,n=g.minXValue(),g=g.maxXValue();c-e<n?c=n+e:c+e>g&&(c=g-e);a.axes.bottom.setMinMax(c-e,c+e);this.lock=!0;a.draw();this.lock=!1;if(f.onChanging)f.onChanging(f,c-e,c+
+e);return c};this.setBounds=function(a,c,e,f){this.bounds.x=a;this.bounds.y=c;this.bounds.width=e;this.bounds.height=f;b.x=a;b.y=c;b.width=e;b.height=f};g.onDrawThumb=function(b){function c(a,b){var d={mi:a.minimum,ma:a.maximum,sp:a.startPos,ep:a.endPos};e(a,b);return d}function e(a,b){a.minimum=b.mi;a.maximum=b.ma;a.startPos=b.sp;a.endPos=b.ep;a.scale=(b.ep-b.sp)/(b.ma-b.mi)}var m=a.chartRect,n=a.ctx;a.chartRect=g.bounds;a.ctx=g.chart.ctx;var j=g.bounds,i=a.series,k;b.min=i.minXValue();b.max=i.maxXValue();
+k=c(a.axes.bottom,{sp:j.x,ep:j.x+j.width,mi:b.min,ma:b.max});var j=c(a.axes.left,{sp:j.y,ep:j.y+j.height,mi:i.minYValue(),ma:i.maxYValue()}),i=0.5*(k.mi+k.ma),l=k.ma-k.mi;if(b.position!=i){b.thumbSize=l*b.bounds.width/(b.max-b.min);l*=0.5;if(f.onChanging)f.onChanging(f,i-l,i+l);b.position=i}a.series.each(function(a){a.visible&&a.useAxes&&a.draw()});e(a.axes.bottom,k);e(a.axes.left,j);a.chartRect=m;a.ctx=n}};Tee.Scroller.prototype=new Tee.Chart;Tee.SliderControl=function(c){c=new Tee.Chart(c);c.panel.transparent=
+!0;c.title.visible=!1;var a=new Tee.Slider(c);a.bounds.x=a.thumbSize+1;a.bounds.width=c.canvas.width-2*a.thumbSize-2;a.bounds.y=0.5*(c.canvas.height-a.bounds.height);c.tools.add(a);return a};Tee.CheckBox=function(c,a,g){Tee.Annotation.call(this,c);this.transparent=!0;this.text=a;this.checked=g||!0;this.margins.left=10;this.cursor="pointer";this.check=new Tee.Format(c);this.check.fill="white";this.draw=function(){Tee.Annotation.prototype.draw.call(this);var a=this.chart.ctx,b=this.position.x+2,c=0.6*
+this.bounds.height,d=this.position.y+0.4*(this.bounds.height-c);this.check.rectangle(b,d,c,c);this.checked&&(a.beginPath(),a.moveTo(b+3,d+5),a.lineTo(b+4,d+8),a.lineTo(b+7,d+2),this.check.stroke.prepare(),a.stroke())};this.onclick=function(){this.checked=!this.checked;if(this.onchange)this.onchange(this);return!0}};Tee.CheckBox.prototype=new Tee.Annotation}).call(this);
View
10 lib/teechart-gauges-min.js
@@ -1,7 +1,7 @@
/*
TeeChart(tm) for JavaScript(tm)
@fileOverview TeeChart for JavaScript(tm)
- v1.3 - October 2012
+ v1.4 - December 2012
Copyright(c) 2012 by Steema Software SL. All Rights Reserved.
http://www.steema.com
@@ -17,15 +17,15 @@ var B=this.ticksBack=new Tee.Format(this.chart);B.stroke.fill="";B.fill="black";
C.radius=0;this.hands=[];this.addHand=function(){var b=new Tee.Format(this.chart);b.size=6;b.length=60;b.back=20;b.gradient.visible=!0;b.gradient.colors[0]="orange";b.shadow.visible=!0;b.shadow.blur=12;b.shadow.color="black";b.stroke.fill="";b.pointer=!0;b.shape="needle";b.visible=!0;this.hands.push(b);return b};var R=this.hand=this.addHand(),H=this.back=new Tee.Format(this.chart);H.fill="black";H.visible=!0;H.gradient.visible=!0;H.gradient.colors=["black","gray"];H.stroke.fill="";var D=this.pointer=
new Tee.Format(this.chart);D.size=3;D.fill="black";D.stroke.fill="";D.visible=!0;var s=this.marks,j=s.format;s.location={x:0,y:10};s.visible=!0;j.fill="black";j.font.fill="white";j.gradient.visible=!0;j.gradient.colors=["gray","black"];j.shadow.visible=!0;j.shadow.blur=8;j.shadow.color="black";var d=this.format;d.visible=!0;d.gradient.visible=!0;d.gradient.colors=["white","black","white"];d.shadow.visible=!0;d.font.style="12px Verdana";d.font.fill="white";d.font.visible=!0;d.size=14;d.round={x:6,
y:6};d.padding=0.5;this.units=new Tee.Annotation(this.chart);this.units.transparent=!0;this.units.format.font.fill="orange";this.units.location={x:0,y:24};this.bounds=this.getRect();this.hover.enabled=!0;var I,P,v=this;this.animate=new Tee.Animation(this.chart,function(b){v.value=I+b*(P-I);v.chart.draw()});this.animate.duration=100;this.animate.onstop=function(){v.value=P;if(v.onchange)v.onchange(v);v.chart.draw()};var K,t,J,O,q,w,z,A,L,M;this.calcBounds=function(){return this.bounds.custom?this.bounds:
-this.cellRect(this.bounds,!0)};this.draw=function(){function b(b,c,e,d,g){0<b.radius&&(e=0.01*m*b.radius);a.beginPath();a.arc(0,0,c,d,g,!1);a.arc(0,0,e,g,d,!0);b.draw(a,null,-e,-e,2*e,2*e)}function n(a,c,e){if(a.visible&&""!=a.fill)if(a.ranges&&0<a.ranges.length){var d=l,g,h=a.fill,i=a.gradient.visible,x=k.max-k.min,j=w-q;a.gradient.visible=!1;k.inverted&&(d+=j);for(var f=0;f<a.ranges.length;f++){var m=Math.min(k.max,a.ranges[f].value);g=0==f?m:m-a.ranges[f-1].value+k.min;g=k.inverted?d-j*(g-k.min)/
+this.cellRect(this.bounds,!0)};this.draw=function(){function b(b,c,e,d,g){0<b.radius&&(e=0.01*m*b.radius);a.beginPath();a.arc(0,0,c,d,g,!1);a.arc(0,0,e,g,d,!0);b.draw(a,null,-e,-e,2*e,2*e)}function n(a,c,e){if(a.visible&&""!==a.fill)if(a.ranges&&0<a.ranges.length){var d=l,g,h=a.fill,i=a.gradient.visible,x=k.max-k.min,j=w-q;a.gradient.visible=!1;k.inverted&&(d+=j);for(var f=0;f<a.ranges.length;f++){var m=Math.min(k.max,a.ranges[f].value);g=0===f?m:m-a.ranges[f-1].value+k.min;g=k.inverted?d-j*(g-k.min)/
x:d+j*(g-k.min)/x;a.fill=a.ranges[f].fill;""!==a.fill&&(k.inverted?b(a,c,e,g,d):b(a,c,e,d,g));d=g;if(m>=k.max)break}a.fill=h;a.gradient.visible=i}else b(a,c,e,l,l+(w-q))}function h(b){if(b.visible)if("circle"==k.shape)b.ellipse(z,A,e,g);else if("segment"==k.shape){a.beginPath();var c=k.units.visible?275:240,d=l+0.01745*k.rotation+0.5*(6.283-0.01745*Math.max(c,k.angle)),h=0.5*e,i=0.5*g;a.arc(z,A,h,d,d+Math.max(0.01745*c,x),!1);a.closePath();b.draw(a,null,z-h,A-i,e,g)}else b.rectangle(z-0.5*e,A-0.5*
g,e,g);return b.visible}var x=0.01745*this.angle,c=this.calcBounds(),e,g;z=c.x+0.5*c.width;A=c.y+0.5*c.height;this.bounds.custom?(e=c.width,g=c.height):g=e=Math.min(c.width,c.height);var k=this,a=k.chart.ctx,l=1.57,m=e;for(q=0.01745*k.rotation+0.5*(6.283-x);6.283<=q;)q-=6.283;for(w=q+x;6.283<=w;)w-=6.283;this.drawHand=function(b){b.value=this.limitValue(b.value);var c=0.01745*this.rotation+0.5*(9.4248-x)+x*((this.inverted?this.max-b.value:b.value)-this.min)/j;L=z+0.0050*e*i.location.x;M=A+0.0050*
g*i.location.y;a.save();a.translate(L,M);a.rotate(c);var c=b.size,d=0.0050*m*b.back,h=Math.min(c,6),f=0.0050*m*b.length;a.beginPath();1<c?(a.moveTo(-d+h,-c),"needle"==b.shape?(a.quadraticCurveTo(-d,-c,-d,-c+h),a.lineTo(-d,c-h),a.quadraticCurveTo(-d,c,-d+h,c),a.lineTo(f,0)):(a.lineTo(-d+h,c),a.lineTo(f,c),a.lineTo(f,-c)),a.closePath()):(a.moveTo(-d,0),a.lineTo(f,0));1<c?b.draw(a,null,-d,-c,d+f,2*c):(b.stroke.prepare(),a.strokeStyle=b.fill,a.stroke());if(this.ondrawHand)this.ondrawHand(this,b);b.pointer&&
-D.visible&&D.ellipse(0.5*(J+t),0,D.size,D.size);a.restore()};h(d)&&(e*=1-0.01*d.size,g*=1-0.01*d.size,this.bounds.custom||(m=g=e));h(this.bevel)&&(e*=1-0.0020*d.size,g*=1-0.0020*d.size,this.bounds.custom||(m=g=e));h(H);var p=r.outside,c=this.min,j=this.max-this.min,y=this.step;0==y&&(y=j/20);y=Math.max(0.1,y);t=p?0.48*m:0.41*m;K=t-m*0.01*r.length;O=p?0.39*m:this.rotateText?0.46*m:0.48*m;J=p?0.45*m:0.38*m;d.font.prepare();var v=d.textHeight("Wj"),v=Math.max(1,j/y/(m*x/6.283/v)|0);a.fillStyle=d.font.fill;
+D.visible&&D.ellipse(0.5*(J+t),0,D.size,D.size);a.restore()};h(d)&&(e*=1-0.01*d.size,g*=1-0.01*d.size,this.bounds.custom||(m=g=e));h(this.bevel)&&(e*=1-0.0020*d.size,g*=1-0.0020*d.size,this.bounds.custom||(m=g=e));h(H);var p=r.outside,c=this.min,j=this.max-this.min,y=this.step;0===y&&(y=j/20);y=Math.max(0.1,y);t=p?0.48*m:0.41*m;K=t-m*0.01*r.length;O=p?0.39*m:this.rotateText?0.46*m:0.48*m;J=p?0.45*m:0.38*m;d.font.prepare();var v=d.textHeight("Wj"),v=Math.max(1,j/y/(m*x/6.283/v)|0);a.fillStyle=d.font.fill;
a.save();var E=z,F=A;k.bounds.custom&&(e>g?F+=0.75*g*g/e:E+=0.75*e*e/g);a.translate(E,F);a.rotate(q);n(B,K,t);n(C,J,t);var E=y*x/j/f.count,F=q,G=this.rotateText?0:0.3*d.textHeight("Wj"),I=0;for(!r.visible&&p&&(O=0.9*J);c<=this.max;){r.visible&&(p=(this.hover.enabled&&this.hover.valid?Math.abs(c-this.hover.value)<0.2*y?this.hover:null:null)||r,a.beginPath(),a.moveTo(0,K),r.triangle?(a.lineTo(-3,t),a.lineTo(3,t),a.closePath(),p.draw(a,-3,K,3,t)):(a.lineTo(0,t),p.stroke.prepare(),a.stroke()));if(d.font.visible&&
-0==I%v&&(360!=this.angle||c+y<=this.max)){p=O-d.textHeight()*d.padding;a.translate(0,p);var N=this.rotateText?3.1416:F;a.rotate(-N);d.font.prepare();a.fillStyle=d.font.fill;var u=k.inverted?this.max-c:c,u=k.ongetText?k.ongetText(u):(u|0)==u?u.toFixed(0):u.toFixed(this.decimals);a.fillText(u,0,G);a.rotate(N);a.translate(0,-p)}if(f.visible){if(c<this.max)for(p=0;p<f.count;p++)if(a.rotate(E),p<f.count-1){u=y/f.count;N=c+(p+1)*u;u=(this.hover.enabled&&this.hover.valid?Math.abs(N-this.hover.value)<0.2*
+0===I%v&&(360!=this.angle||c+y<=this.max)){p=O-d.textHeight()*d.padding;a.translate(0,p);var N=this.rotateText?3.1416:F;a.rotate(-N);d.font.prepare();a.fillStyle=d.font.fill;var u=k.inverted?this.max-c:c,u=k.ongetText?k.ongetText(u):(u|0)==u?u.toFixed(0):u.toFixed(this.decimals);a.fillText(u,0,G);a.rotate(N);a.translate(0,-p)}if(f.visible){if(c<this.max)for(p=0;p<f.count;p++)if(a.rotate(E),p<f.count-1){u=y/f.count;N=c+(p+1)*u;u=(this.hover.enabled&&this.hover.valid?Math.abs(N-this.hover.value)<0.2*
u?this.hover:null:null)||f;if(N>this.max)break;"ellipse"==f.shape?f.ellipse(0,0.5*(J+t),f.size,f.size):(a.beginPath(),a.moveTo(0,J),a.lineTo(0,t),u.stroke.prepare(),a.stroke())}}else a.rotate(E*f.count);F+=E*f.count;c+=y;I++}a.restore();s.visible&&(s.text=this.value.toFixed(this.decimals),s.resize(),s.position.x=z-0.5*s.bounds.width+0.01*s.location.x*e,s.position.y=A+0.01*s.location.y*g,s.draw());c=this.units;c.visible&&(c.resize(),c.position.x=z-0.5*c.bounds.width+0.01*c.location.x*e,c.position.y=
A+0.01*c.location.y*g,c.draw(a));a.save();R.value=this.value;for(c=0;c<this.hands.length;c++)this.hands[c].visible&&this.drawHand(this.hands[c]);a.restore();i.visible&&(c=0.01*m*i.size,i.ellipse(L,M,c,c),i.top.visible&&(c=0.01*c*i.top.size,i.top.ellipse(L,M,c,c)))};this.limitValue=function(b){return Math.min(this.max,Math.max(this.min,b))};this.setValue=function(b){var b=this.limitValue(b),d=this.value!=b;if(d)if(this.animate.active&&0<this.animate.duration)I=this.value,P=b,this.animate.animate(this.chart);
else if(this.value=b,this.onchange)this.onchange(this);return d};this.onclick=function(){};this.clicked=function(){this.dragging=!1;return-1};this.inValue=function(b,d){if(!d.contains(b))return!1;for(var h=b.x-L,f=b.y-M,c=Math.sqrt(h*h+f*f),h=Math.atan2(f,h)-0.5*Math.PI;0>h;)h+=6.283;var e,g;q>w?(f=w,e=q,g=h>=e||h<=f):(e=w,f=q,g=h>=f&&h<=e);return g?(h=this.min+(this.max-this.min)*(q>w?h>e?(h-e)/(6.283-e+f):(6.283-e+h)/(6.283-e+f):(h-f)/(e-f)),this.inverted&&(h=this.max-h),b.value=h,b.inTicks=c>=
Math.min(K,O)&&c<=t,!0):b.inTicks=!1};this.mousemove=function(b){var d=this.calcBounds(),d=this.inValue(b,d);this.dragging?(d&&this.setValue(b.value)&&this.chart.draw(),this.chart.newCursor="pointer"):b.inTicks&&this.drag.enabled?(G(this,b.value),this.chart.newCursor="pointer"):G(this,null)};var Q={x:0,y:0};this.mousedown=function(b){if(this.drag.enabled){var d=this.calcBounds();this.chart.calcMouse(b,Q);this.inValue(Q,d)?(this.dragging=!0,this.hover.value=null,this.hover.valid=!1,this.setValue(Q.value)&&
-this.chart.draw()):this.dragging=!1;return this.dragging}return!1}};Tee.CircularGauge.prototype=new Tee.Series;Tee.CircularGauge.prototype.setChart=function(n,l){var G=Tee.Series.prototype.setChart;G(n,l);n.back.setChart(l);n.center.setChart(l);n.center.top.setChart(l);n.ticks.setChart(l);n.ticksBack.setChart(l);n.minor.setChart(l);n.minorBack.setChart(l);n.hand.setChart(l);n.units.format.setChart(l);n.pointer.setChart(l);n.bevel.setChart(l)}})();
+this.chart.draw()):this.dragging=!1;return this.dragging}return!1}};Tee.CircularGauge.prototype=new Tee.Series;Tee.CircularGauge.prototype.setChart=function(n,l){var G=Tee.Series.prototype.setChart;G(n,l);n.back.setChart(l);n.center.setChart(l);n.center.top.setChart(l);n.ticks.setChart(l);n.ticksBack.setChart(l);n.minor.setChart(l);n.minorBack.setChart(l);n.hand.setChart(l);n.units.setChart(l);n.pointer.setChart(l);n.bevel.setChart(l)}})();
View
389 lib/teechart-maps-min.js
196 additions, 193 deletions not shown
View
345 lib/teechart-min.js
186 additions, 159 deletions not shown
View
1,151 lib/teechart-table.js
@@ -1,564 +1,587 @@
-// -------------------------------------------------------------
-// TeeChart(tm) for JavaScript(tm)
-// v1.0 ALPHA - February 2012
-// Copyright(c) 2012 by Steema Software SL. All Rights Reserved.
-// www.steema.com
-//
-// JavaScript is a trademark of Oracle Corporation.
-// -------------------------------------------------------------
-
-"use strict";
-
-var Tee = Tee || {};
-
-function isNumeric(v) {
- return parseFloat(v)==v;
-}
-
-Tee.Chart.prototype.fromTable=function(table, style, cols, header, labels) {
-
- function setTitleFooter(chart,cell) {
- if (cell)
- if (chart.title.text=="")
- chart.title.text=cell.textContent;
- else
- chart.footer.text=cell.textContent;
- }
-
- var h, st, c, r, l, row, col, cell,
- ta=(table instanceof HTMLTableElement) ? table : document.getElementById(table);
-
- if (ta) {
- if (header==null) header=-1;
- if (labels==null) labels=-1;
-
- this.series.items=[];
-
- if (cols) {
-
- if (header>-1) {
- h=ta.rows[header];
-
- if (h) {
- for (c=labels+1; cell=h.cells[c]; c++) {
- this.addSeries(new style()).title= cell ? cell.textContent : "Series "+c.toFixed(0);
- }
-
- if (labels>-1) setTitleFooter(this,h.cells[labels]);
- }
- }
- else
- {
- h=ta.rows[0];
-
- if (h) {
- for (c=labels+1; cell=h.cells[c]; c++) {
- this.addSeries(new style()).title= "Series "+c.toFixed(0);
- }
- }
- }
-
- for (r=header+1; row = ta.rows[r]; r++) {
- if (row) {
- for (c=labels+1; col = row.cells[c]; c++) {
-
- st=(col.textContent==="") ? null : parseFloat(col.textContent);
- this.series.items[c-labels-1].data.values.push(st);
- }
-
- if (labels>-1) {
- l=row.cells[labels].textContent;
- this.series.each(function(s) { s.data.labels.push(l); } );
- }
- }
- }
- }
- else
- {
- for (r=header+1; row = ta.rows[r]; r++) {
- if (row)
- for (c=labels; col = row.cells[c]; c++) {
- if (c==labels) {
- this.addSeries(new style()).title= col ? col.textContent : "Series "+r.toFixed(0);
- }
- else {
- st=(col.textContent==="") ? null : parseFloat(col.textContent);
- this.series.items[r-header-1].data.values.push(st);
- }
- }
- }
-
- if (header>-1) {
- row=ta.rows[header];
-
- for (c=labels+1; col = row.cells[c]; c++)
- this.series.each(function(s) { s.data.labels.push(col.textContent); });
-
- if (labels>-1)
- setTitleFooter(this,row.cells[labels]);
- }
- }
-
- this.draw();
- }
-}
-
-Tee.Table=function(table,chart) {
-
- var _refresh=null;
-
- this.header=0;
- this.firstCol=0;
- this.byCols=true;
-
- var ta=(table instanceof HTMLTableElement) ? table : document.getElementById(table);
-
- this.table=ta;
-
- function enableColResize() {
- if (table) {
- var row = tb.getElementsByTagName('tr')[0];
- if (row) {
- cols = row.getElementsByTagName('td');
- if(!cols || cols.length==0)
- cols = row.getElementsByTagName('th');
-
- if (cols) {
- for(var i=0;i<cols.length;i++)
- {
- var a=document.createElement('div');
- a.className='arrow-down';
- cols[i].appendChild(a);
- }
- }
- }
- }
- }
-
- function getStyle(x,styleProp)
- {
- if (x.currentStyle)
- return x.currentStyle[styleProp];
- else
- if (window.getComputedStyle)
- return document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
- else
- return "";
- }
-
- this.changeCell=function(cell) {
- if (!(cell instanceof HTMLTableCellElement))
- cell=this;
-
- var s=cell.textContent, l=Math.max(s.length,5);
-
- cell.onclick=null;
-
- var i=document.createElement('input');
- i.type="text";
- i.style.width=cell.clientWidth+"px";
-
- i.onchange=changeValue;
- i.onkeydown=keyDown;
- i.onblur=changeValue;
- i.value=cell.innerHTML;
-
- i.className='inline-editor';
-
- cell.innerHTML="";
- cell.appendChild(i);
-
- cell.firstChild.focus();
- }
-
- var _table=this;
-
- function keyDown(e) {
- var key, text=this;
- if (window.event)
- key = window.event.keyCode;
- else if (e)
- key = e.which;
- else
- return true;
-
- var c=text.parentNode,
- r=c.parentNode,
- tbl=r.parentNode;
-
- if (key==27) // escape
- changeValue(text);
- else
- if (key==13) {
- changeValue(text);
- }
- if (key==9) { // tab
- if (e && e.shiftKey) {
- if (c.cellIndex>_table.firstCol) {
- changeValue(text);
- _table.changeCell(tbl.rows[r.rowIndex].cells[c.cellIndex-1]);
- }
- else
- if (r.rowIndex>1) {
- changeValue(text);
- _table.changeCell(tbl.rows[r.rowIndex-1].cells[r.cells.length-1]);
- }
- }
- else
- {
- if (c.cellIndex<(r.cells.length-1)) {
- changeValue(text);
- _table.changeCell(tbl.rows[r.rowIndex].cells[c.cellIndex+1]);
- }
- else
- if (r.rowIndex<(tbl.rows.length-1)) {
- changeValue(text);
- _table.changeCell(tbl.rows[r.rowIndex+1].cells[1]);
- }
- }
- return false;
- }
- else
- if (key==40) { // arrow down
- if (r.rowIndex<(tbl.rows.length-1)) {
- changeValue(text);
- _table.changeCell(tbl.rows[r.rowIndex+1].cells[c.cellIndex]);
- }
- }
- else
- if (key==38) { // arrow up
- if (r.rowIndex>_table.header) {
- changeValue(text);
- _table.changeCell(tbl.rows[r.rowIndex-1].cells[c.cellIndex]);
- }
- }
-
- return true;
- }
-
- function changeValue(text) {
- if (this instanceof HTMLInputElement)
- text=this;
-
- if (text.onchange) {
- text.onchange=null;
-
- var cell=text.parentNode;
-
- if (cell) {
- cell.innerHTML= text.value;
- cell.onclick= _table.changeCell;
-
- if (_refresh) _refresh(cell);
- }
-
- }
- }
-
- this.enableRowHighlight=function(color,panel) {
- if (typeof panel=="string")
- panel = document.getElementById(panel);
-
- if (ta)
- for (var t=0; t<ta.rows.length; t++) {
- ta.rows[t].onmouseover=function() {
- this.style.backgroundColor=color;
-
- if (panel)
- panel.style.visibility='visible';
- }
-
- ta.rows[t].onmouseout=function() {
- this.style.backgroundColor='#FFFFFF';
-
- if (panel)
- panel.style.visibility='hidden';
- }
- }
- }
-
- function refreshCell(cell) {
- var byCols=_table.byCols,
- ser, row, index, s=cell.innerHTML;
-
- if (byCols) {
- row=cell.parentNode.rowIndex;
- index=cell.cellIndex;
- }
- else
- {
- row=cell.cellIndex;
- index=cell.parentNode.rowIndex;
- }
-
- if (row==1) {// header row
- if (index==1) { // title
- if (s!=chart.footer.text) {
- chart.footer.text=s;
- chart.draw();
- }
- }
- else {
- ser=chart.series.items[index-2];
- if (s!=ser.title) {
- ser.title=s;
- chart.draw();
- }
- }
- }
- else
- {
- row-=2;
-
- if (index==1) { // labels
- ser=chart.series.items[0];
- if (s!=ser.data.labels[row]) {
- chart.series.each(function(s1) {
- s1.data.labels[row]=s;
- });
-
- chart.draw();
- }
- }
- else {
- ser=chart.series.items[index-2];
- var n=parseFloat(s);
-
- if (n!=ser.data.values[row]) {
- ser.data.values[row]=n;
- chart.draw();
- }
- }
- }
- }
-
- this.enableEditing=function(enable, refresh) {
-
- _refresh=refresh || refreshCell;
-
- if (ta)
- for (var r=0, row; row = ta.rows[r]; r++)
- if (row)
- for (var c=0, col; col = row.cells[c]; c++)
- if (col)
- col.onclick= enable ? this.changeCell : null;
- }
-
- // TODO: replace cell.className
- function dohoverCell(cell,active) {
- if (active) {
- cell.style.backgroundColor='gold';
- cell.style.color='white';
- }
- else
- {
- cell.style.backgroundColor='';
- cell.style.color='';
- }
- }
-
- this.pointToCell=function(series,index) {
- var s=series.chart.series.items.indexOf(series)+2;
-
- if (_table.byCols)
- return ta.rows[index+2].cells[s];
- else
- return ta.rows[s].cells[index+2];
- }
-
- this.hoverCell=function(series,index) {
- if (series.over!=-1)
- dohoverCell(_table.pointToCell(series,series.over),false);
-
- if (index!=-1)
- dohoverCell(_table.pointToCell(series,index),true);
- }
-
- function orderToIndex(i) {
- var n=-1;
-
- for (var t=0; t<chart.series.count(); t++) {
- if (chart.series.items[t].visible) {
- n++;
- if (n==i) return t;
- }
- }
-
- return -1;
- }
-
- this.legendHover=function(old,index) {
- var tbl=ta, bycols=_table.byCols, pos=1, c=chart;
-
- if (c.legend.showValues()) {
- var s=c.series.firstVisible();
- pos=2+c.series.items.indexOf(s);
- bycols=!bycols;
- }
-
- // non-visible series --> index old ??
-
- if (bycols) {
- if (old!=-1)
- dohoverCell(ta.rows[pos].cells[orderToIndex(old)+2],false);
- if (index!=-1)
- dohoverCell(ta.rows[pos].cells[orderToIndex(index)+2],true);
- }
- else
- {
- if (old!=-1)
- dohoverCell(ta.rows[old+2].cells[pos],false);
- if (index!=-1)
- dohoverCell(ta.rows[index+2].cells[pos],true);
- }
- }
-
-}
-
-function parseText(data,text) {
- data.values=[];
- data.labels=[];
-
- var v=text.split("\n"), len=v.length;
-
- if (len>0) {
- for(var t=0; t<len; t++) {
- var s=v[t], fields=s.split(","), anyNumber=false;
-
- for(var f=0; f<fields.length; f++)
- {
- s=parseFloat(fields[f]);
- if (s && (!isNaN(s))) {
- anyNumber=true;
- break;
- }
- }
-
- if (anyNumber) {
- if (fields.length==1) {
- s=parseFloat(s);
- if (isNaN(s)) s=0;
- }
- else
- if (fields.length==2) {
- s=parseFloat(fields[0]);
- if (isNaN(s)) s=0;
- data.labels[t]=fields[1];
- }
- else
- if (fields.length==3) {
- s=parseFloat(fields[1]);
- if (isNaN(s)) s=0;
-
- data.labels[t]=fields[2];
- }
-
- data.values[t]=s;
- }
- else
- data.values[t]=0;
-
- }
- }
-}
-
-function loadXML(xml)
-{
- if (window.DOMParser)
- return new DOMParser().parseFromString(xml,"text/xml");
- else // Internet Explorer
- {
- xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
- xmlDoc.async=false;
- xmlDoc.loadXML(xml);
- return xmlDoc;
- }
-}
-
-Tee.Series.prototype.loadXML=function(xml) {
- this.data.xml=xml;
- this.refresh();
-}
-
-function parseXML(series,xml,seriesTag,pointTag) {
- var data=series.data;
- data.values=[];
- data.labels=[];
-
- seriesTag=seriesTag || "series";
-
- var doc=loadXML(xml.value), n;
-
- var s = doc.getElementsByTagName(seriesTag)[0];
- if (s) {
- n= s.getAttribute("color");
- if (n) series.color=n;
-
- n= s.getAttribute("name");
- if (n) series.title=n;
-
- n= s.getAttribute("metric");
- if (n) data.title=n;
-
- pointTag=pointTag || "point";
-
- var points= s.getElementsByTagName(pointTag);
- if (points) {
- for (var t = 0; t < points.length; t++) {
- n = points[t].getAttribute("name");
- if (n) data.labels.push(n);
-
- n = points[t].getAttribute("value");
- data.values.push(parseFloat(n));
-
- n = points[t].getAttribute("x");
- if (n)
- data.x.push(parseFloat(n));
- }
- }
- }
-}
-
-Tee.Series.prototype.loadJSON=function(json) {
- this.data.json=json;
- this.refresh();
-}
-
-function parseJSON(series,json,seriesTag,pointTag) {
- var data=series.data;
- data.values=[];
- data.labels=[];
-
- seriesTag=seriesTag || "series";
-
- var o=JSON.parse(json.value);
- if (o.series) {
- if (o.series.name!="") series.title=o.series.name;
- if (o.series.color!="") series.color=o.series.color;
- if (o.series.metric!="")
- {
- data.title=o.series.metric;
-
- var tmp=series.mandatoryAxis.title;
- if (tmp.text=="") tmp.text=data.title;
- }
-
- if (o.series.category!="")
- {
- var tmp=series.notmandatory.title;
- if (tmp.text=="") tmp.text=data.title;
- }
-
- var p=o.series.point;
- if (p) {
- for(var t=0; t<p.length; t++) {
- data.values.push(p[t].value);
- data.labels.push(p[t].name);
-
- if (p[t].color && (p[t].color!==''))
- series.palette.colors.push(p[t].color);
- }
- }
- }
-}
-
+// -------------------------------------------------------------
+// TeeChart(tm) for JavaScript(tm)
+// v1.4 - December 2012
+// Copyright(c) 2012 by Steema Software SL. All Rights Reserved.
+// www.steema.com
+//
+// JavaScript is a trademark of Oracle Corporation.
+// -------------------------------------------------------------
+
+"use strict";
+
+var Tee = Tee || {};
+
+function isNumeric(v) {
+ return parseFloat(v)==v;
+}
+
+function cellText(cell) {
+ return cell.textContent || cell.innerText; // IE
+}
+
+Tee.Chart.prototype.fromTable=function(table, style, cols, header, labels) {
+
+ function setTitleFooter(chart,cell) {
+ if (cell) {
+
+ var tmp = cellText(cell);
+
+ if (chart.title.text==="")
+ chart.title.text=tmp;
+ else
+ chart.footer.text=tmp;
+ }
+ }
+
+ var h, st, c, r, l, row, col, cell,
+ ta=(table instanceof HTMLTableElement) ? table : document.getElementById(table);
+
+ if (ta) {
+ if (header===null) header=-1;
+ if (labels===null) labels=-1;
+
+ this.series.items=[];
+
+ if (cols) {
+
+ if (header>-1) {
+ h=ta.rows[header];
+
+ if (h) {
+ for (c=labels+1; cell=h.cells[c]; c++) {
+ this.addSeries(new style()).title= cell ? cellText(cell) : "Series "+c.toFixed(0);
+ }
+
+ if (labels>-1) setTitleFooter(this,h.cells[labels]);
+ }
+ }
+ else
+ {
+ h=ta.rows[0];
+
+ if (h) {
+ for (c=labels+1; cell=h.cells[c]; c++) {
+ this.addSeries(new style()).title= "Series "+c.toFixed(0);
+ }
+ }
+ }
+
+ for (r=header+1; row = ta.rows[r]; r++) {
+ if (row) {
+ for (c=labels+1; col = row.cells[c]; c++) {
+
+ st = ( cellText(col)==="" ) ? null : parseFloat( cellText(col) );
+ this.series.items[c-labels-1].data.values.push(st);
+ }
+
+ if (labels>-1) {
+ l = cellText(row.cells[labels]);
+ this.series.each(function(s) { s.data.labels.push(l); } );
+ }
+ }
+ }
+ }
+ else
+ {
+ for (r=header+1; row = ta.rows[r]; r++) {
+ if (row)
+ for (c=labels; col = row.cells[c]; c++) {
+ if (c==labels) {
+ this.addSeries(new style()).title= col ? cellText(col) : "Series "+r.toFixed(0);
+ }
+ else {
+ st = ( cellText(col) === "") ? null : parseFloat( cellText(col) );
+ this.series.items[r-header-1].data.values.push(st);
+ }
+ }
+ }
+
+ if (header>-1) {
+ row=ta.rows[header];
+
+ for (c=labels+1; col = row.cells[c]; c++)
+ this.series.each(function(s) { s.data.labels.push( cellText(col) ); });
+
+ if (labels>-1)
+ setTitleFooter(this,row.cells[labels]);
+ }
+ }
+
+ this.draw();
+ }
+}
+
+Tee.Table=function(table,chart) {
+
+ var _refresh=null;
+
+ this.header=0;
+ this.firstCol=0;
+ this.byCols=true;
+
+ var ta=(table instanceof HTMLTableElement) ? table : document.getElementById(table);
+
+ this.table=ta;
+
+ function enableColResize() {
+ if (table) {
+ var row = tb.getElementsByTagName('tr')[0];
+ if (row) {
+ cols = row.getElementsByTagName('td');
+ if(!cols || cols.length==0)
+ cols = row.getElementsByTagName('th');
+
+ if (cols) {
+ for(var i=0;i<cols.length;i++)
+ {
+ var a=document.createElement('div');
+ a.className='arrow-down';
+ cols[i].appendChild(a);
+ }
+ }
+ }
+ }
+ }
+
+ function getStyle(x,styleProp)
+ {
+ if (x.currentStyle)
+ return x.currentStyle[styleProp];
+ else
+ if (window.getComputedStyle)
+ return document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
+ else
+ return "";
+ }
+
+ this.changeCell=function(cell) {
+ if (!(cell instanceof HTMLTableCellElement))
+ cell=this;
+
+ var s= cellText(cell), l=Math.max(s.length,5);
+
+ cell.onclick=null;
+
+ var i=document.createElement('input');
+ i.type="text";
+ i.style.width=cell.clientWidth+"px";
+
+ i.onchange=changeValue;
+ i.onkeydown=keyDown;
+ i.onblur=changeValue;
+ i.value=cell.innerHTML;
+
+ i.className='inline-editor';
+
+ cell.innerHTML="";
+ cell.appendChild(i);
+
+ cell.firstChild.focus();
+ }
+
+ var _table=this;
+
+ function keyDown(e) {
+ var key, text=this;
+ if (window.event)
+ key = window.event.keyCode;
+ else if (e)
+ key = e.which;
+ else
+ return true;
+
+ var c=text.parentNode,
+ r=c.parentNode,
+ tbl=r.parentNode;
+
+ if (key==27) // escape
+ changeValue(text);
+ else
+ if (key==13) {
+ changeValue(text);
+ }
+ if (key==9) { // tab
+ if (e && e.shiftKey) {
+ if (c.cellIndex>_table.firstCol) {
+ changeValue(text);
+ _table.changeCell(tbl.rows[r.rowIndex].cells[c.cellIndex-1]);
+ }
+ else
+ if (r.rowIndex>1) {
+ changeValue(text);
+ _table.changeCell(tbl.rows[r.rowIndex-1].cells[r.cells.length-1]);
+ }
+ }
+ else
+ {
+ if (c.cellIndex<(r.cells.length-1)) {
+ changeValue(text);
+ _table.changeCell(tbl.rows[r.rowIndex].cells[c.cellIndex+1]);
+ }
+ else
+ if (r.rowIndex<(tbl.rows.length-1)) {
+ changeValue(text);
+ _table.changeCell(tbl.rows[r.rowIndex+1].cells[1]);
+ }
+ }
+ return false;
+ }
+ else
+ if (key==40) { // arrow down
+ if (r.rowIndex<(tbl.rows.length-1)) {
+ changeValue(text);
+ _table.changeCell(tbl.rows[r.rowIndex+1].cells[c.cellIndex]);
+ }
+ }
+ else
+ if (key==38) { // arrow up
+ if (r.rowIndex>_table.header) {
+ changeValue(text);
+ _table.changeCell(tbl.rows[r.rowIndex-1].cells[c.cellIndex]);
+ }
+ }
+
+ return true;
+ }
+
+ function changeValue(text) {
+ if (this instanceof HTMLInputElement)
+ text=this;
+
+ if (text.onchange) {
+ text.onchange=null;
+
+ var cell=text.parentNode;
+
+ if (cell) {
+ cell.innerHTML= text.value;
+ cell.onclick= _table.changeCell;
+
+ if (_refresh) _refresh(cell);
+ }
+
+ }
+ }
+
+ this.enableRowHighlight=function(color,panel) {
+ if (typeof panel=="string")
+ panel = document.getElementById(panel);
+
+ if (ta)
+ for (var t=0; t<ta.rows.length; t++) {
+ ta.rows[t].onmouseover=function() {
+ this.style.backgroundColor=color;
+
+ if (panel)
+ panel.style.visibility='visible';
+ }
+
+ ta.rows[t].onmouseout=function() {
+ this.style.backgroundColor='#FFFFFF';
+
+ if (panel)
+ panel.style.visibility='hidden';
+ }
+ }
+ }
+
+ function refreshCell(cell) {
+ var byCols=_table.byCols,
+ ser, row, index, s=cell.innerHTML;
+
+ if (byCols) {
+ row=cell.parentNode.rowIndex;
+ index=cell.cellIndex;
+ }
+ else
+ {
+ row=cell.cellIndex;
+ index=cell.parentNode.rowIndex;
+ }
+
+ if (row==1) {// header row
+ if (index==1) { // title
+ if (s!=chart.footer.text) {
+ chart.footer.text=s;
+ chart.draw();
+ }
+ }
+ else {
+ ser=chart.series.items[index-2];
+ if (s!=ser.title) {
+ ser.title=s;
+ chart.draw();
+ }
+ }
+ }
+ else
+ {
+ row-=2;
+
+ if (index==1) { // labels
+ ser=chart.series.items[0];
+ if (s!=ser.data.labels[row]) {
+ chart.series.each(function(s1) {
+ s1.data.labels[row]=s;
+ });
+
+ chart.draw();
+ }
+ }
+ else {
+ ser=chart.series.items[index-2];
+ var n=parseFloat(s);
+
+ if (n!=ser.data.values[row]) {
+ ser.data.values[row]=n;
+ chart.draw();
+ }
+ }
+ }
+ }
+
+ this.enableEditing=function(enable, refresh) {
+
+ _refresh=refresh || refreshCell;
+
+ if (ta)
+ for (var r=0, row; row = ta.rows[r]; r++)
+ if (row)
+ for (var c=0, col; col = row.cells[c]; c++)
+ if (col)
+ col.onclick= enable ? this.changeCell : null;
+ }
+
+ // TODO: replace cell.className
+ function dohoverCell(cell,active) {
+ if (active) {
+ cell.style.backgroundColor='gold';
+ cell.style.color='white';
+ }
+ else
+ {
+ cell.style.backgroundColor='';
+ cell.style.color='';
+ }
+ }
+
+ this.pointToCell=function(series,index) {
+ var s=series.chart.series.items.indexOf(series)+2;
+
+ if (_table.byCols)
+ return ta.rows[index+2].cells[s];
+ else
+ return ta.rows[s].cells[index+2];
+ }
+
+ this.hoverCell=function(series,index) {
+ if (series.over!=-1)
+ dohoverCell(_table.pointToCell(series,series.over),false);
+
+ if (index!=-1)
+ dohoverCell(_table.pointToCell(series,index),true);
+ }
+
+ function orderToIndex(i) {
+ var n=-1;
+
+ for (var t=0; t<chart.series.count(); t++) {
+ if (chart.series.items[t].visible) {
+ n++;
+ if (n==i) return t;
+ }
+ }
+
+ return -1;
+ }
+
+ this.legendHover=function(old,index) {
+ var tbl=ta, bycols=_table.byCols, pos=1, c=chart;
+
+ if (c.legend.showValues()) {
+ var s=c.series.firstVisible();
+ pos=2+c.series.items.indexOf(s);
+ bycols=!bycols;
+ }
+
+ // non-visible series --> index old ??
+
+ if (bycols) {
+ if (old!=-1)
+ dohoverCell(ta.rows[pos].cells[orderToIndex(old)+2],false);
+ if (index!=-1)
+ dohoverCell(ta.rows[pos].cells[orderToIndex(index)+2],true);
+ }
+ else
+ {
+ if (old!=-1)
+ dohoverCell(ta.rows[old+2].cells[pos],false);
+ if (index!=-1)
+ dohoverCell(ta.rows[index+2].cells[pos],true);
+ }
+ }
+
+}
+
+function parseText(data,text) {
+ data.values=[];
+ data.labels=[];
+
+ var v=text.split("\n"), len=v.length;
+
+ if (len>0) {
+ for(var t=0; t<len; t++) {
+ var s=v[t], fields=s.split(","), anyNumber=false;
+
+ for(var f=0; f<fields.length; f++)
+ {
+ s=parseFloat(fields[f]);
+ if (s && (!isNaN(s))) {
+ anyNumber=true;
+ break;
+ }
+ }
+
+ if (anyNumber) {
+ if (fields.length==1) {
+ s=parseFloat(s);
+ if (isNaN(s)) s=0;
+ }
+ else
+ if (fields.length==2) {
+ s=parseFloat(fields[0]);
+ if (isNaN(s)) s=0;
+ data.labels[t]=fields[1];
+ }
+ else
+ if (fields.length==3) {
+ s=parseFloat(fields[1]);
+ if (isNaN(s)) s=0;
+
+ data.labels[t]=fields[2];
+ }
+
+ data.values[t]=s;
+ }
+ else
+ data.values[t]=0;
+
+ }
+ }
+}
+
+function loadXML(xml)
+{
+ if (window.DOMParser)
+ return new DOMParser().parseFromString(xml,"text/xml");
+ else // Internet Explorer
+ {
+ xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
+ xmlDoc.async=false;
+ xmlDoc.loadXML(xml);
+ return xmlDoc;
+ }
+}
+
+Tee.Series.prototype.loadXML=function(xml) {
+ this.data.xml=xml;
+ this.refresh();
+}
+
+function parseXML(series,xml,seriesTag,pointTag) {
+ var data=series.data;
+ data.values=[];
+ data.labels=[];
+
+ seriesTag=seriesTag || "series";
+
+ var doc=loadXML(xml.value), n;
+
+ var s = doc.getElementsByTagName(seriesTag)[0];
+ if (s) {
+ n= s.getAttribute("color");
+ if (n) series.color=n;
+
+ n= s.getAttribute("name");
+ if (n) series.title=n;
+
+ n= s.getAttribute("metric");
+ if (n) data.title=n;
+
+ pointTag=pointTag || "point";
+
+ var points= s.getElementsByTagName(pointTag);
+ if (points) {
+ for (var t = 0; t < points.length; t++) {
+ n = points[t].getAttribute("name");
+ if (n) data.labels.push(n);
+
+ n = points[t].getAttribute("value");
+ data.values.push(parseFloat(n));
+
+ n = points[t].getAttribute("x");
+ if (n)
+ data.x.push(parseFloat(n));
+ }
+ }
+ }
+}
+
+Tee.Series.prototype.loadJSON=function(json) {
+ this.data.json=json;
+ this.refresh();
+}
+
+function parseJSON(series,json,seriesTag,pointTag) {
+ var data=series.data, tmp;
+ data.values=[];
+ data.labels=[];
+
+ seriesTag=seriesTag || "series";
+
+ var o=(typeof json.value === "string" ) ? JSON.parse(json.value) : json.value;
+
+ if (o.series) {
+ if (o.series.name!="") series.title=o.series.name;
+ if (o.series.color!="") series.format.fill=o.series.color;
+
+ if (o.series.metric!="")
+ {
+ data.title=o.series.metric;
+
+ tmp=series.mandatoryAxis.title;
+ if (tmp.text=="") tmp.text=data.title;
+ }
+
+ if (o.series.category!="")
+ {
+ tmp=series.notmandatory.title;
+ if (tmp.text=="") tmp.text=o.series.category;
+ }
+
+ var p=o.series.point, pp;
+
+ if (p) {
+ for(var t=0; t<p.length; t++) {
+
+ pp=p[t];
+
+ data.values.push(pp.value);
+
+ if (pp.name !== undefined)
+ data.labels[t]=pp.name;
+
+ if (pp.x !== undefined) {
+ if (!data.x) data.x=[];
+ data.x[t]=pp.x;
+ }
+
+ if (pp.color && (pp.color!=='')) {
+ if (!series.palette.colors) series.palette.colors=[];
+ series.palette.colors[t]=pp.color;
+ }
+ }
+ }
+ }
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.