<html>
<head>
<style>
/*Supplemental: CSS for the YUI distribution*/
#custom-doc { width: 95%; min-width: 950px; }
#mychart {
padding:10px 10px 10px 10px;
}
</style>
</head>
<body class="yui3-skin-sam">
<h3>Unit Tests</h3>
<div id="mychart"></div>
<script>
YUI({
allowRollup: false,
filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min'
}).use('charts', 'test', 'console', function (Y)
{
var ENGINE = "VML",
DOCUMENT = Y.config.doc,
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
TestSVGNodes = function(lineStyles, tickStyles, valueLinePath, valueTickPath, catLinePath, catTickPath)
{
var lineColor = lineStyles.color,
lineWeight = lineStyles.weight,
lineOpacity = lineStyles.alpha,
tickColor = tickStyles.color,
tickWeight = tickStyles.weight,
tickOpacity = tickStyles.alpha;
valueLineNode = valueLinePath.get("node");
valueTickNode = valueTickPath.get("node");
catLineNode = catLinePath.get("node");
catTickNode = catTickPath.get("node");
return ( lineColor == valueLineNode.getAttribute("stroke") &&
parseFloat(lineWeight) === parseFloat(valueLineNode.getAttribute("stroke-width")) &&
parseFloat(lineOpacity) === parseFloat(valueLineNode.getAttribute("stroke-opacity")) &&
lineColor == catLineNode.getAttribute("stroke") &&
parseFloat(lineWeight) === parseFloat(catLineNode.getAttribute("stroke-width")) &&
parseFloat(lineOpacity) === parseFloat(catLineNode.getAttribute("stroke-opacity")) &&
tickColor == valueTickNode.getAttribute("stroke") &&
parseFloat(tickWeight) === parseFloat(valueTickNode.getAttribute("stroke-width")) &&
parseFloat(tickOpacity) === parseFloat(valueTickNode.getAttribute("stroke-opacity")) &&
tickColor == catTickNode.getAttribute("stroke") &&
parseFloat(tickWeight) === parseFloat(catTickNode.getAttribute("stroke-width")) &&
parseFloat(tickOpacity) === parseFloat(catTickNode.getAttribute("stroke-opacity")));
},
compareVMLColors = function(color, strokeNode, node)
{
var toHex = Y.Color.toHex,
color = toHex(color);
return (color == toHex(strokeNode.color) || color == toHex(strokeNode.color.value)) ||
(color == toHex(node.strokecolor) || color == toHex(node.strokecolor.value));
},
compareVMLStrokeWeight = function(weight, strokeNode, node)
{
weight = parseFloat(weight);
alert(weight + ", " + node.strokeWeight);
alert(weight + ", " + strokeNode.weight);
return weight === parseFloat(strokeNode.weight) || weight === parseFloat(node.strokeWeight);
},
TestVMLNodes = function(lineStyles, tickStyles, valueLinePath, valueTickPath, catLinePath, catTickPath)
{
var lineColor = lineStyles.color,
lineWeight = lineStyles.weight,
lineOpacity = lineStyles.alpha,
tickColor = tickStyles.color,
tickWeight = tickStyles.weight,
tickOpacity = tickStyles.alpha;
valueLineStrokeNode = valueLinePath._strokeNode;
valueTickStrokeNode = valueTickPath._strokeNode;
valueLineNode = valueLinePath.get("stroke");
valueTickNode = valueTickPath.get("stroke");
catLineStrokeNode = catLinePath._strokeNode;
catTickStrokeNode = catTickPath._strokeNode;
catLineNode = catLinePath.get("node");
catTickNode = catTickPath.get("node");
return compareVMLColors(lineColor, valueLineStrokeNode, valueLineNode) &&
//compareVMLStrokeWeight(lineWeight, valueLineStrokeNode, valueLineNode) &&
parseFloat(lineOpacity) === parseFloat(valueLineStrokeNode.opacity) &&
compareVMLColors(lineColor, catLineStrokeNode, valueLineNode) &&
//compareVMLStrokeWeight(lineWeight, catLineStrokeNode, catLineNode) &&
parseFloat(lineOpacity) === parseFloat(catLineStrokeNode.opacity) &&
compareVMLColors(tickColor, valueTickStrokeNode, valueTickNode) &&
//compareVMLStrokeWeight(tickWeight, valueTickStrokeNode, valueTickNode) &&
parseFloat(tickOpacity) === parseFloat(valueTickStrokeNode.opacity) &&
compareVMLColors(tickColor, catTickStrokeNode, catTickNode) &&
//compareVMLStrokeWeight(tickWeight, catTickStrokeNode, catTickNode) &&
parseFloat(tickOpacity) === parseFloat(catTickStrokeNode.opacity);
},
toRGBA = function(val, alpha) {
alpha = (alpha !== undefined) ? alpha : 1;
if (!Y.Color.re_RGB.test(val)) {
val = Y.Color.toHex(val);
}
if(Y.Color.re_hex.exec(val)) {
val = 'rgba(' + [
parseInt(RegExp.$1, 16),
parseInt(RegExp.$2, 16),
parseInt(RegExp.$3, 16)
].join(',') + ',' + alpha + ')';
}
return val;
},
TestCanvasNodes = function(lineStyles, tickStyles, valueLinePath, valueTickPath, catLinePath, catTickPath)
{
var toHex = Y.Color.toHex,
lineColor = toHex(lineStyles.color),
lineWeight = lineStyles.weight,
lineOpacity = lineStyles.alpha,
tickColor = toHex(tickStyles.color),
tickWeight = tickStyles.weight,
tickOpacity = tickStyles.alpha,
valueLineContext = valueLinePath._context,
valueTickContext = valueTickPath._context,
catLineContext = catLinePath._context,
catTickContext = catTickPath._context,
valueLineColor = valueLineContext.strokeStyle,
valueTickColor = valueTickContext.strokeStyle,
catLineColor = catLineContext.strokeStyle,
catTickColor = catTickContext.strokeStyle;
lineOpacity = Y.Lang.isNumber(lineOpacity) ? lineOpacity : 1;
tickOpacity = Y.Lang.isNumber(tickOpacity) ? tickOpacity : 1;
//Test values line color and alpha
if(valueLineColor.indexOf("RGBA") > -1 || valueLineColor.indexOf("rgba") > -1)
{
valueLineColor = valueLineColor.toLowerCase();
valueLineColor = valueLineColor.replace(/, /g, ",");
if(valueLineColor != toRGBA(toHex(lineColor), lineOpacity))
{
return false;
}
}
else
{
if(toHex(valueLineColor) != lineColor)
{
return false;
}
}
//Test values ticks color and alpha
if(valueTickColor.indexOf("RGBA") > -1 || valueTickColor.indexOf("rgba") > -1)
{
valueTickColor = valueTickColor.toLowerCase();
valueTickColor = valueTickColor.replace(/, /g, ",");
if(valueTickColor != toRGBA(toHex(tickColor), tickOpacity))
{
return false;
}
}
else
{
if(toHex(valueTickColor) != tickColor)
{
return false;
}
}
//Test category line color and alpha
if(catLineColor.indexOf("RGBA") > -1 || catLineColor.indexOf("rgba") > -1)
{
catLineColor = catLineColor.toLowerCase();
catLineColor = catLineColor.replace(/, /g, ",");
if(catLineColor != toRGBA(toHex(lineColor), lineOpacity))
{
return false;
}
}
else
{
if(toHex(catLineColor) != lineColor)
{
return false;
}
}
//Test category ticks color and alpha
if(catTickColor.indexOf("RGBA") > -1 || catTickColor.indexOf("rgba") > -1)
{
catTickColor = catTickColor.toLowerCase();
catTickColor = catTickColor.replace(/, /g, ",");
if(catTickColor != toRGBA(toHex(tickColor), tickOpacity))
{
return false;
}
}
else
{
if(toHex(catTickColor) != tickColor)
{
return false;
}
}
return lineWeight == valueLineContext.lineWidth &&
lineWeight == catLineContext.lineWidth &&
tickWeight == valueTickContext.lineWidth &&
tickWeight == catTickContext.lineWidth;
};
if(DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"))
{
ENGINE = "SVG";
}
else if(canvas && canvas.getContext && canvas.getContext("2d"))
{
ENGINE = "Canvas";
}
AxisTestTemplate = function(cfg, globalCfg)
{
var i;
cfg.height = cfg.height || 300;
this.attrCfg = cfg;
for(i in globalCfg)
{
if(globalCfg.hasOwnProperty(i))
{
this[i] = globalCfg[i];
}
}
};
Y.extend(AxisTestTemplate, Y.Test.Case, {
setUp: function() {
},
tearDown: function() {
this.chart.destroy(true);
}
});
var AxisMinTestTemplate = function()
{
AxisMinTestTemplate.superclass.constructor.apply(this, arguments);
};
Y.extend(AxisMinTestTemplate, AxisTestTemplate, {
//Tests a NumericAxis minimum by applying the labelFunction of the axis to the set minimum value to the innerHTML of the first label.
//Tests a NumericAxis maximum (unset) by checking to ensure the last label has a numeric value greater than or equal to the largest value in the data set.
testMin: function()
{
var chart = this.chart,
setMin = this.setMin,
dataMax = this.dataMax;
this.eventListener = this.chart.on("chartRendered", function(e) {
var axis = chart.getAxisByKey("values"),
majorUnit = axis.get("styles").majorUnit,
count = majorUnit.count - 1,
labels = axis.get("labels"),
min = parseFloat(labels[0].innerHTML),
max = labels[count].innerHTML,
roundingMethod = axis.get("roundingMethod"),
setIntervals = Y.Lang.isNumber(roundingMethod);
if(setIntervals)
{
Y.assert((max - min) % roundingMethod === 0);
}
//if the roundingMethod is numeric the axis cannot guarantee that the maximum will be greater than the data maximum
if(!setIntervals || (count * roundingMethod) >= dataMax - setMin)
{
Y.assert(max >= dataMax);
}
});
this.chart.render("#mychart");
}
});
Y.AxisMinTestTemplate = AxisMinTestTemplate;
var AxisMaxTestTemplate = function()
{
AxisMaxTestTemplate.superclass.constructor.apply(this, arguments);
};
Y.extend(AxisMaxTestTemplate, AxisTestTemplate, {
//Tests a NumericAxis minimum and maximum by applying the labelFunction of the axis to the set minimum and maximum values and
//then comparing the innerHTML of the first and last labels
testMax: function()
{
var chart = this.chart,
setMax = this.setMax,
dataMin = this.dataMin;
this.eventListener = this.chart.on("chartRendered", function(e) {
var axis = chart.getAxisByKey("values"),
majorUnit = axis.get("styles").majorUnit,
count = majorUnit.count - 1,
labels = axis.get("labels"),
min = parseFloat(labels[0].innerHTML),
max = labels[count].innerHTML,
roundingMethod = axis.get("roundingMethod"),
setIntervals = Y.Lang.isNumber(roundingMethod);
if(setIntervals)
{
Y.assert((max - min) % roundingMethod === 0);
}
//if the roundingMethod is numeric the axis cannot guarantee that the minimum will be less than the data minimum
if(!setIntervals || (count * roundingMethod) >= setMax - dataMin)
{
Y.assert(min <= dataMin);
}
});
this.chart.render("#mychart");
}
});
Y.AxisMaxTestTemplate = AxisMaxTestTemplate;
var AxisMinAndMaxTestTemplate = function()
{
};
testMinAndMax: function()
{
var chart = this.chart,
setMax = this.setMax,
setMin = this.setMin;
count = majorUnit.count - 1,
labels = axis.get("labels");
Y.assert(labels[0].innerHTML == axis.get("labelFunction").apply(axis, [setMin, axis.get("labelFormat")]));
Y.assert(labels[count].innerHTML == axis.get("labelFunction").apply(axis, [setMax, axis.get("labelFormat")]));
});
this.chart.render("#mychart");
}
});
Y.AxisMinAndMaxTestTemplate = AxisMinAndMaxTestTemplate;
function AxisDataProviderTemplate()
{
};
testAxesMinAndMax: function()
{
var chart = this.chart,
maxValues = this.maxValues,
minValues = this.minValues;
catKey = chart.get("categoryKey"),
axis,
dataMin,
dataMax,
key,
seriesKey,
keys,
len,
seriesKey;
for(key in axes)
{
{
axis = axes[key];
keys = axis.get("keys");
for(seriesKey in keys)
{
{
maxValue = maxValues[seriesKey];
minValue = minValues[seriesKey];
}
}
}
}
});
this.chart.render("#mychart");
}
});
Y.AxisDataProviderTemplate = AxisDataProviderTemplate;
function AxisGraphicStylesTemplate()
{
switch(ENGINE)
{
case "SVG" :
this._testNodes = TestSVGNodes;
break;
case "Canvas" :
this._testNodes = TestCanvasNodes;
break;
case "VML" :
this._testNodes = TestVMLNodes;
break;
}
};
testGraphicStyles: function()
{
var chart = this.chart,
lineStyles = this.lineStyles,
tickStyles = this.tickStyles,
testNodes = this._testNodes;
catAxis = chart.getAxisByKey("category"),
valueLinePath = valueAxis.get("path"),
valueTickPath = valueAxis.get("tickPath"),
catLinePath = catAxis.get("path"),
catTickPath = catAxis.get("tickPath");
tickStyles,
valueLinePath,
valueTickPath,
catLinePath,
catTickPath
]
));
});
this.chart.render("#mychart");
}
});
Y.AxisGraphicStylesTemplate = AxisGraphicStylesTemplate;
AxesTests = new Y.Test.Case({
name: "Axes Tests",
setUp: function() {
var myDataValues = [
];
var mychart = new Y.Chart({width:400, height:300, dataProvider:myDataValues, seriesKeys:["values", "revenue"]});
mychart.render("#mychart");
this.chart = mychart;
},
tearDown: function() {
this.chart.destroy(true);
},
//Test axes data classes
testRemoveKey: function()
{
var assert = Y.Assert,
xAxis = this.chart.getCategoryAxis(),
yAxis = this.chart.getAxisByKey("values"),
keys,
l,
i;
}, this));
keys = yAxis.get("keyCollection");
}));
xAxis.removeKey("category");
yAxis.removeKey("revenue");
},
testAddKey: function()
{
var assert = Y.Assert,
yAxis = this.chart.getAxisByKey("values"),
keys,
pattern = [3700, 9100, 1100, 1900],
testarray,
i = 0;
l = 4;
keys = yAxis.get("keyCollection");
testarray = yAxis.getDataByKey("expenses");
for(; i < l; ++i)
{
assert.areEqual(pattern[i], testarray[i]);
}
}, this));
yAxis.addKey("expenses");
}
}),
AxisAlwaysShowZero = new Y.Test.Case({
name: "Axis alwaysShowZero Test",
setUp: function()
{
var myDataValues = [
];
this.chart = new Y.Chart({
width:400,
height:300,
dataProvider:myDataValues
});
},
tearDown: function() {
this.chart.destroy(true);
},
testAlwaysShowZero: function()
{
var chart = this.chart;
this.eventListener = this.chart.on("chartRendered", function(e) {
var i = 0,
yAxis = chart.getAxisByKey("values"),
majorUnit = yAxis.get("styles").majorUnit,
count = majorUnit.count,
labels = yAxis.get("labels"),
label;
for(; i < count; ++i)
{
label = parseFloat(labels[i].innerHTML);
if(label === 0)
{
break;
}
}
Y.assert(label === 0);
});
this.chart.render("#mychart");
}
}),
AxisAlwaysShowZeroFalse = new Y.Test.Case({
name: "Axis alwaysShowZero = false Test",
setUp: function()
{
var myDataValues = [
];
width:400,
height:300,
axes: {
values: {
alwaysShowZero: false
}
},
dataProvider:myDataValues
});
},
tearDown: function() {
this.chart.destroy(true);
},
testAlwaysShowZeroEqualsFalse: function()
{
var chart = this.chart;
var i = 0,
yAxis = chart.getAxisByKey("values"),
count = majorUnit.count,
labels = yAxis.get("labels"),
label;
for(; i < count; ++i)
{
label = parseFloat(labels[i].innerHTML);
if(label === 0)
{
break;
}
}
Y.assert(label !== 0);
});
this.chart.render("#mychart");
}
}),
allPositiveDataProvider = [
],
allPositiveDataProviderDataMax = 9100,
allPositiveDataProviderDataMin = 50,
positiveAndNegativeDataProvider = [
],
positiveAndNegativeDataProviderDataMax = 9100,
positiveAndNegativeDataProviderDataMin = -5000,
allNegativeDataProvider = [
],
allNegativeDataProviderDataMax = -50,
allNegativeDataProviderDataMin = -9100,
decimalDataProvider = [
],
decimalDataProviderDataMax = 9.1,
decimalDataProviderDataMin = 0.05,
missingDataSmallDataProvider = [
],
missingDataLargeDataProvider = [
],
AxisMaxWithDecimalsRoundingMethodNumericTest = new Y.AxisMaxTestTemplate({
axes: {
values: {
roundingMethod: 2,
maximum: 7.5
}
},
dataProvider: decimalDataProvider
},
{
name: "Axes Max with Decimals Test with roundingMethod=2",
dataMin: decimalDataProviderDataMin,
setMax: 7.5
}),
AxisMaxIntegerDecimalDataRoundingMethodNumericTest= new Y.AxisMaxTestTemplate({
axes: {
values: {
roundingMethod: 2,
maximum: 8
}
},
dataProvider: decimalDataProvider
},
{
name: "Axes Integer Max with Decimal Data Test with roundingMethod=2",
dataMin: decimalDataProviderDataMin,
setMax: 8
}),
AxisMaxWithPositiveAndNegativeDataRoundingMethodNumericTest = new Y.AxisMaxTestTemplate({
axes: {
values: {
maximum: 1492,
roundingMethod: 1000
}
},
dataProvider: positiveAndNegativeDataProvider
},
{
name: "Axes Max with Positive and Negative Data Test with roundingMethod=1000",
setMax: 1492,
dataMin: positiveAndNegativeDataProviderDataMin
}),
DualAxesMissingDataSmallTest = new Y.AxisDataProviderTemplate({
axes: {
leftAxis: {
keys: ["expenses"],
type: "numeric",
position: "left"
},
rightAxis: {
keys: ["revenue"],
type: "numeric",
position: "right"
}
},
categoryKey: "date",
dataProvider: missingDataSmallDataProvider
},
{
name: "Dual Axes Missing Data (small dataProvider) Test",
maxValues: {
expenses: 9100,
revenue: 2200
},
minValues: {
expenses: 3700,
revenue: 100
},
seriesKeys: ["expenses", "revenue"]
});
DualAxesMissingDataLargeTest = new Y.AxisDataProviderTemplate({
axes: {
leftAxis: {
keys: ["expenses"],
type: "numeric",
position: "left"
},
rightAxis: {
keys: ["revenue"],
type: "numeric",
position: "right"
}
},
categoryKey: "date",
dataProvider: missingDataLargeDataProvider
},
{
name: "Dual Axes Missing Data (large dataProvider) Test",
maxValues: {
expenses: 9100,
revenue: 2200
},
minValues: {
expenses: 3700,
revenue: 100
},
seriesKeys: ["expenses", "revenue"]
});
DualAxesMissingDataSmallAlwaysShowZeroFalseTest = new Y.AxisDataProviderTemplate({
axes: {
leftAxis: {
keys: ["expenses"],
type: "numeric",
position: "left",
alwaysShowZero: false
},
rightAxis: {
keys: ["revenue"],
type: "numeric",
position: "right",
alwaysShowZero: false
}
},
categoryKey: "date",
dataProvider: missingDataSmallDataProvider
},
{
name: "Dual Axes Missing Data (small dataProvider) Test with alwaysShowZero=false",
maxValues: {
expenses: 9100,
revenue: 2200
},
minValues: {
expenses: 3700,
revenue: 100
},
seriesKeys: ["expenses", "revenue"]
});
DualAxesMissingDataLargeAlwaysShowZeroFalseTest = new Y.AxisDataProviderTemplate({
axes: {
leftAxis: {
keys: ["expenses"],
type: "numeric",
position: "left",
alwaysShowZero: false
},
rightAxis: {
keys: ["revenue"],
type: "numeric",
position: "right",
alwaysShowZero: false
}
},
categoryKey: "date",
dataProvider: missingDataLargeDataProvider
},
{
name: "Dual Axes Missing Data (large dataProvider) Test with alwaysShowZero=false",
maxValues: {
expenses: 9100,
revenue: 2200
},
minValues: {
expenses: 3700,
revenue: 100
},
seriesKeys: ["expenses", "revenue"]
}),
LeftAndBottomAxisCustomTickAndLinesInsideTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "bottom",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}
},
values: {
position: "left",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Left and Bottom Axes with inside ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}),
LeftAndBottomAxisCustomTickAndLinesOutsideTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "bottom",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}
},
values: {
position: "left",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Left and Bottom Axes with outside ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}),
LeftAndBottomAxisCustomTickAndLinesCrossTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "bottom",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}
},
values: {
position: "left",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Left and Bottom Axes with cross ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}),
RightAndBottomAxisCustomTickAndLinesInsideTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "bottom",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}
},
values: {
position: "right",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Right and Bottom Axes with inside ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}),
RightAndBottomAxisCustomTickAndLinesOutsideTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "bottom",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}
},
values: {
position: "right",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Right and Bottom Axes with outside ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}),
RightAndBottomAxisCustomTickAndLinesCrossTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "bottom",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}
},
values: {
position: "left",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Right and Bottom Axes with cross ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}),
LeftAndTopAxisCustomTickAndLinesInsideTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "top",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}
},
values: {
position: "left",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Left and Top Axes with inside ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}),
LeftAndTopAxisCustomTickAndLinesOutsideTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "top",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}
},
values: {
position: "left",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Left and Top Axes with outside ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}),
LeftAndTopAxisCustomTickAndLinesCrossTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "top",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}
},
values: {
position: "left",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Left and Top Axes with cross ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}),
RightAndTopAxisCustomTickAndLinesInsideTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "top",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}
},
values: {
position: "right",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Right and Top Axes with inside ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
}),
RightAndTopAxisCustomTickAndLinesOutsideTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "top",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}
},
values: {
position: "right",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Right and Top Axes with outside ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "outside"
}
}),
RightAndTopAxisCustomTickAndLinesCrossTicks = new Y.AxisGraphicStylesTemplate({
axes: {
category: {
position: "top",
type: "category",
keys: ["category"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}
},
values: {
position: "left",
type: "numeric",
keys: ["expenses", "revenue"],
styles: {
line: {
weight: 2,
color: "#ff0000",
alpha: 1
},
majorTicks: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "cross"
}
}
}
},
dataProvider: allPositiveDataProvider
},
{
name: "Custom Right and Top Axes with cross ticks",
lineStyles: {
weight: 2,
color: "#ff0000",
alpha: 1
},
tickStyles: {
weight: 1,
color: "#0000ff",
alpha: 0.5,
display: "inside"
}
});
suite.add(AxesTests);
suite.add(AxisMaxWithDecimalsRoundingMethodNumericTest);
suite.add(AxisMaxIntegerDecimalDataRoundingMethodNumericTest);
suite.add(AxisMaxWithPositiveAndNegativeDataRoundingMethodNumericTest);
suite.add(AxisAlwaysShowZero);
suite.add(AxisAlwaysShowZeroFalse);
suite.add(DualAxesMissingDataSmallTest);
suite.add(DualAxesMissingDataLargeTest);
suite.add(DualAxesMissingDataSmallAlwaysShowZeroFalseTest);
suite.add(DualAxesMissingDataLargeAlwaysShowZeroFalseTest);
suite.add(LeftAndBottomAxisCustomTickAndLinesInsideTicks);
suite.add(LeftAndBottomAxisCustomTickAndLinesOutsideTicks);
suite.add(LeftAndBottomAxisCustomTickAndLinesCrossTicks);
suite.add(RightAndBottomAxisCustomTickAndLinesInsideTicks);
suite.add(RightAndBottomAxisCustomTickAndLinesOutsideTicks);
suite.add(RightAndBottomAxisCustomTickAndLinesCrossTicks);
suite.add(LeftAndTopAxisCustomTickAndLinesInsideTicks);
suite.add(LeftAndTopAxisCustomTickAndLinesOutsideTicks);
suite.add(LeftAndTopAxisCustomTickAndLinesCrossTicks);
suite.add(RightAndTopAxisCustomTickAndLinesInsideTicks);
suite.add(RightAndTopAxisCustomTickAndLinesOutsideTicks);
suite.add(RightAndTopAxisCustomTickAndLinesCrossTicks);
//create the console
var r = new Y.Console({
newestOnTop : false,
style: 'block' // to anchor in the example content
});
r.render('#testLogger');
//run the tests
Y.Test.Runner.add(suite);
});
</script>
</body>
</html>