JavaScript DHTML/YUI Library/Chart — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 10:02, 26 мая 2010
Содержание
Chart and DataTable Example
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Chart and DataTable Example</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/datatable/assets/skins/sam/datatable.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datatable/datatable-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
#chart
{
width: 500px;
height: 350px;
margin-bottom: 10px;
}
.yui-dt-table {width: 500px;}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Chart and DataTable Example</h1>
<div class="exampleIntro">
<p>A <a href="http://developer.yahoo.ru/yui/charts/">YUI Charts Control</a> and a <a href="http://developer.yahoo.ru/yui/datatable/">DataTable Control</a> may share a <a href="http://developer.yahoo.ru/yui/datasource/">DataSource</a> to display the same data.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title">Widgets, Inc. Financial Summary 2003-2006</span>
<div id="chart">Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p></div>
<div id="datatable"></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//used to format x axis labels
YAHOO.example.numberToCurrency = function( value )
{
return YAHOO.util.Number.format(Number(value), {prefix: "$", thousandsSeparator: ","});
}
//manipulating the DOM causes problems in ie, so create after window fires "load"
YAHOO.util.Event.addListener(window, "load", function()
{
//--- data
YAHOO.example.annualIncome =
[
{ year: 2003, revenue: 1246852, expense: 1123359, income: 123493 },
{ year: 2004, revenue: 2451876, expense: 2084952, income: 366920 },
{ year: 2005, revenue: 2917246, expense: 2587151, income: 330095 },
{ year: 2006, revenue: 3318185, expense: 3087456, income: 230729 }
];
var incomeData = new YAHOO.util.DataSource( YAHOO.example.annualIncome );
incomeData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
incomeData.responseSchema = { fields: [ "year", "revenue", "expense", "income" ] };
//--- chart
var seriesDef =
[
{
xField: "revenue",
displayName: "Revenue"
},
{
xField: "expense",
displayName: "Expense"
},
{
type: "line",
xField: "income",
displayName: "Income"
}
];
var currencyAxis = new YAHOO.widget.NumericAxis();
currencyAxis.labelFunction = "YAHOO.example.numberToCurrency";
var mychart = new YAHOO.widget.BarChart( "chart", incomeData,
{
series: seriesDef,
yField: "year",
xAxis: currencyAxis,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
//--- data table
var columns =
[
{ key: "year", sortable: true, resizeable: true },
{ key: "revenue", formatter: "currency", sortable: true, resizeable: true },
{ key: "expense", formatter: "currency", sortable: true, resizeable: true },
{ key: "income", formatter: "currency", sortable: true, resizeable: true }
];
var mytable = new YAHOO.widget.DataTable( "datatable", columns, incomeData,
{ sortedBy: { key: "year", dir: "asc" }
});
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>
Charts in a TabView
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Charts in a TabView</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/tabview/assets/skins/sam/tabview.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/tabview/tabview-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
.chart
{
width: 500px;
height: 350px;
margin-bottom: 10px;
}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
#tabContainer
{
width: 520px;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Charts in a TabView</h1>
<div class="exampleIntro">
<p>This example uses the <a href="http://developer.yahoo.ru/yui/charts/">YUI Charts Control</a> and the <a href="http://developer.yahoo.ru/yui/tabview/">TabView Control</a> to display different views of the same <a href="http://developer.yahoo.ru/yui/datasource/">DataSource</a>.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title">Monthly Expenses</span>
<div id="tabContainer"></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//--- DataSource
YAHOO.example.monthlyExpenses =
[
{ month: "January", rent: 880.00, utilities: 894.68 },
{ month: "February", rent: 880.00, utilities: 901.35 },
{ month: "March", rent: 880.00, utilities: 889.32 },
{ month: "April", rent: 880.00, utilities: 884.71 },
{ month: "May", rent: 910.00, utilities: 879.811 },
{ month: "June", rent: 910.00, utilities: 897.95 }
];
var myDataSource = new YAHOO.util.DataSource( YAHOO.example.monthlyExpenses );
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
myDataSource.responseSchema =
{
fields: [ "month", "rent", "utilities" ]
};
//--- tabView
//Create a TabView
var tabView = new YAHOO.widget.TabView();
//Add a tab for the Bar Chart
tabView.addTab( new YAHOO.widget.Tab({
label: "Bar Chart",
content: "<span class="chart_title">Bar Chart</span><div class="chart" id="barchart"></div>",
active: true
}));
//Add a tab for the Line Chart
tabView.addTab( new YAHOO.widget.Tab({
label: "Line Chart",
content: "<span class="chart_title">Line Chart</span><div class="chart" id="linechart"></div>"
}));
//Add a tab for the Column Chart
tabView.addTab( new YAHOO.widget.Tab({
label: "Column Chart",
content: "<span class="chart_title">Column Chart</span><div class="chart" id="columnchart"></div>"
}));
//Append TabView to its container div
tabView.appendTo("tabContainer");
//--- chart
//series definition for Column and Line Charts
var seriesDef =
[
{ displayName: "Rent", yField: "rent" },
{ displayName: "Utilities", yField: "utilities" }
];
//series definition for Bar Chart
var barChartSeriesDef =
[
{ displayName: "Rent", xField: "rent" },
{ displayName: "Utilities", xField: "utilities" }
];
//format currency
YAHOO.example.formatCurrencyAxisLabel = function( value )
{
return YAHOO.util.Number.format( value,
{
prefix: "$",
thousandsSeparator: ",",
decimalPlaces: 2
});
}
//return the formatted text
YAHOO.example.getDataTipText = function( item, index, series, axisField )
{
var toolTipText = series.displayName + " for " + item.month;
toolTipText += "\n" + YAHOO.example.formatCurrencyAxisLabel( item[series[axisField]] );
return toolTipText;
}
//DataTip function for the Line Chart and Column Chart
YAHOO.example.getYAxisDataTipText = function( item, index, series )
{
return YAHOO.example.getDataTipText(item, index, series, "yField");
}
//DataTip function for the Bar Chart
YAHOO.example.getXAxisDataTipText = function( item, index, series )
{
return YAHOO.example.getDataTipText(item, index, series, "xField");
}
//create a Numeric Axis for displaying dollars
var currencyAxis = new YAHOO.widget.NumericAxis();
currencyAxis.minimum = 800;
currencyAxis.labelFunction = YAHOO.example.formatCurrencyAxisLabel;
//Create Line Chart
var lineChart = new YAHOO.widget.LineChart( "linechart", myDataSource,
{
series: seriesDef,
xField: "month",
yAxis: currencyAxis,
dataTipFunction: YAHOO.example.getYAxisDataTipText,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
//Create Bar Chart
var barChart = new YAHOO.widget.BarChart( "barchart", myDataSource,
{
series:barChartSeriesDef,
yField: "month",
xAxis: currencyAxis,
dataTipFunction: YAHOO.example.getXAxisDataTipText,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
//Create Column Chart
var columnChart = new YAHOO.widget.ColumnChart( "columnchart", myDataSource,
{
series: seriesDef,
xField: "month",
yAxis: currencyAxis,
dataTipFunction: YAHOO.example.getYAxisDataTipText,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>
Charts Quickstart Example
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Charts Quickstart Example</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
#chart
{
width: 500px;
height: 350px;
}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Charts Quickstart Example</h1>
<div class="exampleIntro">
<p>This example is a demonstration of the <a href="http://developer.yahoo.ru/yui/charts/">YUI Chart Control</a>"s basic features.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title">Monthly Expenses</span>
<div id="chart">Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//--- data
YAHOO.example.monthlyExpenses =
[
{ month: "January", rent: 880.00, utilities: 894.68 },
{ month: "February", rent: 880.00, utilities: 901.35 },
{ month: "March", rent: 880.00, utilities: 889.32 },
{ month: "April", rent: 880.00, utilities: 884.71 },
{ month: "May", rent: 910.00, utilities: 879.811 },
{ month: "June", rent: 910.00, utilities: 897.95 }
];
var myDataSource = new YAHOO.util.DataSource( YAHOO.example.monthlyExpenses );
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
myDataSource.responseSchema =
{
fields: [ "month", "rent", "utilities" ]
};
//--- chart
var seriesDef =
[
{ displayName: "Rent", yField: "rent" },
{ displayName: "Utilities", yField: "utilities" }
];
YAHOO.example.formatCurrencyAxisLabel = function( value )
{
return YAHOO.util.Number.format( value,
{
prefix: "$",
thousandsSeparator: ",",
decimalPlaces: 2
});
}
YAHOO.example.getDataTipText = function( item, index, series )
{
var toolTipText = series.displayName + " for " + item.month;
toolTipText += "\n" + YAHOO.example.formatCurrencyAxisLabel( item[series.yField] );
return toolTipText;
}
var currencyAxis = new YAHOO.widget.NumericAxis();
currencyAxis.minimum = 800;
currencyAxis.labelFunction = YAHOO.example.formatCurrencyAxisLabel;
var mychart = new YAHOO.widget.LineChart( "chart", myDataSource,
{
series: seriesDef,
xField: "month",
yAxis: currencyAxis,
dataTipFunction: YAHOO.example.getDataTipText,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>
Chart with DataSource Polling
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Chart with DataSource Polling</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/connection/connection-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
#chart
{
width: 500px;
height: 350px;
}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Chart with DataSource Polling</h1>
<div class="exampleIntro">
<p>The <a href="http://developer.yahoo.ru/yui/charts/">YUI Charts Control</a> provides built-in support for iterative polling for data over XHR using an XHR <a href="http://developer.yahoo.ru/yui/datasource/">DataSource</a> instance. In the example below, iterative polling causes the chart to refresh every several seconds and animate its display to represent the new data.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title"></span>
<div id="chart">Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//--- data
var jsonData = new YAHOO.util.DataSource( "yui_2.7.0b-assets/charts-assets/generatedata.php?" );
//use POST so that IE doesn"t cache the data
jsonData.connMethodPost = true;
jsonData.responseType = YAHOO.util.DataSource.TYPE_JSON;
jsonData.responseSchema =
{
resultsList: "Results",
fields: ["Name","Value"]
};
//--- chart
var yAxis = new YAHOO.widget.NumericAxis();
yAxis.minimum = 0;
yAxis.maximum = 100;
var mychart = new YAHOO.widget.ColumnChart( "chart", jsonData,
{
xField: "Name",
yField: "Value",
yAxis: yAxis,
polling: 2000,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>
Chart with Legend Example
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Chart with Legend Example</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
#chart
{
float: left;
width: 450px;
height: 300px;
}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Chart with Legend Example</h1>
<div class="exampleIntro">
<p>A legend may be displayed with the <a href="http://developer.yahoo.ru/yui/charts/">YUI Charts Control</a> by setting a few simple styles. This example shows you how.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title">Survey: What is your favorite season?</span>
<div id="chart">Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can install the latest version at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//--- data
YAHOO.example.publicOpinion =
[
{ response: "Summer", count: 564815 },
{ response: "Fall", count: 664182 },
{ response: "Spring", count: 248124 },
{ response: "Winter", count: 271214 },
{ response: "Undecided", count: 81845 }
]
var opinionData = new YAHOO.util.DataSource( YAHOO.example.publicOpinion );
opinionData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
opinionData.responseSchema = { fields: [ "response", "count" ] };
//--- chart
var mychart = new YAHOO.widget.PieChart( "chart", opinionData,
{
dataField: "count",
categoryField: "response",
style:
{
padding: 20,
legend:
{
display: "right",
padding: 10,
spacing: 5,
font:
{
family: "Arial",
size: 13
}
}
},
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>
Column Chart with Rotated Title and Labels
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Column Chart with Rotated Title and Labels</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
#chart
{
width: 500px;
height: 350px;
}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Column Chart with Rotated Title and Labels</h1>
<div class="exampleIntro">
<p>Axes Title and Label fields can be rotated on the <a href="http://developer.yahoo.ru/yui/charts/">YUI Charts Control</a> by setting the titleRotation and labelRotation axis styles. This example shows you how.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title">Monthly Expenses</span>
<div id="chart">Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//--- data
YAHOO.example.monthlyExpenses =
[
{ month: "January", rent: 1350.00, utilities: 941.68 },
{ month: "February", rent: 1350.00, utilities: 901.35 },
{ month: "March", rent: 1350.00, utilities: 789.32 },
{ month: "April", rent: 1350.00, utilities: 684.71 },
{ month: "May", rent: 1500.00, utilities: 779.811 },
{ month: "June", rent: 1500.00, utilities: 897.95 },
{ month: "July", rent: 1500.00, utilities: 919.811 },
{ month: "August", rent: 1500.00, utilities: 937.95 },
{ month: "September", rent: 1500.00, utilities: 779.811 },
{ month: "October", rent: 1500.00, utilities: 697.95 },
{ month: "November", rent: 1500.00, utilities: 679.811 },
{ month: "December", rent: 1500.00, utilities: 897.95 }
];
var myDataSource = new YAHOO.util.DataSource( YAHOO.example.monthlyExpenses );
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
myDataSource.responseSchema =
{
fields: [ "month", "rent", "utilities" ]
};
//--- chart
//series definition for chart
var seriesDef =
[
{
displayName: "Rent",
yField: "rent",
style:{size:10}
},
{
displayName: "Utilities",
yField: "utilities",
style:{size:10}
}
];
//Style object for chart
var styleDef =
{
xAxis:
{
labelRotation:-90
},
yAxis:
{
titleRotation:-90
}
}
//format currency
YAHOO.example.formatCurrencyAxisLabel = function( value )
{
return YAHOO.util.Number.format( value,
{
prefix: "$",
thousandsSeparator: ",",
decimalPlaces: 2
});
}
//DataTip function for the chart
YAHOO.example.getDataTipText = function( item, index, series )
{
var toolTipText = series.displayName + " for " + item.month;
toolTipText += "\n" + YAHOO.example.formatCurrencyAxisLabel( item[series.yField] );
return toolTipText;
}
//create a Numeric Axis for displaying dollars
var currencyAxis = new YAHOO.widget.NumericAxis();
currencyAxis.labelFunction = YAHOO.example.formatCurrencyAxisLabel;
currencyAxis.title = "Money Spent";
//create Category Axis to specify a title for the months
var categoryAxis = new YAHOO.widget.CategoryAxis();
categoryAxis.title = "Month";
//create a Chart
var mychart = new YAHOO.widget.ColumnChart( "chart", myDataSource,
{
series: seriesDef,
xField: "month",
yAxis: currencyAxis,
xAxis: categoryAxis,
style: styleDef,
dataTipFunction: YAHOO.example.getDataTipText,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>
Skinning a Chart
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Skinning a Chart Example</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
#chart
{
width: 580px;
height: 400px;
}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Skinning a Chart Example</h1>
<div class="exampleIntro">
<p>This example demonstrates how to modify the <a href="http://developer.yahoo.ru/yui/charts/">YUI Charts Control</a>"s styles to give it a custom appearance.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title">Wilson"s Supermarket - Product Comparison</span>
<div id="chart">Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//--- data
YAHOO.example.salesComparison =
[
{ month: "Oct", pork: 1354, beef: 1442 },
{ month: "Nov", pork: 1326, beef: 1496 },
{ month: "Dec", pork: 1292, beef: 1582 },
{ month: "Jan", pork: 1387, beef: 1597 },
{ month: "Feb", pork: 1376, beef: 1603 }
];
var salesData = new YAHOO.util.DataSource( YAHOO.example.salesComparison );
salesData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
salesData.responseSchema = { fields: [ "month", "pork", "beef" ] };
//--- chart
var seriesDef =
[
{
yField: "pork",
displayName: "Sales of Pork",
style:
{
image: "yui_2.7.0b-assets/charts-assets/tube.png",
mode: "no-repeat",
color: 0x2e434d,
size: 40
}
},
{
yField: "beef",
displayName: "Sales of Beef",
style:
{
image: "yui_2.7.0b-assets/charts-assets/tube.png",
mode: "no-repeat",
color: 0xc2d81e,
size: 40
}
}
];
var mychart = new YAHOO.widget.ColumnChart( "chart", salesData,
{
series: seriesDef,
xField: "month",
style:
{
border: {color: 0x96acb4, size: 12},
font: {name: "Arial Black", size: 14, color: 0x586b71},
dataTip:
{
border: {color: 0x2e434d, size: 2},
font: {name: "Arial Black", size: 13, color: 0x586b71}
},
xAxis:
{
color: 0x2e434d
},
yAxis:
{
color: 0x2e434d,
majorTicks: {color: 0x2e434d, length: 4},
minorTicks: {color: 0x2e434d, length: 2},
majorGridLines: {size: 0}
}
},
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>
Stacked Bar Chart
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Stacked Bar Chart</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
#chart
{
width: 500px;
height: 350px;
}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Stacked Bar Chart</h1>
<div class="exampleIntro">
<p>This example demonstrates how to use <a href="http://developer.yahoo.ru/yui/charts/">YUI Charts Control</a> to create a Stacked Bar Chart.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title">Media Conglomerate Ad Sales Summary 2004-2007</span>
<div id="chart">Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//--- data
YAHOO.example.annualSales =
[
{ year: 2004, internetsales: 246852, printsales: 2523359, tvsales: 3123493 },
{ year: 2005, internetsales: 851876, printsales: 1084952, tvsales: 3166920 },
{ year: 2006, internetsales: 3917246, printsales: 587151, tvsales: 2330095 },
{ year: 2007, internetsales: 5318185, printsales: 307456, tvsales: 1830729 }
];
var salesData = new YAHOO.util.DataSource( YAHOO.example.annualSales );
salesData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
salesData.responseSchema = { fields: [ "year", "internetsales", "printsales", "tvsales" ] };
//--- chart
var seriesDef =
[
{
xField: "internetsales",
displayName: "Internet Sales"
},
{
xField: "printsales",
displayName: "Print Sales"
},
{
xField: "tvsales",
displayName: "Television Sales"
}
];
//used to format x axis
YAHOO.example.numberToCurrency = function( value )
{
return YAHOO.util.Number.format(Number(value), {prefix: "$", thousandsSeparator: ","});
}
//Numeric Axis for our currency
var currencyAxis = new YAHOO.widget.NumericAxis();
currencyAxis.stackingEnabled = true;
currencyAxis.labelFunction = YAHOO.example.numberToCurrency;
var mychart = new YAHOO.widget.StackedBarChart( "chart", salesData,
{
series: seriesDef,
yField: "year",
xAxis: currencyAxis,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>
Styling Lines, Borders and Fills
<!--
Software License Agreement (BSD License)
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sources of Intellectual Property Included in the YUI Library
YUI is issued by Yahoo! under the BSD license above. Below is a list of certain publicly available software that is the source of intellectual property in YUI, along with the licensing terms that pertain to thosesources of IP. This list is for informational purposes only and is not intended to represent an exhaustive list of third party contributions to the YUI.
* Douglas Crockford"s JSON parsing and stringifying methods: In the JSON Utility, Douglas Crockford"s JSON parsing and stringifying methods are adapted from work published at JSON.org. The adapted work is in the public domain.
* Robert Penner"s animation-easing algorithms: In the Animation Utility, YUI makes use of Robert Penner"s algorithms for easing.
* Geoff Stearns"s SWFObject: In the Charts Control and the Uploader versions through 2.7.0, YUI makes use of Geoff Stearns"s SWFObject v1.5 for Flash Player detection and embedding. More information on SWFObject can be found here (http://blog.deconcept.ru/swfobject/). SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License (http://www.opensource.org/licenses/mit-license.php).
* Diego Perini"s IEContentLoaded technique: The Event Utility employs a technique developed by Diego Perini and licensed under GPL. YUI"s use of this technique is included under our BSD license with the author"s permission.
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Styling Lines, Borders and Fills</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" />
<script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/datasource/datasource-min.js"></script>
<script type="text/javascript" src="yui_2.7.0b-lib/charts/charts-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
#chart
{
width: 500px;
height: 350px;
}
.chart_title
{
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 0.4em;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Styling Lines, Borders and Fills</h1>
<div class="exampleIntro">
<p>The <a href="http://developer.yahoo.ru/yui/charts/">YUI Charts Control</a> offers customization through its style and series style objects. This example demonstrates one way to customize a Line Chart.</p>
<p>Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE -->
<span class="chart_title">January Daily Profits</span>
<div id="chart">Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the <a href="http://www.adobe.ru/go/getflashplayer">Adobe Flash Player Download Center</a>.</p></div>
<script type="text/javascript">
YAHOO.widget.Chart.SWFURL = "yui_2.7.0b-lib/charts/assets/charts.swf";
//--- data
//revenue and expenses per day
var dailyFinancials =
[
{date:"1/1/2009", revenue:14002, expenses:15000},
{date:"1/2/2009", revenue:14027, expenses:16527},
{date:"1/3/2009", revenue:15083, expenses:17283},
{date:"1/4/2009", revenue:15006, expenses:18694},
{date:"1/5/2009", revenue:15035, expenses:18235},
{date:"1/6/2009", revenue:17871, expenses:18371},
{date:"1/7/2009", revenue:25887, expenses:17787},
{date:"1/8/2009", revenue:16149, expenses:16149},
{date:"1/9/2009", revenue:17366, expenses:15666},
{date:"1/10/2009", revenue:16424, expenses:15776},
{date:"1/11/2009", revenue:15817, expenses:18717},
{date:"1/12/2009", revenue:13554, expenses:18154},
{date:"1/13/2009", revenue:19782, expenses:18182},
{date:"1/14/2009", revenue:24400, expenses:18600},
{date:"1/15/2009", revenue:21780, expenses:18480},
{date:"1/16/2009", revenue:16681, expenses:21581},
{date:"1/17/2009", revenue:24645, expenses:21745},
{date:"1/18/2009", revenue:22212, expenses:20388},
{date:"1/19/2009", revenue:24026, expenses:24726},
{date:"1/20/2009", revenue:29264, expenses:24864},
{date:"1/21/2009", revenue:19922, expenses:23622},
{date:"1/22/2009", revenue:12373, expenses:18773},
{date:"1/23/2009", revenue:11944, expenses:18444},
{date:"1/24/2009", revenue:23741, expenses:18641},
{date:"1/25/2009", revenue:24758, expenses:19758},
{date:"1/26/2009", revenue:31611, expenses:19611},
{date:"1/27/2009", revenue:25612, expenses:18212},
{date:"1/28/2009", revenue:26830, expenses:18330},
{date:"1/29/2009", revenue:27929, expenses:19029},
{date:"1/30/2009", revenue:28153, expenses:19953},
{date:"1/31/2009", revenue:28018, expenses:18118}
];
//calculate profits from revenue and expenses
function calculateProfits(dataArray)
{
var dataLength = dataArray.length;
for(var i = 0; i < dataLength; i++)
{
var dataObj = dataArray[i];
dataObj.profits = dataObj.revenue - dataObj.expenses;
}
return dataArray;
}
var myDataSource = new YAHOO.util.DataSource(calculateProfits(dailyFinancials));
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
myDataSource.responseSchema =
{
fields:
[
"date",
"expenses",
"revenue",
"profits"
]
};
//--- chart
//series definition
var seriesDef = [
{
displayName:"Expenses",
yField:"expenses",
style:
{
lineColor:0xB5BAC8,
lineAlpha:.5,
borderColor:0xB5BAC8,
fillColor:0xB5BAC8
}
},
{
displayName:"Revenue",
yField:"revenue",
style:
{
lineColor:0xB5BAC8,
lineAlpha:.5,
borderColor:0xB5BAC8,
fillColor:0xffffff
}
},
{
displayName:"Profits",
yField:"profits",
style:
{
lineColor:0x79839B,
borderColor:0x79839B,
fillColor:0x79839B
}
}
];
//Style object
var styleDef =
{
xAxis:
{
majorTicks:
{
display:"inside",
length:3,
size:1
},
minorTicks:
{
display:"inside",
length:2
},
labelRotation: -90
},
yAxis:
{
zeroGridLine:
{
size:2,
color:0xff0000
},
minorTicks:{display:"none"}
}
}
//format date labels
YAHOO.example.formatTimeData = function(value, major)
{
var formattedData = YAHOO.util.Date.format(new Date(value), {format:"%b %e"});
return formattedData.toString();
}
//format currency labels
YAHOO.example.formatCurrencyAxisLabel = function( value )
{
return YAHOO.util.Number.format( value,
{
prefix: "$",
thousandsSeparator: ",",
decimalPlaces: 2
});
}
//DataTip function for the chart
YAHOO.example.formatDataTipText = function(item, index, series)
{
var str = series.displayName + " for " + item.date;
str += "\n" + YAHOO.example.formatCurrencyAxisLabel(item[(series.displayName).toLowerCase()]);
return str;
}
//Create a TimeAxis for displaying dates
var myTimeAxis = new YAHOO.widget.TimeAxis();
myTimeAxis.labelFunction = YAHOO.example.formatTimeData;
myTimeAxis.majorTimeUnit = "day";
//create a Numeric Axis for displaying dollars
myCurrencyAxis = new YAHOO.widget.NumericAxis();
myCurrencyAxis.labelFunction = YAHOO.example.formatCurrencyAxisLabel;
//create a Chart
var mychart = new YAHOO.widget.LineChart("chart", myDataSource,
{
series: seriesDef,
style: styleDef,
xField: "date",
xAxis: myTimeAxis,
yAxis: myCurrencyAxis,
dataTipFunction:YAHOO.example.formatDataTipText,
//only needed for flash player express install
expressInstall: "yui_2.7.0b-assets/charts-assets/expressinstall.swf"
});
</script>
<!--END SOURCE CODE FOR EXAMPLE -->
</body>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>