mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
New build scripts
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5282 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
146
source/web/scripts/ajax/dojo/src/charting/Axis.js
Normal file
146
source/web/scripts/ajax/dojo/src/charting/Axis.js
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.Axis");
|
||||
dojo.require("dojo.lang.common");
|
||||
|
||||
dojo.charting.Axis = function(/* string? */label, /* string? */scale, /* array? */labels){
|
||||
var id = "dojo-charting-axis-"+dojo.charting.Axis.count++;
|
||||
this.getId=function(){ return id; };
|
||||
this.setId=function(key){ id = key; };
|
||||
this.scale = scale || "linear"; // linear || log
|
||||
this.label = label || "";
|
||||
this.showLabel = true; // show axis label.
|
||||
this.showLabels = true; // show interval ticks.
|
||||
this.showLines = false; // if you want lines over the range of the plot area
|
||||
this.showTicks = false; // if you want tick marks on the axis.
|
||||
this.range = { upper : 0, lower : 0 }; // range of individual axis.
|
||||
this.origin = "min"; // this can be any number, "min" or "max". min/max is translated on init.
|
||||
|
||||
this.labels = labels || [];
|
||||
this._labels = []; // what we really use to draw things.
|
||||
this.nodes={ main: null, axis: null, label: null, labels: null, lines: null, ticks: null };
|
||||
};
|
||||
dojo.charting.Axis.count = 0;
|
||||
|
||||
dojo.extend(dojo.charting.Axis, {
|
||||
// TODO: implement log scaling.
|
||||
getCoord: function(
|
||||
/* float */val,
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot
|
||||
){
|
||||
// summary
|
||||
// returns the coordinate of val based on this axis range, plot area and plot.
|
||||
val = parseFloat(val, 10);
|
||||
var area = plotArea.getArea();
|
||||
if(plot.axisX == this){
|
||||
var offset = 0 - this.range.lower;
|
||||
var min = this.range.lower + offset; // FIXME: check this.
|
||||
var max = this.range.upper + offset;
|
||||
val += offset;
|
||||
return (val*((area.right-area.left)/max))+area.left; // float
|
||||
} else {
|
||||
var max = this.range.upper;
|
||||
var min = this.range.lower;
|
||||
var offset = 0;
|
||||
if(min<0){
|
||||
offset += Math.abs(min);
|
||||
}
|
||||
max += offset; min += offset; val += offset;
|
||||
var pmin = area.bottom;
|
||||
var pmax = area.top;
|
||||
return (((pmin-pmax)/(max-min))*(max-val))+pmax;
|
||||
}
|
||||
},
|
||||
initializeOrigin: function(drawAgainst, plane){
|
||||
// figure out the origin value.
|
||||
if(isNaN(this.origin)){
|
||||
if(this.origin.toLowerCase() == "max"){
|
||||
this.origin = drawAgainst.range[(plane=="y")?"upper":"lower"];
|
||||
}
|
||||
else if (this.origin.toLowerCase() == "min"){
|
||||
this.origin = drawAgainst.range[(plane=="y")?"lower":"upper"];
|
||||
}
|
||||
else { this.origin=0; }
|
||||
}
|
||||
},
|
||||
initializeLabels: function(){
|
||||
// Translate the labels if needed.
|
||||
if(this.labels.length == 0){
|
||||
this.showLabels = false;
|
||||
this.showLines = false;
|
||||
this.showTicks = false;
|
||||
} else {
|
||||
if(this.labels[0].label && this.labels[0].value != null){
|
||||
for(var i=0; i<this.labels.length; i++){
|
||||
this._labels.push(this.labels[i]);
|
||||
}
|
||||
}
|
||||
else if(!isNaN(this.labels[0])){
|
||||
for(var i=0; i<this.labels.length; i++){
|
||||
this._labels.push({ label: this.labels[i], value: this.labels[i] });
|
||||
}
|
||||
}
|
||||
else {
|
||||
// clone me
|
||||
var a = [];
|
||||
for(var i=0; i<this.labels.length; i++){
|
||||
a.push(this.labels[i]);
|
||||
}
|
||||
|
||||
// do the bottom one.
|
||||
var s=a.shift();
|
||||
this._labels.push({ label: s, value: this.range.lower });
|
||||
|
||||
// do the top one.
|
||||
if(a.length>0){
|
||||
var s=a.pop();
|
||||
this._labels.push({ label: s, value: this.range.upper });
|
||||
}
|
||||
// do the rest.
|
||||
if(a.length>0){
|
||||
var range = this.range.upper - this.range.lower;
|
||||
var step = range / (this.labels.length-1);
|
||||
for(var i=1; i<=a.length; i++){
|
||||
this._labels.push({
|
||||
label: a[i-1],
|
||||
value: this.range.lower+(step*i)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
initialize: function(plotArea, plot, drawAgainst, plane){
|
||||
// summary
|
||||
// Initialize the passed axis descriptor. Note that this should always
|
||||
// be the result of plotArea.getAxes, and not the axis directly!
|
||||
this.destroy();
|
||||
this.initializeOrigin(drawAgainst, plane);
|
||||
this.initializeLabels();
|
||||
var node = this.render(plotArea, plot, drawAgainst, plane);
|
||||
return node;
|
||||
},
|
||||
destroy: function(){
|
||||
for(var p in this.nodes){
|
||||
while(this.nodes[p] && this.nodes[p].childNodes.length > 0){
|
||||
this.nodes[p].removeChild(this.nodes[p].childNodes[0]);
|
||||
}
|
||||
if(this.nodes[p] && this.nodes[p].parentNode){
|
||||
this.nodes[p].parentNode.removeChild(this.nodes[p]);
|
||||
}
|
||||
this.nodes[p] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dojo.requireIf(dojo.render.svg.capable, "dojo.charting.svg.Axis");
|
||||
dojo.requireIf(dojo.render.vml.capable, "dojo.charting.vml.Axis");
|
85
source/web/scripts/ajax/dojo/src/charting/Chart.js
vendored
Normal file
85
source/web/scripts/ajax/dojo/src/charting/Chart.js
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.Chart");
|
||||
dojo.require("dojo.lang.common");
|
||||
dojo.require("dojo.charting.PlotArea");
|
||||
|
||||
dojo.charting.Chart = function(
|
||||
/* HTMLElement? */node,
|
||||
/* string? */title,
|
||||
/* string? */description
|
||||
){
|
||||
// summary
|
||||
// Create the basic Chart object.
|
||||
this.node = node || null;
|
||||
this.title = title || "Chart"; // pure string.
|
||||
this.description = description || ""; // HTML is allowed.
|
||||
this.plotAreas = [];
|
||||
};
|
||||
|
||||
dojo.extend(dojo.charting.Chart, {
|
||||
// methods
|
||||
addPlotArea: function(/* object */obj, /* bool? */doRender){
|
||||
// summary
|
||||
// Add a PlotArea to this chart; object should be in the
|
||||
// form of: { plotArea, (x, y) or (top, left) }
|
||||
if(obj.x!=null && obj.left==null){ obj.left = obj.x; }
|
||||
if(obj.y!=null && obj.top==null){ obj.top = obj.y; }
|
||||
this.plotAreas.push(obj);
|
||||
if(doRender){ this.render(); }
|
||||
},
|
||||
|
||||
// events
|
||||
onInitialize:function(chart){ },
|
||||
onRender:function(chart){ },
|
||||
onDestroy:function(chart){ },
|
||||
|
||||
// standard build methods
|
||||
initialize: function(){
|
||||
// summary
|
||||
// Initialize the Chart by rendering it.
|
||||
if(!this.node){
|
||||
dojo.raise("dojo.charting.Chart.initialize: there must be a root node defined for the Chart.");
|
||||
}
|
||||
this.destroy();
|
||||
this.render();
|
||||
this.onInitialize(this);
|
||||
},
|
||||
render:function(){
|
||||
// summary
|
||||
// Render the chart in its entirety.
|
||||
if(this.node.style.position != "absolute"){
|
||||
this.node.style.position = "relative";
|
||||
}
|
||||
for(var i=0; i<this.plotAreas.length; i++){
|
||||
var area = this.plotAreas[i].plotArea;
|
||||
var node = area.initialize();
|
||||
node.style.position = "absolute";
|
||||
node.style.top = this.plotAreas[i].top + "px";
|
||||
node.style.left = this.plotAreas[i].left + "px";
|
||||
this.node.appendChild(node);
|
||||
area.render();
|
||||
}
|
||||
},
|
||||
destroy: function(){
|
||||
// summary
|
||||
// Destroy any nodes that have maintained references.
|
||||
|
||||
// kill any existing plotAreas
|
||||
for(var i=0; i<this.plotAreas.length; i++){
|
||||
this.plotAreas[i].plotArea.destroy();
|
||||
};
|
||||
// clean out any child nodes.
|
||||
while(this.node && this.node.childNodes && this.node.childNodes.length > 0){
|
||||
this.node.removeChild(this.node.childNodes[0]);
|
||||
}
|
||||
}
|
||||
});
|
103
source/web/scripts/ajax/dojo/src/charting/Plot.js
Normal file
103
source/web/scripts/ajax/dojo/src/charting/Plot.js
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.Plot");
|
||||
dojo.require("dojo.lang.common");
|
||||
dojo.require("dojo.charting.Axis");
|
||||
dojo.require("dojo.charting.Series");
|
||||
|
||||
dojo.charting.RenderPlotSeries = { Singly:"single", Grouped:"grouped" };
|
||||
|
||||
dojo.charting.Plot = function(
|
||||
/* dojo.charting.Axis? */xaxis,
|
||||
/* dojo.charting.Axis? */yaxis,
|
||||
/* dojo.charting.Series[]? */series
|
||||
){
|
||||
// summary
|
||||
// Creates a new instance of a Plot (X/Y Axis + n Series).
|
||||
var id = "dojo-charting-plot-"+dojo.charting.Plot.count++;
|
||||
this.getId=function(){ return id; };
|
||||
this.setId=function(key){ id = key; };
|
||||
this.axisX = null;
|
||||
this.axisY = null;
|
||||
this.series = [];
|
||||
this.dataNode = null;
|
||||
|
||||
// for bar charts, pie charts and stacked charts, change to Grouped.
|
||||
this.renderType = dojo.charting.RenderPlotSeries.Singly;
|
||||
if(xaxis){
|
||||
this.setAxis(xaxis,"x");
|
||||
}
|
||||
if(yaxis){
|
||||
this.setAxis(yaxis,"y");
|
||||
}
|
||||
if(series){
|
||||
for(var i=0; i<series.length; i++){ this.addSeries(series[i]); }
|
||||
}
|
||||
}
|
||||
dojo.charting.Plot.count=0;
|
||||
|
||||
dojo.extend(dojo.charting.Plot, {
|
||||
addSeries: function(
|
||||
/* dojo.charting.Series || object */series,
|
||||
/* function? */plotter
|
||||
){
|
||||
// summary
|
||||
// Add a new Series to this plot. Can take the form of a Series, or an object
|
||||
// of the form { series, plotter }
|
||||
if(series.plotter){
|
||||
this.series.push(series);
|
||||
} else {
|
||||
this.series.push({
|
||||
data: series,
|
||||
plotter: plotter || dojo.charting.Plotters["Default"]
|
||||
});
|
||||
}
|
||||
},
|
||||
setAxis: function(/* dojo.charting.Axis */axis, /* string */which){
|
||||
// summary
|
||||
// Set the axis on which plane.
|
||||
if(which.toLowerCase()=="x"){ this.axisX = axis; }
|
||||
else if(which.toLowerCase()=="y"){ this.axisY = axis; }
|
||||
},
|
||||
getRanges: function(){
|
||||
// summary
|
||||
// set the ranges on these axes.
|
||||
var xmin, xmax, ymin, ymax;
|
||||
xmin=ymin=Number.MAX_VALUE;
|
||||
xmax=ymax=Number.MIN_VALUE;
|
||||
for(var i=0; i<this.series.length; i++){
|
||||
var values = this.series[i].data.evaluate(); // full data range.
|
||||
for(var j=0; j<values.length; j++){
|
||||
var comp=values[j];
|
||||
xmin=Math.min(comp.x, xmin);
|
||||
ymin=Math.min(comp.y, ymin);
|
||||
xmax=Math.max(comp.x, xmax);
|
||||
ymax=Math.max(comp.y, ymax);
|
||||
}
|
||||
}
|
||||
return {
|
||||
x:{ upper: xmax, lower:xmin },
|
||||
y:{ upper: ymax, lower:ymin },
|
||||
toString:function(){
|
||||
return "[ x:"+xmax+" - "+xmin+", y:"+ymax+" - "+ymin+"]";
|
||||
}
|
||||
}; // object
|
||||
},
|
||||
destroy: function(){
|
||||
// summary
|
||||
// Clean out any existing DOM node references.
|
||||
var node=this.dataNode;
|
||||
while(node && node.childNodes && node.childNodes.length > 0){
|
||||
node.removeChild(node.childNodes[0]);
|
||||
}
|
||||
this.dataNode=null;
|
||||
}
|
||||
});
|
195
source/web/scripts/ajax/dojo/src/charting/PlotArea.js
Normal file
195
source/web/scripts/ajax/dojo/src/charting/PlotArea.js
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.PlotArea");
|
||||
dojo.require("dojo.lang.common");
|
||||
dojo.require("dojo.gfx.color");
|
||||
dojo.require("dojo.gfx.color.hsl");
|
||||
dojo.require("dojo.charting.Plot");
|
||||
|
||||
dojo.charting.PlotArea = function(){
|
||||
// summary
|
||||
// Creates a new PlotArea for drawing onto a Chart.
|
||||
var id="dojo-charting-plotarea-"+dojo.charting.PlotArea.count++;
|
||||
this.getId=function(){ return id; };
|
||||
this.setId=function(key){ id = key; };
|
||||
this.areaType = "standard"; // standard || radar
|
||||
this.plots = []; // plots that will be drawn on this area
|
||||
|
||||
this.size={ width:600, height:400 };
|
||||
this.padding={ top:10, right:10, bottom:20, left:20 };
|
||||
|
||||
// drawing node references.
|
||||
this.nodes = {
|
||||
main:null,
|
||||
area:null,
|
||||
background: null,
|
||||
axes: null,
|
||||
plots: null
|
||||
};
|
||||
|
||||
// this is preset for a limited color range (green to purple),
|
||||
// anticipating a max of 32 series on this plot area.
|
||||
// if you need more flexibility, override these numbers.
|
||||
this._color = { h: 140, s: 120, l: 120, step: 27 };
|
||||
};
|
||||
dojo.charting.PlotArea.count = 0;
|
||||
|
||||
dojo.extend(dojo.charting.PlotArea, {
|
||||
nextColor: function(){
|
||||
// summary
|
||||
// Advances the internal HSV cursor and returns the next generated color.
|
||||
var rgb=dojo.gfx.color.hsl2rgb(this._color.h, this._color.s, this._color.l);
|
||||
this._color.h = (this._color.h + this._color.step)%360;
|
||||
while(this._color.h < 140){
|
||||
this._color.h += this._color.step;
|
||||
}
|
||||
return dojo.gfx.color.rgb2hex(rgb[0], rgb[1], rgb[2]); // string
|
||||
},
|
||||
getArea:function(){
|
||||
// summary
|
||||
// Return an object describing the coordinates of the available area to plot on.
|
||||
return {
|
||||
left: this.padding.left,
|
||||
right: this.size.width - this.padding.right,
|
||||
top: this.padding.top,
|
||||
bottom: this.size.height - this.padding.bottom,
|
||||
toString:function(){
|
||||
var a=[ this.top, this.right, this.bottom, this.left ];
|
||||
return "["+a.join()+"]";
|
||||
}
|
||||
}; // object
|
||||
},
|
||||
getAxes: function(){
|
||||
// summary
|
||||
// get the unique axes for this plot area.
|
||||
var axes={};
|
||||
for(var i=0; i<this.plots.length; i++){
|
||||
var plot=this.plots[i];
|
||||
axes[plot.axisX.getId()] = {
|
||||
axis: plot.axisX,
|
||||
drawAgainst: plot.axisY,
|
||||
plot: plot,
|
||||
plane: "x"
|
||||
};
|
||||
axes[plot.axisY.getId()] = {
|
||||
axis: plot.axisY,
|
||||
drawAgainst: plot.axisX,
|
||||
plot: plot,
|
||||
plane: "y"
|
||||
};
|
||||
}
|
||||
return axes; // object
|
||||
},
|
||||
getLegendInfo: function(){
|
||||
// summary
|
||||
// return an array describing all data series on this plot area.
|
||||
var a=[];
|
||||
for(var i=0; i<this.plots.length; i++){
|
||||
for(var j=0; j<this.plots[i].series.length; j++){
|
||||
var data = this.plots[i].series[j].data;
|
||||
a.push({ label:data.label, color:data.color });
|
||||
}
|
||||
}
|
||||
return a; // array
|
||||
},
|
||||
setAxesRanges: function(){
|
||||
// summary
|
||||
// Find and set the ranges on all axes on this plotArea.
|
||||
// We do this because plots may have axes in common; if you
|
||||
// want to use this, make sure you do it *before* initialization.
|
||||
var ranges={};
|
||||
var axes={};
|
||||
for(var i=0; i<this.plots.length; i++){
|
||||
var plot = this.plots[i];
|
||||
var ranges=plot.getRanges();
|
||||
var x=ranges.x;
|
||||
var y=ranges.y;
|
||||
var ax, ay;
|
||||
if(!axes[plot.axisX.getId()]){
|
||||
axes[plot.axisX.getId()]=plot.axisX;
|
||||
ranges[plot.axisX.getId()]={upper: x.upper, lower:x.lower};
|
||||
}
|
||||
ax=ranges[plot.axisX.getId()];
|
||||
ax.upper=Math.max(ax.upper, x.upper);
|
||||
ax.lower=Math.min(ax.lower, x.lower);
|
||||
|
||||
if(!axes[plot.axisY.getId()]){
|
||||
axes[plot.axisY.getId()]=plot.axisY;
|
||||
ranges[plot.axisY.getId()]={upper: y.upper, lower:y.lower};
|
||||
}
|
||||
ay=ranges[plot.axisY.getId()];
|
||||
ay.upper=Math.max(ay.upper, y.upper);
|
||||
ay.lower=Math.min(ay.lower, y.lower);
|
||||
}
|
||||
|
||||
// now that we have all the max/min ranges, set the axes
|
||||
for(var p in axes){
|
||||
axes[p].range=ranges[p];
|
||||
}
|
||||
},
|
||||
|
||||
render: function(/* object? */kwArgs, /* function? */applyToData){
|
||||
// summary
|
||||
// Render this plotArea. Optional kwArgs are the same as that taken for Series.evaluate;
|
||||
// applyToData is a callback function used by plotters for customization.
|
||||
if(!this.nodes.main
|
||||
|| !this.nodes.area
|
||||
|| !this.nodes.background
|
||||
|| !this.nodes.plots
|
||||
|| !this.nodes.axes
|
||||
){ this.initialize(); }
|
||||
|
||||
// plot it.
|
||||
for(var i=0; i<this.plots.length; i++){
|
||||
var plot=this.plots[i];
|
||||
this.nodes.plots.removeChild(plot.dataNode);
|
||||
var target = this.initializePlot(plot);
|
||||
switch(plot.renderType){
|
||||
case dojo.charting.RenderPlotSeries.Grouped: {
|
||||
// ALWAYS plot using the first plotter, ignore any others.
|
||||
if(plot.series[0]){
|
||||
target.appendChild(plot.series[0].plotter(this, plot, kwArgs, applyToData));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case dojo.charting.RenderPlotSeries.Singly:
|
||||
default: {
|
||||
for(var j=0; j<plot.series.length; j++){
|
||||
var series = plot.series[j];
|
||||
var data = series.data.evaluate(kwArgs);
|
||||
target.appendChild(series.plotter(data, this, plot, applyToData));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.nodes.plots.appendChild(target);
|
||||
}
|
||||
},
|
||||
destroy: function(){
|
||||
// summary
|
||||
// Clean out any existing DOM references.
|
||||
for(var i=0; i<this.plots.length; i++){
|
||||
this.plots[i].destroy();
|
||||
};
|
||||
// clean out any child nodes.
|
||||
for(var p in this.nodes){
|
||||
var node=this.nodes[p];
|
||||
if(!node) continue;
|
||||
if(!node.childNodes) continue;
|
||||
while(node.childNodes.length > 0){
|
||||
node.removeChild(node.childNodes[0]);
|
||||
}
|
||||
this.nodes[p]=null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dojo.requireIf(dojo.render.svg.capable, "dojo.charting.svg.PlotArea");
|
||||
dojo.requireIf(dojo.render.vml.capable, "dojo.charting.vml.PlotArea");
|
19
source/web/scripts/ajax/dojo/src/charting/Plotters.js
Normal file
19
source/web/scripts/ajax/dojo/src/charting/Plotters.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.Plotters");
|
||||
|
||||
/*
|
||||
* Plotters is the placeholder; what will happen is that the proper renderer types
|
||||
* will be mixed into this object (as opposed to creating a new one).
|
||||
*/
|
||||
|
||||
dojo.requireIf(dojo.render.svg.capable, "dojo.charting.svg.Plotters");
|
||||
dojo.requireIf(dojo.render.vml.capable, "dojo.charting.vml.Plotters");
|
46
source/web/scripts/ajax/dojo/src/charting/README.txt
Normal file
46
source/web/scripts/ajax/dojo/src/charting/README.txt
Normal file
@@ -0,0 +1,46 @@
|
||||
Dojo Charting Engine
|
||||
=========================================================================
|
||||
The Dojo Charting Engine is a (fairly) complex object structure, designed
|
||||
to provide as much flexibility as possible in terms of chart construction.
|
||||
To this end, the engine details the following structure:
|
||||
|
||||
Chart
|
||||
---PlotArea[]
|
||||
------Plot[]
|
||||
---------Axis (axisX)
|
||||
---------Axis (axisY)
|
||||
---------Series[]
|
||||
|
||||
|
||||
A Chart object is the main entity; it is the entire graphic. A Chart may
|
||||
have any number of PlotArea objects, which are the basic canvas against
|
||||
which data is plotted. A PlotArea may have any number of Plot objects,
|
||||
which is a container representing up to 2 axes and any number of series
|
||||
to be plotted against those axes; a Series represents a binding against
|
||||
two fields from a data source (initial rev, this data source is always of
|
||||
type dojo.collections.Store but this will probably change once dojo.data
|
||||
is in production).
|
||||
|
||||
The point of this structure is to allow for as much flexibility as possible
|
||||
in terms of what kinds of charts can be represented by the engine. The
|
||||
current plan is to accomodate up to analytical financial charts, which tend
|
||||
to have 3 plot areas and any number of different types of axes on each one.
|
||||
|
||||
The main exception to this is the pie chart, which will have it's own
|
||||
custom codebase. Also, 3D charts are not accounted for at this time,
|
||||
although the only thing that will probably need to be altered to make
|
||||
that work would be Plot and Series (to accomodate the additional Z axis).
|
||||
|
||||
Finally, a Plot will render its series[] through the use of Plotters, which
|
||||
are custom methods to render specific types of charts.
|
||||
-------------------------------------------------------------------------
|
||||
In terms of widgets, the basic concept is that there is a central, super-
|
||||
flexible Chart widget (Chart, oddly enough), and then any number of preset
|
||||
chart type widgets, that are basically built to serve a simple, easy
|
||||
purpose. For instance, if someone just needs to plot a series of lines,
|
||||
they would be better off using the LineChart widget; but if someone needed
|
||||
to plot a combo chart, that has 2 Y Axes (one linear, one log) against the
|
||||
same X Axis, using lines and areas, then they will want to use a Chart widget.
|
||||
Note also that unlike other widgets, the Charting engine *can* be called
|
||||
directly from script *without* the need for the actual widget engine to be
|
||||
loaded; the Chart widgets are thin wrappers around the charting engine.
|
215
source/web/scripts/ajax/dojo/src/charting/Series.js
Normal file
215
source/web/scripts/ajax/dojo/src/charting/Series.js
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.Series");
|
||||
dojo.require("dojo.lang.common");
|
||||
dojo.require("dojo.charting.Plotters");
|
||||
|
||||
dojo.charting.Series = function(/* object? */kwArgs){
|
||||
// summary
|
||||
// Create an instance of data series for plotting.
|
||||
var args = kwArgs || { length:1 };
|
||||
this.dataSource = args.dataSource || null;
|
||||
this.bindings = { };
|
||||
this.color = args.color;
|
||||
this.label = args.label;
|
||||
|
||||
if(args.bindings){
|
||||
for(var p in args.bindings){
|
||||
this.addBinding(p, args.bindings[p]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
dojo.extend(dojo.charting.Series, {
|
||||
bind:function(/* dojo.collections.Store */src, /* object */bindings){
|
||||
// summary
|
||||
// Bind this series to src, with bindings.
|
||||
this.dataSource = src;
|
||||
this.bindings = bindings;
|
||||
},
|
||||
addBinding:function(/* string */name, /* string */binding){
|
||||
// summary
|
||||
// Bind to field "binding" using "name".
|
||||
this.bindings[name] = binding;
|
||||
},
|
||||
evaluate:function(/* object? */kwArgs){
|
||||
// summary
|
||||
// Evaluate all bindings and return an array of objects describing the bind.
|
||||
var ret = [];
|
||||
var a = this.dataSource.getData();
|
||||
var l = a.length;
|
||||
var start = 0;
|
||||
var end = l;
|
||||
|
||||
/* Allow for ranges. Can be done in one of two ways:
|
||||
* 1. { from, to } as 0-based indices
|
||||
* 2. { length } as num of data points to get; a negative
|
||||
* value will start from the end of the data set.
|
||||
* No kwArg object means the full data set will be evaluated
|
||||
* and returned.
|
||||
*/
|
||||
if(kwArgs){
|
||||
if(kwArgs.from){
|
||||
start = Math.max(kwArgs.from,0);
|
||||
if(kwArgs.to){
|
||||
end = Math.min(kwArgs.to, end);
|
||||
}
|
||||
}
|
||||
else if(kwArgs.length){
|
||||
if(kwArgs.length < 0){
|
||||
// length points from end
|
||||
start = Math.max((end + length),0);
|
||||
} else {
|
||||
end = Math.min((start + length), end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(var i=start; i<end; i++){
|
||||
var o = { src: a[i], series: this };
|
||||
for(var p in this.bindings){
|
||||
o[p] = this.dataSource.getField(a[i], this.bindings[p]);
|
||||
}
|
||||
ret.push(o);
|
||||
}
|
||||
|
||||
// sort by the x axis, if available.
|
||||
if(typeof(ret[0].x) != "undefined"){
|
||||
ret.sort(function(a,b){
|
||||
if(a.x > b.x) return 1;
|
||||
if(a.x < b.x) return -1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
return ret; // array
|
||||
},
|
||||
|
||||
// trends
|
||||
trends:{
|
||||
createRange: function(/* array */values, /* int */len){
|
||||
// summary
|
||||
// Creates the data range used for all trends.
|
||||
var idx = values.length-1;
|
||||
var length = (len||values.length);
|
||||
return { "index": idx, "length": length, "start":Math.max(idx-length,0) }; // object
|
||||
},
|
||||
|
||||
mean: function(/* array */values, /* int */len){
|
||||
// summary
|
||||
// Returns the mean or average over the set of values.
|
||||
var range = this.createRange(values, len);
|
||||
if(range.index<0){ return 0; }
|
||||
var total = 0;
|
||||
var count = 0;
|
||||
for(var i=range.index; i>=range.start; i--){
|
||||
total += values[i].y;
|
||||
count++;
|
||||
}
|
||||
total /= Math.max(count,1);
|
||||
return total; // float
|
||||
},
|
||||
|
||||
variance: function(/* array */values,/* int */len){
|
||||
// summary
|
||||
// Returns the variance of the set of values.
|
||||
var range = this.createRange(values,len);
|
||||
if(range.index < 0){ return 0; }
|
||||
var total = 0;
|
||||
var square = 0;
|
||||
var count = 0;
|
||||
for(var i=range.index; i>=range.start; i--){
|
||||
total += values[i].y;
|
||||
square += Math.pow(values[i].y, 2);
|
||||
count++;
|
||||
}
|
||||
return (square/count)-Math.pow(total/count,2); // float
|
||||
},
|
||||
|
||||
standardDeviation: function(/* array */values, /* int */len){
|
||||
// summary
|
||||
// Returns the standard deviation of the set of values.
|
||||
return Math.sqrt(this.getVariance(values, len)); // float
|
||||
},
|
||||
|
||||
max: function(/* array */values, /* int */len){
|
||||
// summary
|
||||
// Returns the max number in the set of values.
|
||||
var range = this.createRange(values, len);
|
||||
if(range.index < 0){ return 0; }
|
||||
var max = Number.MIN_VALUE;
|
||||
for (var i=range.index; i>=range.start; i--){
|
||||
max = Math.max(values[i].y,max);
|
||||
}
|
||||
return max; // float
|
||||
},
|
||||
|
||||
min: function(/* array */values, /* int */len){
|
||||
// summary
|
||||
// Returns the lowest number in the set of values.
|
||||
var range=this.createRange(values, len);
|
||||
if(range.index < 0){ return 0; }
|
||||
var min = Number.MAX_VALUE;
|
||||
for(var i=range.index; i>=range.start; i--){
|
||||
min = Math.min(values[i].y, min);
|
||||
}
|
||||
return min; // float
|
||||
},
|
||||
|
||||
median: function(/* array */values, /* int */len){
|
||||
// summary
|
||||
// Returns the median in the set of values (number closest to the middle of a sorted set).
|
||||
var range = this.createRange(values, len);
|
||||
if(range.index<0){ return 0; }
|
||||
var a = [];
|
||||
for (var i=range.index; i>=range.start; i--){
|
||||
var b=false;
|
||||
for(var j=0; j<a.length; j++){
|
||||
if(values[i].y == a[j]){
|
||||
b = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!b){
|
||||
a.push(values[i].y);
|
||||
}
|
||||
}
|
||||
a.sort();
|
||||
if(a.length > 0){
|
||||
return a[Math.ceil(a.length / 2)]; // float
|
||||
}
|
||||
return 0; // float
|
||||
},
|
||||
|
||||
mode: function(/* array */values, /* int */len){
|
||||
// summary
|
||||
// Returns the mode in the set of values
|
||||
var range=this.createRange(values, len);
|
||||
if(range.index<0){ return 0; }
|
||||
var o = {};
|
||||
var ret = 0
|
||||
var median = Number.MIN_VALUE;
|
||||
for(var i=range.index; i>=range.start; i--){
|
||||
if (!o[values[i].y]){
|
||||
o[values[i].y] = 1;
|
||||
} else {
|
||||
o[values[i].y]++;
|
||||
}
|
||||
}
|
||||
for(var p in o){
|
||||
if(median < o[p]){
|
||||
median = o[p];
|
||||
ret=p;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
});
|
11
source/web/scripts/ajax/dojo/src/charting/__package__.js
Normal file
11
source/web/scripts/ajax/dojo/src/charting/__package__.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.*");
|
226
source/web/scripts/ajax/dojo/src/charting/svg/Axis.js
Normal file
226
source/web/scripts/ajax/dojo/src/charting/svg/Axis.js
Normal file
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.svg.Axis");
|
||||
dojo.require("dojo.lang.common");
|
||||
|
||||
if(dojo.render.svg.capable){
|
||||
dojo.extend(dojo.charting.Axis, {
|
||||
renderLines: function(
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* string */plane
|
||||
){
|
||||
// summary
|
||||
// Renders any reference lines for this axis.
|
||||
if(this.nodes.lines){
|
||||
while(this.nodes.lines.childNodes.length > 0){
|
||||
this.nodes.lines.removeChild(this.nodes.lines.childNodes[0]);
|
||||
}
|
||||
if(this.nodes.lines.parentNode){
|
||||
this.nodes.lines.parentNode.removeChild(this.nodes.lines);
|
||||
this.nodes.lines = null;
|
||||
}
|
||||
}
|
||||
|
||||
var area = plotArea.getArea();
|
||||
var g = this.nodes.lines = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
g.setAttribute("id", this.getId()+"-lines");
|
||||
for(var i=0; i<this._labels.length; i++){
|
||||
if (this._labels[i].value == this.origin){ continue; }
|
||||
|
||||
var v = this.getCoord(this._labels[i].value, plotArea, plot);
|
||||
var l=document.createElementNS(dojo.svg.xmlns.svg, "line");
|
||||
l.setAttribute("style","stroke:#999;stroke-width:1px;stroke-dasharray:1,4;");
|
||||
if(plane == "x"){
|
||||
l.setAttribute("y1",area.top);
|
||||
l.setAttribute("y2",area.bottom);
|
||||
l.setAttribute("x1",v);
|
||||
l.setAttribute("x2",v);
|
||||
}
|
||||
else if (plane == "y"){
|
||||
l.setAttribute("y1",v);
|
||||
l.setAttribute("y2",v);
|
||||
l.setAttribute("x1",area.left);
|
||||
l.setAttribute("x2",area.right);
|
||||
}
|
||||
g.appendChild(l);
|
||||
}
|
||||
return g; // SVGGElement
|
||||
},
|
||||
renderTicks: function(
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* string */plane,
|
||||
/* float */coord
|
||||
){
|
||||
// summary
|
||||
// Renders any tick lines for this axis.
|
||||
if(this.nodes.ticks){
|
||||
while(this.nodes.ticks.childNodes.length > 0){
|
||||
this.nodes.ticks.removeChild(this.nodes.ticks.childNodes[0]);
|
||||
}
|
||||
if(this.nodes.ticks.parentNode){
|
||||
this.nodes.ticks.parentNode.removeChild(this.nodes.ticks);
|
||||
this.nodes.ticks = null;
|
||||
}
|
||||
}
|
||||
|
||||
var g = this.nodes.ticks = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
g.setAttribute("id", this.getId()+"-ticks");
|
||||
for(var i=0; i<this._labels.length; i++){
|
||||
var v = this.getCoord(this._labels[i].value, plotArea, plot);
|
||||
|
||||
var l=document.createElementNS(dojo.svg.xmlns.svg, "line");
|
||||
l.setAttribute("style","stroke:#000;stroke-width:1pt;");
|
||||
if(plane == "x"){
|
||||
l.setAttribute("y1",coord);
|
||||
l.setAttribute("y2",coord+3);
|
||||
l.setAttribute("x1",v);
|
||||
l.setAttribute("x2",v);
|
||||
}
|
||||
else if (plane == "y"){
|
||||
l.setAttribute("y1",v);
|
||||
l.setAttribute("y2",v);
|
||||
l.setAttribute("x1",coord-2);
|
||||
l.setAttribute("x2",coord+2);
|
||||
}
|
||||
g.appendChild(l);
|
||||
}
|
||||
return g; // SVGGElement
|
||||
},
|
||||
renderLabels: function(
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* string */plane,
|
||||
/* float */coord,
|
||||
/* int */textSize,
|
||||
/* string */anchor
|
||||
){
|
||||
// summary
|
||||
// Render all labels for this axis.
|
||||
function createLabel(label, x, y, textSize, anchor){
|
||||
var text = document.createElementNS(dojo.svg.xmlns.svg, "text");
|
||||
text.setAttribute("x", x);
|
||||
text.setAttribute("y", (plane=="x"?y:y+2));
|
||||
text.setAttribute("style", "text-anchor:"+anchor+";font-family:sans-serif;font-size:"+textSize+"px;fill:#000;");
|
||||
text.appendChild(document.createTextNode(label));
|
||||
return text;
|
||||
};
|
||||
|
||||
// wipe if needed
|
||||
if(this.nodes.labels){
|
||||
while(this.nodes.labels.childNodes.length > 0){
|
||||
this.nodes.labels.removeChild(this.nodes.labels.childNodes[0]);
|
||||
}
|
||||
if(this.nodes.labels.parentNode){
|
||||
this.nodes.labels.parentNode.removeChild(this.nodes.labels);
|
||||
this.nodes.labels = null;
|
||||
}
|
||||
}
|
||||
var g = this.nodes.labels = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
g.setAttribute("id", this.getId()+"-labels");
|
||||
|
||||
for(var i=0; i<this._labels.length; i++){
|
||||
var v = this.getCoord(this._labels[i].value, plotArea, plot);
|
||||
if(plane == "x"){
|
||||
g.appendChild(createLabel(this._labels[i].label, v, coord, textSize, anchor));
|
||||
}
|
||||
else if (plane == "y"){
|
||||
g.appendChild(createLabel(this._labels[i].label, coord, v, textSize, anchor));
|
||||
}
|
||||
}
|
||||
return g; // SVGGelement
|
||||
},
|
||||
render: function(
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* dojo.charting.Axis */drawAgainst,
|
||||
/* string */plane
|
||||
){
|
||||
// summary
|
||||
// Renders this axis to the given plot.
|
||||
|
||||
// get the origin plot point.
|
||||
var area = plotArea.getArea();
|
||||
var stroke = 1;
|
||||
var style = "stroke:#000;stroke-width:"+stroke+"px;";
|
||||
var textSize=10;
|
||||
var coord = drawAgainst.getCoord(this.origin, plotArea, plot);
|
||||
|
||||
// draw the axis.
|
||||
this.nodes.main = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
var g = this.nodes.main;
|
||||
g.setAttribute("id", this.getId()); // need a handle if we have to kill parts of the axis def.
|
||||
var line = this.nodes.axis = document.createElementNS(dojo.svg.xmlns.svg, "line");
|
||||
if(plane == "x"){
|
||||
line.setAttribute("y1", coord);
|
||||
line.setAttribute("y2", coord);
|
||||
line.setAttribute("x1", area.left-stroke);
|
||||
line.setAttribute("x2", area.right+stroke);
|
||||
line.setAttribute("style", style);
|
||||
|
||||
// set up the labels
|
||||
var y = coord+textSize+2;
|
||||
if(this.showLines){
|
||||
g.appendChild(this.renderLines(plotArea, plot, plane, y));
|
||||
}
|
||||
if(this.showTicks){
|
||||
g.appendChild(this.renderTicks(plotArea, plot, plane, coord));
|
||||
}
|
||||
if(this.showLabels){
|
||||
g.appendChild(this.renderLabels(plotArea, plot, plane, y, textSize, "middle"));
|
||||
}
|
||||
if(this.showLabel && this.label){
|
||||
var x = plotArea.size.width/2;
|
||||
var text = document.createElementNS(dojo.svg.xmlns.svg, "text");
|
||||
text.setAttribute("x", x);
|
||||
text.setAttribute("y", (coord + (textSize*2) + (textSize/2)));
|
||||
text.setAttribute("style", "text-anchor:middle;font-family:sans-serif;font-weight:bold;font-size:"+(textSize+2)+"px;fill:#000;");
|
||||
text.appendChild(document.createTextNode(this.label));
|
||||
g.appendChild(text);
|
||||
}
|
||||
} else {
|
||||
line.setAttribute("x1", coord);
|
||||
line.setAttribute("x2", coord);
|
||||
line.setAttribute("y1", area.top);
|
||||
line.setAttribute("y2", area.bottom);
|
||||
line.setAttribute("style", style);
|
||||
|
||||
// set up the labels
|
||||
var isMax = this.origin == drawAgainst.range.upper;
|
||||
var x = coord + (isMax?4:-4);
|
||||
var anchor = isMax?"start":"end";
|
||||
if(this.showLines){
|
||||
g.appendChild(this.renderLines(plotArea, plot, plane, x));
|
||||
}
|
||||
if(this.showTicks){
|
||||
g.appendChild(this.renderTicks(plotArea, plot, plane, coord));
|
||||
}
|
||||
if(this.showLabels){
|
||||
g.appendChild(this.renderLabels(plotArea, plot, plane, x, textSize, anchor));
|
||||
}
|
||||
if(this.showLabel && this.label){
|
||||
var x = isMax?(coord+(textSize*2)+(textSize/2)):(coord-(textSize*4));
|
||||
var y = plotArea.size.height / 2;
|
||||
var text = document.createElementNS(dojo.svg.xmlns.svg, "text");
|
||||
text.setAttribute("x", x);
|
||||
text.setAttribute("y", y);
|
||||
text.setAttribute("transform", "rotate(90, " + x + ", " + y + ")");
|
||||
text.setAttribute("style", "text-anchor:middle;font-family:sans-serif;font-weight:bold;font-size:"+(textSize+2)+"px;fill:#000;");
|
||||
text.appendChild(document.createTextNode(this.label));
|
||||
g.appendChild(text);
|
||||
}
|
||||
}
|
||||
g.appendChild(line);
|
||||
return g; // SVGGElement
|
||||
}
|
||||
});
|
||||
}
|
81
source/web/scripts/ajax/dojo/src/charting/svg/PlotArea.js
Normal file
81
source/web/scripts/ajax/dojo/src/charting/svg/PlotArea.js
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.svg.PlotArea");
|
||||
dojo.require("dojo.lang.common");
|
||||
|
||||
if(dojo.render.svg.capable){
|
||||
dojo.require("dojo.svg");
|
||||
dojo.extend(dojo.charting.PlotArea, {
|
||||
initializePlot: function(plot){
|
||||
// summary
|
||||
// Initialize the plot node for data rendering.
|
||||
plot.destroy();
|
||||
plot.dataNode = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
plot.dataNode.setAttribute("id", plot.getId());
|
||||
return plot.dataNode; // SVGGElement
|
||||
},
|
||||
initialize: function(){
|
||||
// summary
|
||||
// Initialize the PlotArea.
|
||||
|
||||
this.destroy(); // kill everything first.
|
||||
|
||||
// start with the background
|
||||
this.nodes.main = document.createElement("div");
|
||||
|
||||
this.nodes.area = document.createElementNS(dojo.svg.xmlns.svg, "svg");
|
||||
this.nodes.area.setAttribute("id", this.getId());
|
||||
this.nodes.area.setAttribute("width", this.size.width);
|
||||
this.nodes.area.setAttribute("height", this.size.height);
|
||||
this.nodes.main.appendChild(this.nodes.area);
|
||||
|
||||
var area=this.getArea();
|
||||
var defs = document.createElementNS(dojo.svg.xmlns.svg, "defs");
|
||||
var clip = document.createElementNS(dojo.svg.xmlns.svg, "clipPath");
|
||||
clip.setAttribute("id",this.getId()+"-clip");
|
||||
var rect = document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
rect.setAttribute("x", area.left);
|
||||
rect.setAttribute("y", area.top);
|
||||
rect.setAttribute("width", area.right-area.left);
|
||||
rect.setAttribute("height", area.bottom-area.top);
|
||||
clip.appendChild(rect);
|
||||
defs.appendChild(clip);
|
||||
this.nodes.area.appendChild(defs);
|
||||
|
||||
this.nodes.background = document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
this.nodes.background.setAttribute("id", this.getId()+"-background");
|
||||
this.nodes.background.setAttribute("width", this.size.width);
|
||||
this.nodes.background.setAttribute("height", this.size.height);
|
||||
this.nodes.background.setAttribute("fill", "#fff");
|
||||
this.nodes.area.appendChild(this.nodes.background);
|
||||
|
||||
this.nodes.plots = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
this.nodes.plots.setAttribute("id", this.getId()+"-plots");
|
||||
this.nodes.plots.setAttribute("style","clip-path:url(#"+this.getId()+"-clip);");
|
||||
this.nodes.area.appendChild(this.nodes.plots);
|
||||
|
||||
for(var i=0; i<this.plots.length; i++){
|
||||
this.nodes.plots.appendChild(this.initializePlot(this.plots[i]));
|
||||
}
|
||||
|
||||
// do the axes
|
||||
this.nodes.axes = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
this.nodes.axes.setAttribute("id", this.getId()+"-axes");
|
||||
this.nodes.area.appendChild(this.nodes.axes);
|
||||
var axes = this.getAxes();
|
||||
for(var p in axes){
|
||||
var obj = axes[p];
|
||||
this.nodes.axes.appendChild(obj.axis.initialize(this, obj.plot, obj.drawAgainst, obj.plane));
|
||||
}
|
||||
return this.nodes.main; // HTMLDivElement
|
||||
}
|
||||
});
|
||||
}
|
875
source/web/scripts/ajax/dojo/src/charting/svg/Plotters.js
Normal file
875
source/web/scripts/ajax/dojo/src/charting/svg/Plotters.js
Normal file
@@ -0,0 +1,875 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.svg.Plotters");
|
||||
dojo.require("dojo.lang.common");
|
||||
|
||||
if(dojo.render.svg.capable){
|
||||
dojo.require("dojo.svg");
|
||||
|
||||
// TODO for 0.5: look at replacing manual plotting with dojo.gfx.
|
||||
|
||||
// Mixin the SVG-specific plotter object.
|
||||
dojo.mixin(dojo.charting.Plotters, {
|
||||
/*********************************************************
|
||||
* Grouped plotters: need all series on a plot at once.
|
||||
*********************************************************/
|
||||
Bar: function(
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* object? */kwArgs,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots a set of grouped bars.
|
||||
// Bindings: y
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
// precompile the data
|
||||
var n = plot.series.length; // how many series
|
||||
var data = [];
|
||||
for(var i=0; i<n; i++){
|
||||
var tmp = plot.series[i].data.evaluate(kwArgs);
|
||||
data.push(tmp);
|
||||
}
|
||||
|
||||
// calculate the width of each bar.
|
||||
var space = 8;
|
||||
var nPoints = data[0].length;
|
||||
var width = ((area.right-area.left)-(space*(nPoints-1)))/nPoints; // the width of each group.
|
||||
var barWidth = width/n; // the width of each bar, no spaces.
|
||||
var yOrigin = plot.axisY.getCoord(plot.axisX.origin, plotarea, plot);
|
||||
|
||||
for(var i=0; i<nPoints; i++){
|
||||
// calculate offset
|
||||
var xStart = area.left+(width*i)+(space*i);
|
||||
for(var j=0; j<n; j++){
|
||||
var value = data[j][i].y;
|
||||
var yA = yOrigin;
|
||||
var x = xStart + (barWidth*j);
|
||||
var y = plot.axisY.getCoord(value, plotarea, plot);
|
||||
var h = Math.abs(yA-y);
|
||||
if(value < plot.axisX.origin){
|
||||
yA = y;
|
||||
y = yOrigin;
|
||||
}
|
||||
|
||||
var bar=document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
bar.setAttribute("fill", data[j][i].series.color);
|
||||
bar.setAttribute("stroke-width", "0");
|
||||
bar.setAttribute("x", x);
|
||||
bar.setAttribute("y", y);
|
||||
bar.setAttribute("width", barWidth);
|
||||
bar.setAttribute("height", h);
|
||||
bar.setAttribute("fill-opacity", "0.6");
|
||||
if(applyTo){ applyTo(bar, data[j][i].src); }
|
||||
group.appendChild(bar);
|
||||
}
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
HorizontalBar: function(
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* object? */kwArgs,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots data in a set of grouped bars horizontally.
|
||||
// Bindings: y
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
// precompile the data
|
||||
var n = plot.series.length; // how many series
|
||||
var data = [];
|
||||
for(var i=0; i<n; i++){
|
||||
var tmp = plot.series[i].data.evaluate(kwArgs);
|
||||
data.push(tmp);
|
||||
}
|
||||
|
||||
var space = 6;
|
||||
var nPoints = data[0].length;
|
||||
var h = ((area.bottom-area.top)-(space*(nPoints-1)))/nPoints;
|
||||
var barH = h/n;
|
||||
var xOrigin = plot.axisX.getCoord(0, plotarea, plot);
|
||||
|
||||
for(var i=0; i<nPoints; i++){
|
||||
// calculate offset
|
||||
var yStart = area.top+(h*i)+(space*i);
|
||||
for(var j=0; j<n; j++){
|
||||
var value = data[j][i].y;
|
||||
var y = yStart + (barH*j);
|
||||
var xA = xOrigin;
|
||||
var x = plot.axisX.getCoord(value, plotarea, plot);
|
||||
var w = Math.abs(x-xA);
|
||||
if(value > 0){
|
||||
x = xOrigin;
|
||||
}
|
||||
|
||||
var bar=document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
bar.setAttribute("fill", data[j][i].series.color);
|
||||
bar.setAttribute("stroke-width", "0");
|
||||
bar.setAttribute("x", xA);
|
||||
bar.setAttribute("y", y);
|
||||
bar.setAttribute("width", w);
|
||||
bar.setAttribute("height", barH);
|
||||
bar.setAttribute("fill-opacity", "0.6");
|
||||
if(applyTo){ applyTo(bar, data[j][i].src); }
|
||||
group.appendChild(bar);
|
||||
}
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
Gantt: function(
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* object? */kwArgs,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots a grouped set of Gantt bars
|
||||
// Bindings: high/low
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
// precompile the data
|
||||
var n = plot.series.length; // how many series
|
||||
var data = [];
|
||||
for(var i=0; i<n; i++){
|
||||
var tmp = plot.series[i].data.evaluate(kwArgs);
|
||||
data.push(tmp);
|
||||
}
|
||||
|
||||
var space = 2;
|
||||
var nPoints = data[0].length;
|
||||
var h = ((area.bottom-area.top)-(space*(nPoints-1)))/nPoints;
|
||||
var barH = h/n;
|
||||
for(var i=0; i<nPoints; i++){
|
||||
// calculate offset
|
||||
var yStart = area.top+(h*i)+(space*i);
|
||||
for(var j=0; j<n; j++){
|
||||
var high = data[j][i].high;
|
||||
var low = data[j][i].low;
|
||||
if(low > high){
|
||||
var t = high;
|
||||
high = low;
|
||||
low = t;
|
||||
}
|
||||
var x = plot.axisX.getCoord(low, plotarea, plot);
|
||||
var w = plot.axisX.getCoord(high, plotarea, plot) - x;
|
||||
var y = yStart + (barH*j);
|
||||
|
||||
var bar=document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
bar.setAttribute("fill", data[j][i].series.color);
|
||||
bar.setAttribute("stroke-width", "0");
|
||||
bar.setAttribute("x", x);
|
||||
bar.setAttribute("y", y);
|
||||
bar.setAttribute("width", w);
|
||||
bar.setAttribute("height", barH);
|
||||
bar.setAttribute("fill-opacity", "0.6");
|
||||
if(applyTo){ applyTo(bar, data[j][i].src); }
|
||||
group.appendChild(bar);
|
||||
}
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
StackedArea: function(
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* object? */kwArgs,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots a set of stacked areas.
|
||||
// Bindings: x/y
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
// precompile the data
|
||||
var n = plot.series.length; // how many series
|
||||
var data = [];
|
||||
var totals = [];
|
||||
|
||||
// we're assuming that all series for this plot has the name x assignment for now.
|
||||
for(var i=0; i<n; i++){
|
||||
var tmp = plot.series[i].data.evaluate(kwArgs);
|
||||
// run through and add current totals
|
||||
for(var j=0; j<tmp.length; j++){
|
||||
if(i==0){ totals.push(tmp[j].y); }
|
||||
else { totals[j] += tmp[j].y; }
|
||||
tmp[j].y = totals[j];
|
||||
}
|
||||
data.push(tmp);
|
||||
}
|
||||
|
||||
for(var i=n-1; i>=0; i--){
|
||||
var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
|
||||
path.setAttribute("fill", data[i][0].series.color);
|
||||
path.setAttribute("fill-opacity", "0.4");
|
||||
path.setAttribute("stroke", data[i][0].series.color);
|
||||
path.setAttribute("stroke-width" , "1");
|
||||
path.setAttribute("stroke-opacity", "0.85");
|
||||
|
||||
var cmd = [];
|
||||
var r=3;
|
||||
for(var j=0; j<data[i].length; j++){
|
||||
var values = data[i];
|
||||
var x = plot.axisX.getCoord(values[j].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(values[j].y, plotarea, plot);
|
||||
|
||||
if(j==0){ cmd.push("M"); }
|
||||
else { cmd.push("L"); }
|
||||
cmd.push(x+","+y);
|
||||
|
||||
// points on the line
|
||||
var c=document.createElementNS(dojo.svg.xmlns.svg, "circle");
|
||||
c.setAttribute("cx",x);
|
||||
c.setAttribute("cy",y);
|
||||
c.setAttribute("r","3");
|
||||
c.setAttribute("fill", values[j].series.color);
|
||||
c.setAttribute("fill-opacity", "0.6");
|
||||
c.setAttribute("stroke-width", "1");
|
||||
c.setAttribute("stroke-opacity", "0.85");
|
||||
group.appendChild(c);
|
||||
if(applyTo){ applyTo(c, data[i].src); }
|
||||
}
|
||||
|
||||
// now run the path backwards from the previous series.
|
||||
if(i == 0){
|
||||
cmd.push("L");
|
||||
cmd.push(x + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
|
||||
cmd.push("L");
|
||||
cmd.push(plot.axisX.getCoord(data[0][0].x, plotarea, plot) + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
|
||||
cmd.push("Z");
|
||||
} else {
|
||||
var values = data[i-1];
|
||||
cmd.push("L");
|
||||
cmd.push(x + "," + Math.round(plot.axisY.getCoord(values[values.length-1].y, plotarea, plot)));
|
||||
for(var j=values.length-2; j>=0; j--){
|
||||
var x = plot.axisX.getCoord(values[j].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(values[j].y, plotarea, plot);
|
||||
cmd.push("L");
|
||||
cmd.push(x+","+y);
|
||||
}
|
||||
}
|
||||
path.setAttribute("d", cmd.join(" ")+ " Z");
|
||||
group.appendChild(path);
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
StackedCurvedArea: function(
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* object? */kwArgs,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots a set of stacked areas, using a tensioning factor to soften points.
|
||||
// Bindings: x/y
|
||||
var tension = 3;
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
// precompile the data
|
||||
var n = plot.series.length; // how many series
|
||||
var data = [];
|
||||
var totals = [];
|
||||
|
||||
// we're assuming that all series for this plot has the name x assignment for now.
|
||||
for(var i=0; i<n; i++){
|
||||
var tmp = plot.series[i].data.evaluate(kwArgs);
|
||||
// run through and add current totals
|
||||
for(var j=0; j<tmp.length; j++){
|
||||
if(i==0){ totals.push(tmp[j].y); }
|
||||
else { totals[j] += tmp[j].y; }
|
||||
tmp[j].y = totals[j];
|
||||
}
|
||||
data.push(tmp);
|
||||
}
|
||||
|
||||
for(var i=n-1; i>=0; i--){
|
||||
var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
|
||||
path.setAttribute("fill", data[i][0].series.color);
|
||||
path.setAttribute("fill-opacity", "0.4");
|
||||
path.setAttribute("stroke", data[i][0].series.color);
|
||||
path.setAttribute("stroke-width" , "1");
|
||||
path.setAttribute("stroke-opacity", "0.85");
|
||||
|
||||
var cmd = [];
|
||||
var r=3;
|
||||
for(var j=0; j<data[i].length; j++){
|
||||
var values = data[i];
|
||||
var x = plot.axisX.getCoord(values[j].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(values[j].y, plotarea, plot);
|
||||
var dx = area.left + 1;
|
||||
var dy = area.bottom;
|
||||
if(j>0){
|
||||
dx = x - plot.axisX.getCoord(values[j-1].x, plotarea, plot);
|
||||
dy = plot.axisY.getCoord(values[j-1].y, plotarea, plot);
|
||||
}
|
||||
|
||||
if(j==0){ cmd.push("M"); }
|
||||
else {
|
||||
cmd.push("C");
|
||||
var cx = x-(tension-1) * (dx/tension);
|
||||
cmd.push(cx + "," + dy);
|
||||
cx = x - (dx/tension);
|
||||
cmd.push(cx + "," + y);
|
||||
}
|
||||
cmd.push(x+","+y);
|
||||
|
||||
// points on the line
|
||||
var c=document.createElementNS(dojo.svg.xmlns.svg, "circle");
|
||||
c.setAttribute("cx",x);
|
||||
c.setAttribute("cy",y);
|
||||
c.setAttribute("r","3");
|
||||
c.setAttribute("fill", values[j].series.color);
|
||||
c.setAttribute("fill-opacity", "0.6");
|
||||
c.setAttribute("stroke-width", "1");
|
||||
c.setAttribute("stroke-opacity", "0.85");
|
||||
group.appendChild(c);
|
||||
if(applyTo){ applyTo(c, data[i].src); }
|
||||
}
|
||||
|
||||
// now run the path backwards from the previous series.
|
||||
if(i == 0){
|
||||
cmd.push("L");
|
||||
cmd.push(x + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
|
||||
cmd.push("L");
|
||||
cmd.push(plot.axisX.getCoord(data[0][0].x, plotarea, plot) + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
|
||||
cmd.push("Z");
|
||||
} else {
|
||||
var values = data[i-1];
|
||||
cmd.push("L");
|
||||
cmd.push(x + "," + Math.round(plot.axisY.getCoord(values[values.length-1].y, plotarea, plot)));
|
||||
for(var j=values.length-2; j>=0; j--){
|
||||
var x = plot.axisX.getCoord(values[j].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(values[j].y, plotarea, plot);
|
||||
var dx = x - plot.axisX.getCoord(values[j+1].x, plotarea, plot);
|
||||
var dy = plot.axisY.getCoord(values[j+1].y, plotarea, plot);
|
||||
|
||||
cmd.push("C");
|
||||
var cx = x-(tension-1) * (dx/tension);
|
||||
cmd.push(cx + "," + dy);
|
||||
cx = x - (dx/tension);
|
||||
cmd.push(cx + "," + y);
|
||||
cmd.push(x+","+y);
|
||||
}
|
||||
}
|
||||
path.setAttribute("d", cmd.join(" ")+ " Z");
|
||||
group.appendChild(path);
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
|
||||
/*********************************************************
|
||||
* Single plotters: one series at a time.
|
||||
*********************************************************/
|
||||
DataBar: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots a set of bars in relation to y==0.
|
||||
// Bindings: x/y
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
var n = data.length;
|
||||
var w = (area.right-area.left)/(plot.axisX.range.upper - plot.axisX.range.lower); // the width of each group.
|
||||
var yOrigin = plot.axisY.getCoord(plot.axisX.origin, plotarea, plot);
|
||||
|
||||
for(var i=0; i<n; i++){
|
||||
// calculate offset
|
||||
var value = data[i].y;
|
||||
var yA = yOrigin;
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot) - (w/2);
|
||||
var y = plot.axisY.getCoord(value, plotarea, plot);
|
||||
var h = Math.abs(yA-y);
|
||||
if(value < plot.axisX.origin){
|
||||
yA = y;
|
||||
y = yOrigin;
|
||||
}
|
||||
var bar=document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
bar.setAttribute("fill", data[i].series.color);
|
||||
bar.setAttribute("stroke-width", "0");
|
||||
bar.setAttribute("x", x);
|
||||
bar.setAttribute("y", y);
|
||||
bar.setAttribute("width", w);
|
||||
bar.setAttribute("height", h);
|
||||
bar.setAttribute("fill-opacity", "0.6");
|
||||
if(applyTo){ applyTo(bar, data[i].src); }
|
||||
group.appendChild(bar);
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
Line: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as a line.
|
||||
// Bindings: x/y
|
||||
var area = plotarea.getArea();
|
||||
var line = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
|
||||
line.appendChild(path);
|
||||
|
||||
path.setAttribute("fill", "none");
|
||||
path.setAttribute("stroke", data[0].series.color);
|
||||
path.setAttribute("stroke-width" , "2");
|
||||
path.setAttribute("stroke-opacity", "0.85");
|
||||
if(data[0].series.label != null){
|
||||
path.setAttribute("title", data[0].series.label);
|
||||
}
|
||||
|
||||
var cmd=[];
|
||||
for(var i=0; i<data.length; i++){
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
|
||||
if(i==0){ cmd.push("M"); }
|
||||
else { cmd.push("L"); }
|
||||
cmd.push(x+","+y);
|
||||
|
||||
// points on the line
|
||||
var c=document.createElementNS(dojo.svg.xmlns.svg, "circle");
|
||||
c.setAttribute("cx",x);
|
||||
c.setAttribute("cy",y);
|
||||
c.setAttribute("r","3");
|
||||
c.setAttribute("fill", data[i].series.color);
|
||||
c.setAttribute("fill-opacity", "0.6");
|
||||
c.setAttribute("stroke-width", "1");
|
||||
c.setAttribute("stroke-opacity", "0.85");
|
||||
line.appendChild(c);
|
||||
if(applyTo){ applyTo(c, data[i].src); }
|
||||
}
|
||||
path.setAttribute("d", cmd.join(" "));
|
||||
return line; // SVGGElement
|
||||
},
|
||||
CurvedLine: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as a line with a tension factor for softening.
|
||||
// Bindings: x/y
|
||||
var tension = 3;
|
||||
var area = plotarea.getArea();
|
||||
var line = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
|
||||
line.appendChild(path);
|
||||
|
||||
path.setAttribute("fill", "none");
|
||||
path.setAttribute("stroke", data[0].series.color);
|
||||
path.setAttribute("stroke-width" , "2");
|
||||
path.setAttribute("stroke-opacity", "0.85");
|
||||
if(data[0].series.label != null){
|
||||
path.setAttribute("title", data[0].series.label);
|
||||
}
|
||||
|
||||
var cmd=[];
|
||||
for(var i=0; i<data.length; i++){
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
|
||||
var dx = area.left + 1;
|
||||
var dy = area.bottom;
|
||||
if(i>0){
|
||||
dx = x - plot.axisX.getCoord(data[i-1].x, plotarea, plot);
|
||||
dy = plot.axisY.getCoord(data[i-1].y, plotarea, plot);
|
||||
}
|
||||
|
||||
if(i==0){ cmd.push("M"); }
|
||||
else {
|
||||
cmd.push("C");
|
||||
var cx = x-(tension-1) * (dx/tension);
|
||||
cmd.push(cx + "," + dy);
|
||||
cx = x - (dx/tension);
|
||||
cmd.push(cx + "," + y);
|
||||
}
|
||||
cmd.push(x+","+y);
|
||||
|
||||
// points on the line
|
||||
var c=document.createElementNS(dojo.svg.xmlns.svg, "circle");
|
||||
c.setAttribute("cx",x);
|
||||
c.setAttribute("cy",y);
|
||||
c.setAttribute("r","3");
|
||||
c.setAttribute("fill", data[i].series.color);
|
||||
c.setAttribute("fill-opacity", "0.6");
|
||||
c.setAttribute("stroke-width", "1");
|
||||
c.setAttribute("stroke-opacity", "0.85");
|
||||
line.appendChild(c);
|
||||
if(applyTo){ applyTo(c, data[i].src); }
|
||||
}
|
||||
path.setAttribute("d", cmd.join(" "));
|
||||
return line; // SVGGElement
|
||||
},
|
||||
Area: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as an area.
|
||||
// Bindings: x/y
|
||||
var area = plotarea.getArea();
|
||||
var line = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
|
||||
line.appendChild(path);
|
||||
|
||||
path.setAttribute("fill", data[0].series.color);
|
||||
path.setAttribute("fill-opacity", "0.4");
|
||||
path.setAttribute("stroke", data[0].series.color);
|
||||
path.setAttribute("stroke-width" , "1");
|
||||
path.setAttribute("stroke-opacity", "0.85");
|
||||
if(data[0].series.label != null){
|
||||
path.setAttribute("title", data[0].series.label);
|
||||
}
|
||||
|
||||
var cmd=[];
|
||||
for(var i=0; i<data.length; i++){
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
|
||||
if(i==0){ cmd.push("M"); }
|
||||
else { cmd.push("L"); }
|
||||
cmd.push(x+","+y);
|
||||
|
||||
// points on the line
|
||||
var c=document.createElementNS(dojo.svg.xmlns.svg, "circle");
|
||||
c.setAttribute("cx",x);
|
||||
c.setAttribute("cy",y);
|
||||
c.setAttribute("r","3");
|
||||
c.setAttribute("fill", data[i].series.color);
|
||||
c.setAttribute("fill-opacity", "0.6");
|
||||
c.setAttribute("stroke-width", "1");
|
||||
c.setAttribute("stroke-opacity", "0.85");
|
||||
line.appendChild(c);
|
||||
if(applyTo){ applyTo(c, data[i].src); }
|
||||
}
|
||||
// finish it off
|
||||
cmd.push("L");
|
||||
cmd.push(x + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
|
||||
cmd.push("L");
|
||||
cmd.push(plot.axisX.getCoord(data[0].x, plotarea, plot) + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
|
||||
cmd.push("Z");
|
||||
path.setAttribute("d", cmd.join(" "));
|
||||
return line; // SVGGElement
|
||||
},
|
||||
CurvedArea: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as an area with a tension for softening.
|
||||
// Bindings: x/y
|
||||
var tension = 3;
|
||||
var area = plotarea.getArea();
|
||||
var line = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
var path = document.createElementNS(dojo.svg.xmlns.svg, "path");
|
||||
line.appendChild(path);
|
||||
|
||||
path.setAttribute("fill", data[0].series.color);
|
||||
path.setAttribute("fill-opacity", "0.4");
|
||||
path.setAttribute("stroke", data[0].series.color);
|
||||
path.setAttribute("stroke-width" , "1");
|
||||
path.setAttribute("stroke-opacity", "0.85");
|
||||
if(data[0].series.label != null){
|
||||
path.setAttribute("title", data[0].series.label);
|
||||
}
|
||||
|
||||
var cmd=[];
|
||||
for(var i=0; i<data.length; i++){
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
|
||||
var dx = area.left + 1;
|
||||
var dy = area.bottom;
|
||||
if(i>0){
|
||||
dx = x - plot.axisX.getCoord(data[i-1].x, plotarea, plot);
|
||||
dy = plot.axisY.getCoord(data[i-1].y, plotarea, plot);
|
||||
}
|
||||
|
||||
if(i==0){ cmd.push("M"); }
|
||||
else {
|
||||
cmd.push("C");
|
||||
var cx = x-(tension-1) * (dx/tension);
|
||||
cmd.push(cx + "," + dy);
|
||||
cx = x - (dx/tension);
|
||||
cmd.push(cx + "," + y);
|
||||
}
|
||||
cmd.push(x+","+y);
|
||||
|
||||
// points on the line
|
||||
var c=document.createElementNS(dojo.svg.xmlns.svg, "circle");
|
||||
c.setAttribute("cx",x);
|
||||
c.setAttribute("cy",y);
|
||||
c.setAttribute("r","3");
|
||||
c.setAttribute("fill", data[i].series.color);
|
||||
c.setAttribute("fill-opacity", "0.6");
|
||||
c.setAttribute("stroke-width", "1");
|
||||
c.setAttribute("stroke-opacity", "0.85");
|
||||
line.appendChild(c);
|
||||
if(applyTo){ applyTo(c, data[i].src); }
|
||||
}
|
||||
// finish it off
|
||||
cmd.push("L");
|
||||
cmd.push(x + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
|
||||
cmd.push("L");
|
||||
cmd.push(plot.axisX.getCoord(data[0].x, plotarea, plot) + "," + plot.axisY.getCoord(plot.axisX.origin, plotarea, plot));
|
||||
cmd.push("Z");
|
||||
path.setAttribute("d", cmd.join(" "));
|
||||
return line; // SVGGElement
|
||||
},
|
||||
HighLow: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as a set of high/low bars.
|
||||
// Bindings: x/high/low
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
var n = data.length;
|
||||
var part = ((area.right-area.left)/(plot.axisX.range.upper - plot.axisX.range.lower))/4;
|
||||
var w = part*2;
|
||||
|
||||
for(var i=0; i<n; i++){
|
||||
var high = data[i].high;
|
||||
var low = data[i].low;
|
||||
if(low > high){
|
||||
var t = low;
|
||||
low = high;
|
||||
high = t;
|
||||
}
|
||||
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot) - (w/2);
|
||||
var y = plot.axisY.getCoord(high, plotarea, plot);
|
||||
var h = plot.axisY.getCoord(low, plotarea, plot)-y;
|
||||
|
||||
// high + low
|
||||
var bar=document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
bar.setAttribute("fill", data[i].series.color);
|
||||
bar.setAttribute("stroke-width", "0");
|
||||
bar.setAttribute("x", x);
|
||||
bar.setAttribute("y", y);
|
||||
bar.setAttribute("width", w);
|
||||
bar.setAttribute("height", h);
|
||||
bar.setAttribute("fill-opacity", "0.6");
|
||||
if(applyTo){ applyTo(bar, data[i].src); }
|
||||
group.appendChild(bar);
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
HighLowClose: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as a set of high/low bars with a close indicator.
|
||||
// Bindings: x/high/low/close
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
var n = data.length;
|
||||
var part = ((area.right-area.left)/(plot.axisX.range.upper - plot.axisX.range.lower))/4;
|
||||
var w = part*2;
|
||||
|
||||
for(var i=0; i<n; i++){
|
||||
var high = data[i].high;
|
||||
var low = data[i].low;
|
||||
if(low > high){
|
||||
var t = low;
|
||||
low = high;
|
||||
high = t;
|
||||
}
|
||||
var c = data[i].close;
|
||||
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot) - (w/2);
|
||||
var y = plot.axisY.getCoord(high, plotarea, plot);
|
||||
var h = plot.axisY.getCoord(low, plotarea, plot)-y;
|
||||
var close = plot.axisY.getCoord(c, plotarea, plot);
|
||||
|
||||
var g = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
// high + low
|
||||
var bar=document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
bar.setAttribute("fill", data[i].series.color);
|
||||
bar.setAttribute("stroke-width", "0");
|
||||
bar.setAttribute("x", x);
|
||||
bar.setAttribute("y", y);
|
||||
bar.setAttribute("width", w);
|
||||
bar.setAttribute("height", h);
|
||||
bar.setAttribute("fill-opacity", "0.6");
|
||||
g.appendChild(bar);
|
||||
|
||||
// close
|
||||
var line=document.createElementNS(dojo.svg.xmlns.svg, "line");
|
||||
line.setAttribute("x1", x);
|
||||
line.setAttribute("x2", x+w+(part*2));
|
||||
line.setAttribute("y1", close);
|
||||
line.setAttribute("y2", close);
|
||||
line.setAttribute("style", "stroke:"+data[i].series.color+";stroke-width:1px;stroke-opacity:0.6;");
|
||||
g.appendChild(line);
|
||||
|
||||
if(applyTo){ applyTo(g, data[i].src); }
|
||||
group.appendChild(g);
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
HighLowOpenClose: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as a set of high/low bars with open and close indicators.
|
||||
// Bindings: x/high/low/open/close
|
||||
var area = plotarea.getArea();
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
var n = data.length;
|
||||
var part = ((area.right-area.left)/(plot.axisX.range.upper - plot.axisX.range.lower))/4;
|
||||
var w = part*2;
|
||||
|
||||
for(var i=0; i<n; i++){
|
||||
var high = data[i].high;
|
||||
var low = data[i].low;
|
||||
if(low > high){
|
||||
var t = low;
|
||||
low = high;
|
||||
high = t;
|
||||
}
|
||||
var o = data[i].open;
|
||||
var c = data[i].close;
|
||||
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot) - (w/2);
|
||||
var y = plot.axisY.getCoord(high, plotarea, plot);
|
||||
var h = plot.axisY.getCoord(low, plotarea, plot)-y;
|
||||
var open = plot.axisY.getCoord(o, plotarea, plot);
|
||||
var close = plot.axisY.getCoord(c, plotarea, plot);
|
||||
|
||||
var g = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
|
||||
// high + low
|
||||
var bar=document.createElementNS(dojo.svg.xmlns.svg, "rect");
|
||||
bar.setAttribute("fill", data[i].series.color);
|
||||
bar.setAttribute("stroke-width", "0");
|
||||
bar.setAttribute("x", x);
|
||||
bar.setAttribute("y", y);
|
||||
bar.setAttribute("width", w);
|
||||
bar.setAttribute("height", h);
|
||||
bar.setAttribute("fill-opacity", "0.6");
|
||||
g.appendChild(bar);
|
||||
|
||||
// open
|
||||
var line=document.createElementNS(dojo.svg.xmlns.svg, "line");
|
||||
line.setAttribute("x1", x-(part*2));
|
||||
line.setAttribute("x2", x+w);
|
||||
line.setAttribute("y1", open);
|
||||
line.setAttribute("y2", open);
|
||||
line.setAttribute("style", "stroke:"+data[i].series.color+";stroke-width:1px;stroke-opacity:0.6;");
|
||||
g.appendChild(line);
|
||||
|
||||
// close
|
||||
var line=document.createElementNS(dojo.svg.xmlns.svg, "line");
|
||||
line.setAttribute("x1", x);
|
||||
line.setAttribute("x2", x+w+(part*2));
|
||||
line.setAttribute("y1", close);
|
||||
line.setAttribute("y2", close);
|
||||
line.setAttribute("style", "stroke:"+data[i].series.color+";stroke-width:1px;stroke-opacity:0.6;");
|
||||
g.appendChild(line);
|
||||
|
||||
if(applyTo){ applyTo(g, data[i].src); }
|
||||
group.appendChild(g);
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
Scatter: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as a set of points.
|
||||
// Bindings: x/y
|
||||
var r=7;
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
for (var i=0; i<data.length; i++){
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
|
||||
var point = document.createElementNS(dojo.svg.xmlns.svg, "path");
|
||||
point.setAttribute("fill", data[i].series.color);
|
||||
point.setAttribute("stroke-width", "0");
|
||||
point.setAttribute("d",
|
||||
"M " + x + "," + (y-r) + " " +
|
||||
"Q " + x + "," + y + " " + (x+r) + "," + y + " " +
|
||||
"Q " + x + "," + y + " " + x + "," + (y+r) + " " +
|
||||
"Q " + x + "," + y + " " + (x-r) + "," + y + " " +
|
||||
"Q " + x + "," + y + " " + x + "," + (y-r) + " " +
|
||||
"Z"
|
||||
);
|
||||
if(applyTo){ applyTo(point, data[i].src); }
|
||||
group.appendChild(point);
|
||||
}
|
||||
return group; // SVGGElement
|
||||
},
|
||||
Bubble: function(
|
||||
/* array */data,
|
||||
/* dojo.charting.PlotArea */plotarea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* function? */applyTo
|
||||
){
|
||||
// summary
|
||||
// Plots the series as a set of points with a size factor.
|
||||
// Bindings: x/y/size
|
||||
var group = document.createElementNS(dojo.svg.xmlns.svg, "g");
|
||||
var sizeFactor=1;
|
||||
for (var i=0; i<data.length; i++){
|
||||
var x = plot.axisX.getCoord(data[i].x, plotarea, plot);
|
||||
var y = plot.axisY.getCoord(data[i].y, plotarea, plot);
|
||||
if(i==0){
|
||||
// figure out the size factor, start with the axis with the greater range.
|
||||
var raw = data[i].size;
|
||||
var dy = plot.axisY.getCoord(data[i].y + raw, plotarea, plot)-y;
|
||||
sizeFactor = dy/raw;
|
||||
}
|
||||
if(sizeFactor<1) { sizeFactor = 1; }
|
||||
var point = document.createElementNS(dojo.svg.xmlns.svg, "circle");
|
||||
point.setAttribute("fill", data[i].series.color);
|
||||
point.setAttribute("fill-opacity", "0.8");
|
||||
point.setAttribute("stroke", data[i].series.color);
|
||||
point.setAttribute("stroke-width", "1");
|
||||
point.setAttribute("cx",x);
|
||||
point.setAttribute("cy",y);
|
||||
point.setAttribute("r", (data[i].size/2)*sizeFactor);
|
||||
if(applyTo){ applyTo(point, data[i].src); }
|
||||
group.appendChild(point);
|
||||
}
|
||||
return group; // SVGGElement
|
||||
}
|
||||
});
|
||||
dojo.charting.Plotters["Default"] = dojo.charting.Plotters.Line;
|
||||
}
|
272
source/web/scripts/ajax/dojo/src/charting/vml/Axis.js
Normal file
272
source/web/scripts/ajax/dojo/src/charting/vml/Axis.js
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.vml.Axis");
|
||||
dojo.require("dojo.lang.common");
|
||||
|
||||
if(dojo.render.vml.capable){
|
||||
dojo.extend(dojo.charting.Axis, {
|
||||
renderLines: function(
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* string */plane
|
||||
){
|
||||
// summary
|
||||
// Renders any reference lines for this axis.
|
||||
if(this.nodes.lines){
|
||||
while(this.nodes.lines.childNodes.length > 0){
|
||||
this.nodes.lines.removeChild(this.nodes.lines.childNodes[0]);
|
||||
}
|
||||
if(this.nodes.lines.parentNode){
|
||||
this.nodes.lines.parentNode.removeChild(this.nodes.lines);
|
||||
this.nodes.lines = null;
|
||||
}
|
||||
}
|
||||
|
||||
var area = plotArea.getArea();
|
||||
var g = this.nodes.lines = document.createElement("div");
|
||||
g.setAttribute("id", this.getId()+"-lines");
|
||||
for(var i=0; i<this._labels.length; i++){
|
||||
if (this._labels[i].value == this.origin){ continue; }
|
||||
|
||||
var v = this.getCoord(this._labels[i].value, plotArea, plot);
|
||||
var l=document.createElement("v:line");
|
||||
var str=document.createElement("v:stroke");
|
||||
str.dashstyle="dot";
|
||||
l.appendChild(str);
|
||||
l.setAttribute("strokecolor", "#666");
|
||||
l.setAttribute("strokeweight", "1px");
|
||||
var s=l.style;
|
||||
s.position="absolute";
|
||||
s.top="0px";
|
||||
s.left="0px";
|
||||
s.antialias="false";
|
||||
if(plane == "x"){
|
||||
l.setAttribute("from", v+"px,"+area.top+"px");
|
||||
l.setAttribute("to", v+"px,"+area.bottom+"px");
|
||||
}
|
||||
else if (plane == "y"){
|
||||
l.setAttribute("from", area.left+"px,"+v+"px");
|
||||
l.setAttribute("to", area.right+"px,"+v+"px");
|
||||
}
|
||||
g.appendChild(l);
|
||||
}
|
||||
return g; // HTMLDivElement
|
||||
},
|
||||
renderTicks: function(
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* string */plane,
|
||||
/* float */coord
|
||||
){
|
||||
// summary
|
||||
// Renders any tick lines for this axis.
|
||||
if(this.nodes.ticks){
|
||||
while(this.nodes.ticks.childNodes.length > 0){
|
||||
this.nodes.ticks.removeChild(this.nodes.ticks.childNodes[0]);
|
||||
}
|
||||
if(this.nodes.ticks.parentNode){
|
||||
this.nodes.ticks.parentNode.removeChild(this.nodes.ticks);
|
||||
this.nodes.ticks = null;
|
||||
}
|
||||
}
|
||||
|
||||
var g = this.nodes.ticks = document.createElement("div");
|
||||
g.setAttribute("id", this.getId()+"-ticks");
|
||||
for(var i=0; i<this._labels.length; i++){
|
||||
var v = this.getCoord(this._labels[i].value, plotArea, plot);
|
||||
|
||||
var l=document.createElement("v:line");
|
||||
l.setAttribute("strokecolor", "#000");
|
||||
l.setAttribute("strokeweight", "1px");
|
||||
var s=l.style;
|
||||
s.position="absolute";
|
||||
s.top="0px";
|
||||
s.left="0px";
|
||||
s.antialias="false";
|
||||
if(plane == "x"){
|
||||
l.setAttribute("from", v+"px,"+coord+"px");
|
||||
l.setAttribute("to", v+"px,"+(coord+3)+"px");
|
||||
}
|
||||
else if (plane == "y"){
|
||||
l.setAttribute("from", (coord-2)+"px,"+v+"px");
|
||||
l.setAttribute("to", (coord+2)+"px,"+v+"px");
|
||||
}
|
||||
g.appendChild(l);
|
||||
}
|
||||
return g; // HTMLDivElement
|
||||
},
|
||||
renderLabels: function(
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* string */plane,
|
||||
/* float */coord,
|
||||
/* int */textSize,
|
||||
/* string */anchor
|
||||
){
|
||||
// summary
|
||||
// Render all labels for this axis.
|
||||
function createLabel(label, x, y, textSize, anchor){
|
||||
var text = document.createElement("div");
|
||||
var s=text.style;
|
||||
text.innerHTML=label;
|
||||
s.fontSize=textSize+"px";
|
||||
s.fontFamily="sans-serif";
|
||||
s.position="absolute";
|
||||
s.top = y+"px";
|
||||
if(anchor == "center"){
|
||||
s.left = x + "px";
|
||||
s.textAlign="center";
|
||||
} else if (anchor == "left"){
|
||||
s.left = x + "px";
|
||||
s.textAlign="left";
|
||||
} else if (anchor == "right"){
|
||||
s.right = x + "px";
|
||||
s.textAlign="right";
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
// wipe if needed
|
||||
if(this.nodes.labels){
|
||||
while(this.nodes.labels.childNodes.length > 0){
|
||||
this.nodes.labels.removeChild(this.nodes.labels.childNodes[0]);
|
||||
}
|
||||
if(this.nodes.labels.parentNode){
|
||||
this.nodes.labels.parentNode.removeChild(this.nodes.labels);
|
||||
this.nodes.labels = null;
|
||||
}
|
||||
}
|
||||
var g = this.nodes.labels = document.createElement("div");
|
||||
g.setAttribute("id", this.getId()+"-labels");
|
||||
|
||||
for(var i=0; i<this._labels.length; i++){
|
||||
var v = this.getCoord(this._labels[i].value, plotArea, plot);
|
||||
if(plane == "x"){
|
||||
// ugly hack but it works.
|
||||
var node=createLabel(this._labels[i].label, v, coord, textSize, anchor);
|
||||
document.body.appendChild(node);
|
||||
node.style.left = v-(node.offsetWidth/2)+"px";
|
||||
g.appendChild(node);
|
||||
}
|
||||
else if (plane == "y"){
|
||||
var node = createLabel(this._labels[i].label, coord, v, textSize, anchor);
|
||||
document.body.appendChild(node);
|
||||
node.style.top = v-(node.offsetHeight/2)+"px";
|
||||
g.appendChild(node);
|
||||
}
|
||||
}
|
||||
return g; // HTMLDivElement
|
||||
},
|
||||
render: function(
|
||||
/* dojo.charting.PlotArea */plotArea,
|
||||
/* dojo.charting.Plot */plot,
|
||||
/* dojo.charting.Axis */drawAgainst,
|
||||
/* string */plane
|
||||
){
|
||||
// summary
|
||||
// Renders this axis to the given plot.
|
||||
|
||||
// get the origin plot point.
|
||||
var area = plotArea.getArea();
|
||||
var stroke = 1;
|
||||
var style = "stroke:#000;stroke-width:"+stroke+"px;";
|
||||
var textSize=10;
|
||||
var coord = drawAgainst.getCoord(this.origin, plotArea, plot);
|
||||
|
||||
// draw the axis.
|
||||
var g = this.nodes.main = document.createElement("div");
|
||||
g.setAttribute("id", this.getId()); // need a handle if we have to kill parts of the axis def.
|
||||
var line = this.nodes.axis = document.createElement("v:line");
|
||||
line.setAttribute("strokecolor", "#000");
|
||||
line.setAttribute("strokeweight", stroke+"px");
|
||||
var s=line.style;
|
||||
s.position="absolute";
|
||||
s.top="0px";
|
||||
s.left="0px";
|
||||
s.antialias="false";
|
||||
if(plane == "x"){
|
||||
line.setAttribute("from", area.left+"px,"+coord+"px");
|
||||
line.setAttribute("to", area.right+"px,"+coord+"px");
|
||||
|
||||
// set up the labels
|
||||
var y = coord + Math.floor(textSize/2);
|
||||
if(this.showLines){
|
||||
g.appendChild(this.renderLines(plotArea, plot, plane, y));
|
||||
}
|
||||
if(this.showTicks){
|
||||
g.appendChild(this.renderTicks(plotArea, plot, plane, coord));
|
||||
}
|
||||
if(this.showLabels){
|
||||
g.appendChild(this.renderLabels(plotArea, plot, plane, y, textSize, "center"));
|
||||
}
|
||||
if(this.showLabel && this.label){
|
||||
var x = plotArea.size.width/2;
|
||||
var y = coord + Math.round(textSize*1.5);
|
||||
var text = document.createElement("div");
|
||||
var s=text.style;
|
||||
text.innerHTML=this.label;
|
||||
s.fontSize=(textSize+2)+"px";
|
||||
s.fontFamily="sans-serif";
|
||||
s.fontWeight="bold";
|
||||
s.position="absolute";
|
||||
s.top = y+"px";
|
||||
s.left = x + "px";
|
||||
s.textAlign="center";
|
||||
document.body.appendChild(text);
|
||||
text.style.left = x-(text.offsetWidth/2)+"px";
|
||||
g.appendChild(text);
|
||||
}
|
||||
} else {
|
||||
line.setAttribute("from", coord+"px,"+area.top+"px");
|
||||
line.setAttribute("to", coord+"px,"+area.bottom+"px");
|
||||
|
||||
// set up the labels
|
||||
var isMax = this.origin == drawAgainst.range.upper;
|
||||
var x = coord+4;
|
||||
var anchor = "left";
|
||||
if(!isMax){
|
||||
x = area.right-coord+textSize+4;
|
||||
anchor = "right";
|
||||
if(coord == area.left){ x += (textSize*2)-(textSize/2); }
|
||||
}
|
||||
if(this.showLines){
|
||||
g.appendChild(this.renderLines(plotArea, plot, plane, x));
|
||||
}
|
||||
if(this.showTicks){
|
||||
g.appendChild(this.renderTicks(plotArea, plot, plane, coord));
|
||||
}
|
||||
if(this.showLabels){
|
||||
g.appendChild(this.renderLabels(plotArea, plot, plane, x, textSize, anchor));
|
||||
}
|
||||
if(this.showLabel && this.label){
|
||||
x += (textSize*2)-2;
|
||||
var y = plotArea.size.height/2;
|
||||
var text = document.createElement("div");
|
||||
var s=text.style;
|
||||
text.innerHTML=this.label;
|
||||
s.fontSize=(textSize+2)+"px";
|
||||
s.fontFamily="sans-serif";
|
||||
s.fontWeight="bold";
|
||||
s.position="absolute";
|
||||
s.height = plotArea.size.height+"px";
|
||||
s.writingMode = "tb-rl";
|
||||
s.textAlign="center";
|
||||
s[anchor] = x+"px";
|
||||
document.body.appendChild(text);
|
||||
s.top = y-(text.offsetHeight/2)+"px";
|
||||
g.appendChild(text);
|
||||
}
|
||||
}
|
||||
g.appendChild(line);
|
||||
return g; // HTMLDivElement
|
||||
}
|
||||
});
|
||||
}
|
80
source/web/scripts/ajax/dojo/src/charting/vml/PlotArea.js
Normal file
80
source/web/scripts/ajax/dojo/src/charting/vml/PlotArea.js
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.charting.vml.PlotArea");
|
||||
dojo.require("dojo.lang.common");
|
||||
|
||||
if(dojo.render.vml.capable){
|
||||
dojo.extend(dojo.charting.PlotArea, {
|
||||
initializePlot: function(plot){
|
||||
// summary
|
||||
// Initialize the plot node for data rendering.
|
||||
plot.destroy();
|
||||
plot.dataNode = document.createElement("div");
|
||||
plot.dataNode.id = plot.getId();
|
||||
return plot.dataNode; // HTMLDivElement
|
||||
},
|
||||
initialize:function(){
|
||||
// summary
|
||||
// Initialize the PlotArea.
|
||||
|
||||
this.destroy(); // kill everything first.
|
||||
var main = this.nodes.main = document.createElement("div");
|
||||
|
||||
// start with the background
|
||||
var area = this.nodes.area = document.createElement("div");
|
||||
area.id = this.getId();
|
||||
area.style.width=this.size.width+"px";
|
||||
area.style.height=this.size.height+"px";
|
||||
area.style.position="absolute";
|
||||
main.appendChild(area);
|
||||
|
||||
var bg = this.nodes.background = document.createElement("div");
|
||||
bg.id = this.getId()+"-background";
|
||||
bg.style.width=this.size.width+"px";
|
||||
bg.style.height=this.size.height+"px";
|
||||
bg.style.position="absolute";
|
||||
bg.style.top="0px";
|
||||
bg.style.left="0px";
|
||||
bg.style.backgroundColor="#fff";
|
||||
area.appendChild(bg);
|
||||
|
||||
// the plot group
|
||||
var a=this.getArea();
|
||||
var plots = this.nodes.plots = document.createElement("div");
|
||||
plots.id = this.getId()+"-plots";
|
||||
plots.style.width=this.size.width+"px";
|
||||
plots.style.height=this.size.height+"px";
|
||||
plots.style.position="absolute";
|
||||
plots.style.top="0px";
|
||||
plots.style.left="0px";
|
||||
plots.style.clip="rect("
|
||||
+ a.top+" "
|
||||
+ a.right+" "
|
||||
+ a.bottom+" "
|
||||
+ a.left
|
||||
+")";
|
||||
area.appendChild(plots);
|
||||
for(var i=0; i<this.plots.length; i++){
|
||||
plots.appendChild(this.initializePlot(this.plots[i]));
|
||||
}
|
||||
|
||||
var axes = this.nodes.axes = document.createElement("div");
|
||||
axes.id = this.getId() + "-axes";
|
||||
area.appendChild(axes);
|
||||
var ax = this.getAxes();
|
||||
for(var p in ax){
|
||||
var obj = ax[p];
|
||||
axes.appendChild(obj.axis.initialize(this, obj.plot, obj.drawAgainst, obj.plane));
|
||||
}
|
||||
return main; // HTMLDivElement
|
||||
}
|
||||
});
|
||||
}
|
1077
source/web/scripts/ajax/dojo/src/charting/vml/Plotters.js
Normal file
1077
source/web/scripts/ajax/dojo/src/charting/vml/Plotters.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user