<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>
/*Supplemental: CSS for the YUI distribution*/
#custom-doc { width: 95%; min-width: 950px; }
#pagetitle {background-image: url(/assets/bg_hd.gif);}
#mychart {
padding:10px 10px 10px 10px;
}
</style>
<link rel="stylesheet" type="text/css" href="/build/cssfonts/fonts-min.css">
</head>
<body class="yui3-skin-sam">
<h3>Unit Tests</h3>
<div id="mychart"></div>
<script type="text/javascript" src="/build/yui/yui-min.js"></script>
<script>
YUI({
allowRollup: false,
filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min'
}).use('charts', 'test', 'console', function (Y)
{
Y.namespace("example.test");
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;
AxisTestTemplate.superclass.constructor.apply(this);
cfg.width = cfg.width || 400;
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() {
this.chart = new Y.Chart(this.attrCfg);
},
tearDown: function() {
this.eventListener.detach();
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);
Y.assert(min == axis.get("labelFunction").apply(axis, [setMin, axis.get("labelFormat")]));
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);
Y.assert(max == axis.get("labelFunction").apply(axis, [setMax, axis.get("labelFormat")]));
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()
{
AxisMinAndMaxTestTemplate.superclass.constructor.apply(this, arguments);
};
Y.extend(AxisMinAndMaxTestTemplate, AxisTestTemplate, {
testMinAndMax: function()
{
var chart = this.chart,
setMax = this.setMax,
setMin = this.setMin;
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");
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()
{
AxisDataProviderTemplate.superclass.constructor.apply(this, arguments);
};
Y.extend(AxisDataProviderTemplate, AxisTestTemplate, {
testAxesMinAndMax: function()
{
var chart = this.chart,
maxValues = this.maxValues,
minValues = this.minValues;
this.eventListener = this.chart.on("chartRendered", function(e) {
var axes = chart.get("axes"),
catKey = chart.get("categoryKey"),
axis,
dataMin,
dataMax,
key,
seriesKey,
keys,
len,
seriesKey;
for(key in axes)
{
if(axes.hasOwnProperty(key) && key != catKey)
{
axis = axes[key];
keys = axis.get("keys");
for(seriesKey in keys)
{
if(keys.hasOwnProperty(seriesKey))
{
maxValue = maxValues[seriesKey];
minValue = minValues[seriesKey];
Y.assert(axis.get("maximum") >= maxValue);
Y.assert(axis.get("minimum") <= minValue);
}
}
}
}
});
this.chart.render("#mychart");
}
});
Y.AxisDataProviderTemplate = AxisDataProviderTemplate;
function AxisGraphicStylesTemplate()
{
AxisGraphicStylesTemplate.superclass.constructor.apply(this, arguments);
switch(ENGINE)
{
case "SVG" :
this._testNodes = TestSVGNodes;
break;
case "Canvas" :
this._testNodes = TestCanvasNodes;
break;
case "VML" :
this._testNodes = TestVMLNodes;
break;
}
};
Y.extend(AxisGraphicStylesTemplate, AxisTestTemplate, {
testGraphicStyles: function()
{
var chart = this.chart,
lineStyles = this.lineStyles,
tickStyles = this.tickStyles,
testNodes = this._testNodes;
this.eventListener = this.chart.on("chartRendered", function(e) {
var valueAxis = chart.getAxisByKey("values"),
catAxis = chart.getAxisByKey("category"),
valueLinePath = valueAxis.get("path"),
valueTickPath = valueAxis.get("tickPath"),
catLinePath = catAxis.get("path"),
catTickPath = catAxis.get("tickPath");
Y.Assert.isTrue(testNodes.apply(this, [lineStyles,
tickStyles,
valueLinePath,
valueTickPath,
catLinePath,
catTickPath
]
));
});
this.chart.render("#mychart");
}
});
Y.AxisGraphicStylesTemplate = AxisGraphicStylesTemplate;
var suite = new Y.Test.Suite("Y.Charts"),
AxesTests = new Y.Test.Case({
name: "Axes Tests",
setUp: function() {
var myDataValues = [
{category:"5/1/2010", values:2000, expenses:3700, revenue:2200},
{category:"5/2/2010", values:50, expenses:9100, revenue:100},
{category:"5/3/2010", values:400, expenses:1100, revenue:1500},
{category:"5/4/2010", values:200, expenses:1900, revenue:2800},
{category:"5/5/2010", values:5000, expenses:5000, revenue:2650}
];
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.xHandle = xAxis.on("dataUpdate", Y.bind(function(e) {
l = xAxis.get("keyCollection").length || 0;
assert.areEqual(0, 0, "The value should be zero");
}, this));
this.yHandle = yAxis.on("dataUpdate", Y.bind(function(e) {
keys = yAxis.get("keyCollection");
assert.areEqual(1, keys.length, "The length should be 1");
assert.areEqual(Y.Array.indexOf(keys, "revenue"), -1, "The key revenue should be removed");
}));
xAxis.removeKey("category");
yAxis.removeKey("revenue");
this.xHandle.detach();
this.yHandle.detach();
},
testAddKey: function()
{
var assert = Y.Assert,
yAxis = this.chart.getAxisByKey("values"),
keys,
pattern = [3700, 9100, 1100, 1900],
testarray,
i = 0;
l = 4;
this.yHandle = yAxis.on("dataUpdate", Y.bind(function(e) {
keys = yAxis.get("keyCollection");
testarray = yAxis.getDataByKey("expenses");
assert.areEqual(3, keys.length);
assert.areEqual(Y.Array.indexOf(keys, "expenses"), 2);
for(; i < l; ++i)
{
assert.areEqual(pattern[i], testarray[i]);
}
}, this));
yAxis.addKey("expenses");
this.yHandle.detach();
}
}),
AxisAlwaysShowZero = new Y.Test.Case({
name: "Axis alwaysShowZero Test",
setUp: function()
{
var myDataValues = [
{category:"5/1/2010", values:2000, expenses:3700, revenue:2200},
{category:"5/2/2010", values:50, expenses:9100, revenue:-100},
{category:"5/3/2010", values:-400, expenses:-1100, revenue:1500},
{category:"5/4/2010", values:200, expenses:1900, revenue:-2800},
{category:"5/5/2010", values:5000, expenses:-5000, revenue:2650}
];
this.chart = new Y.Chart({
width:400,
height:300,
dataProvider:myDataValues
});
},
tearDown: function() {
this.eventListener.detach();
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 = [
{category:"5/1/2010", values:2000, expenses:3700, revenue:2200},
{category:"5/2/2010", values:50, expenses:9100, revenue:-100},
{category:"5/3/2010", values:-400, expenses:-1100, revenue:1500},
{category:"5/4/2010", values:200, expenses:1900, revenue:-2800},
{category:"5/5/2010", values:5000, expenses:-5000, revenue:2650}
];
this.chart = new Y.Chart({
width:400,
height:300,
axes: {
values: {
alwaysShowZero: false
}
},
dataProvider:myDataValues
});
},
tearDown: function() {
this.eventListener.detach();
this.chart.destroy(true);
},
testAlwaysShowZeroEqualsFalse: 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");
}
}),
allPositiveDataProvider = [
{category:"5/1/2010", values:2000, expenses:3700, revenue:2200},
{category:"5/2/2010", values:50, expenses:9100, revenue:100},
{category:"5/3/2010", values:400, expenses:1100, revenue:1500},
{category:"5/4/2010", values:200, expenses:1900, revenue:2800},
{category:"5/5/2010", values:5000, expenses:5000, revenue:2650}
],
allPositiveDataProviderDataMax = 9100,
allPositiveDataProviderDataMin = 50,
positiveAndNegativeDataProvider = [
{category:"5/1/2010", values:2000, expenses:3700, revenue:2200},
{category:"5/2/2010", values:50, expenses:9100, revenue:-100},
{category:"5/3/2010", values:-400, expenses:-1100, revenue:1500},
{category:"5/4/2010", values:200, expenses:1900, revenue:-2800},
{category:"5/5/2010", values:5000, expenses:-5000, revenue:2650}
],
positiveAndNegativeDataProviderDataMax = 9100,
positiveAndNegativeDataProviderDataMin = -5000,
allNegativeDataProvider = [
{category:"5/1/2010", values:-2000, expenses:-3700, revenue:-2200},
{category:"5/2/2010", values:-50, expenses:-9100, revenue:-100},
{category:"5/3/2010", values:-400, expenses:-1100, revenue:-1500},
{category:"5/4/2010", values:-200, expenses:-1900, revenue:-2800},
{category:"5/5/2010", values:-5000, expenses:-5000, revenue:-2650}
],
allNegativeDataProviderDataMax = -50,
allNegativeDataProviderDataMin = -9100,
decimalDataProvider = [
{category:"5/1/2010", values:2.45, expenses:3.71, revenue:2.2},
{category:"5/2/2010", values:0.5, expenses:9.1, revenue:0.16},
{category:"5/3/2010", values:1.4, expenses:1.14, revenue:1.25},
{category:"5/4/2010", values:0.05, expenses:1.9, revenue:2.8},
{category:"5/5/2010", values:5.53, expenses:5.21, revenue:2.65}
],
decimalDataProviderDataMax = 9.1,
decimalDataProviderDataMin = 0.05,
missingDataSmallDataProvider = [
{date: "1/1/2010", expenses: 3700},
{date: "1/2/2010", revenue: 2200},
{date: "2/1/2010", expenses: 9100},
{date: "2/2/2010", revenue: 100}
],
missingDataLargeDataProvider = [
{date: "1/1/2010", expenses: 3700},
{date: "1/2/2010", revenue: 2200},
{date: "1/3/2010", expenses: 3000},
{date: "1/4/2010", revenue: 400},
{date: "2/1/2010", expenses: 9100},
{date: "2/2/2010", revenue: 100},
{date: "2/3/2010", expenses: 3300},
{date: "2/4/2010", revenue: 1500}
],
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.setName("Y.Charts");
Y.Test.Runner.add(suite);
Y.Test.Runner.run();
});
</script>
</body>
</html>