init repo
This commit is contained in:
@@ -0,0 +1,238 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<!--
|
||||
/**
|
||||
* o------------------------------------------------------------------------------o
|
||||
* | This file is part of the OfficeExcel package - you can learn more at: |
|
||||
* | |
|
||||
* | http://www.OfficeExcel.net |
|
||||
* | |
|
||||
* | This package is licensed under the OfficeExcel license. For all kinds of business |
|
||||
* | purposes there is a small one-time licensing fee to pay and for non |
|
||||
* | commercial purposes it is free to use. You can read the full license here: |
|
||||
* | |
|
||||
* | http://www.OfficeExcel.net/LICENSE.txt |
|
||||
* o------------------------------------------------------------------------------o
|
||||
*/
|
||||
-->
|
||||
<title>HOWTO: Make a transition effect</title>
|
||||
|
||||
<meta name="keywords" content="OfficeExcel html5 canvas chart docs links" />
|
||||
<meta name="description" content="A HOWTO guide for making a transition effect between different charts" />
|
||||
<meta name="googlebot" content="NOODP">
|
||||
|
||||
<meta property="og:title" content="OfficeExcel: HTML5 Javascript charts library" />
|
||||
<meta property="og:description" content="A chart library based on the HTML5 canvas tag" />
|
||||
<meta property="og:image" content="http://www.OfficeExcel.net/images/logo.jpg"/>
|
||||
|
||||
<link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" />
|
||||
<link rel="icon" type="image/png" href="../images/favicon.png">
|
||||
|
||||
<!-- Place this tag in your head or just before your close body tag -->
|
||||
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
|
||||
|
||||
<meta name="keywords" content="OfficeExcel chart html5 javascript canvas" />
|
||||
<meta name="description" content="OfficeExcel: HTML5 Javascript charts library Javascript charts & HTML5 canvas charts library" />
|
||||
|
||||
<script src="../libraries/OfficeExcel.bar.js" ></script>
|
||||
<script src="../libraries/OfficeExcel.common.core.js" ></script>
|
||||
<script src="../libraries/OfficeExcel.common.key.js" ></script>
|
||||
<script src="../libraries/OfficeExcel.common.effects.js" ></script>
|
||||
<script src="../libraries/jquery.min.js" ></script>
|
||||
|
||||
<?php PrintAnalyticsCode() ?>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* This function shows the chart that displays total sales by day.
|
||||
*/
|
||||
function ShowChart1 ()
|
||||
{
|
||||
// Enable the correct button
|
||||
document.getElementById("butDayAndPerson").disabled = false;
|
||||
|
||||
var bar1 = new OfficeExcel.Bar('cvs', [4,5,8,6,4,3,2]);
|
||||
bar1.Set('chart.labels', ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])
|
||||
bar1.Set('chart.title', 'Total sales by day');
|
||||
OfficeExcel.Effects.jQuery.Reveal(bar1);
|
||||
}
|
||||
|
||||
/**
|
||||
* This chart shows the total sales by day again, but this time broken down by person as well.
|
||||
*/
|
||||
function ShowChart2 ()
|
||||
{
|
||||
// Enable the correct button
|
||||
document.getElementById("butDay").disabled = false;
|
||||
|
||||
var bar2 = new OfficeExcel.Bar('cvs', [[2,2],[3,2],[5,3],[3,3],[3,1],[2,1],[1,1]]);
|
||||
bar2.Set('chart.title', 'Sales broken down by day and person');
|
||||
bar2.Set('chart.labels', ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']);
|
||||
bar2.Set('chart.key', ['John','Brandon']);
|
||||
bar2.Set('chart.ymax', 10);
|
||||
OfficeExcel.Effects.jQuery.Reveal(bar2);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function hides the canvas (whichever chart is being shown) and calls the relevant function to
|
||||
* show the desired chart. It uses the Conceal effect to hide the canvas and passes the appropriate
|
||||
* function as the "callback" which is called when the Concealeffect is done.
|
||||
*
|
||||
* The callback then clears the canvas and draws the appropriate chart on it.
|
||||
*/
|
||||
function TransitionTo(func)
|
||||
{
|
||||
// Disable both buttons
|
||||
document.getElementById("butDay").disabled = true;
|
||||
document.getElementById("butDayAndPerson").disabled = true;
|
||||
|
||||
OfficeExcel.Effects.jQuery.Conceal(document.getElementById("cvs").__object__, null, func);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initially the canvas is blabk so there is no need to clear anything. So it is sufficient to
|
||||
* just call the relevant function to show the first chart.
|
||||
*/
|
||||
window.onload = function ()
|
||||
{
|
||||
ShowChart1();
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
|
||||
<!-- Social networking buttons -->
|
||||
<?php
|
||||
$prefix = substr($_SERVER['SERVER_NAME'], 0, 3);
|
||||
require("/OfficeExcel.{$prefix}/social.html");
|
||||
?>
|
||||
<!-- Social networking buttons -->
|
||||
|
||||
|
||||
<div id="breadcrumb">
|
||||
<a href="../index.html">OfficeExcel: HTML5 Javascript charts library</a>
|
||||
>
|
||||
<a href="./index.html">Documentation</a>
|
||||
>
|
||||
HOWTO: Make a transition effect
|
||||
</div>
|
||||
|
||||
<h1>HOWTO: <span>Make a transition effect</span></h1>
|
||||
|
||||
<p>
|
||||
You can use the range of OfficeExcel effects to easily make an effective transition effect. This page shows you how you can do just
|
||||
that with the Conceal ad Reveal effects. If you need to show multiple charts this can be an effective way to switch between the
|
||||
two.
|
||||
</p>
|
||||
|
||||
<div style="text-align: center">
|
||||
<canvas id="cvs" width="600" height="250">[No canvas support]</canvas>
|
||||
|
||||
<br />
|
||||
|
||||
<button onclick="TransitionTo(ShowChart1)" disabled="disabled" id="butDay">Show sales by day only</button>
|
||||
<button onclick="TransitionTo(ShowChart2)" disabled="disabled" id="butDayAndPerson">Show sales by day and person</button>
|
||||
</div>
|
||||
|
||||
<h4>1. Include the libraries</h4>
|
||||
<p>
|
||||
This HTML code, which goes in the page <HEAD>, simply includes the relevant OfficeExcel libraries along with jQuery.
|
||||
</p>
|
||||
|
||||
<pre class="code">
|
||||
<script src="OfficeExcel.common.core.js" ></script>
|
||||
<script src="OfficeExcel.common.key.js" ></script>
|
||||
<script src="OfficeExcel.common.effects.js" ></script>
|
||||
<script src="OfficeExcel.bar.js" ></script>
|
||||
<script src="jquery.min.js" ></script>
|
||||
</pre>
|
||||
|
||||
<h4>2. Define the Javascript that draws the charts</h4>
|
||||
<p>
|
||||
The charts are drawn by individual functions. This makes it easy to call those functions when needed and draw the charts.
|
||||
</p>
|
||||
|
||||
<pre class="code">
|
||||
<script>
|
||||
/**
|
||||
* This function shows the chart that displays total sales by day.
|
||||
*/
|
||||
function ShowChart1 ()
|
||||
{
|
||||
// Enable the correct button
|
||||
document.getElementById("butDayAndPerson").disabled = false;
|
||||
|
||||
var bar1 = new OfficeExcel.Bar('cvs', [4,5,8,6,4,3,2]);
|
||||
bar1.Set('chart.labels', ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])
|
||||
bar1.Set('chart.title', 'Total sales by day');
|
||||
OfficeExcel.Effects.jQuery.Reveal(bar1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This chart shows the total sales by day again, but this time broken down by person as well.
|
||||
*/
|
||||
function ShowChart2 ()
|
||||
{
|
||||
// Enable the correct button
|
||||
document.getElementById("butDay").disabled = false;
|
||||
|
||||
var bar2 = new OfficeExcel.Bar('cvs', [[2,2],[3,2],[5,3],[3,3],[3,1],[2,1],[1,1]]);
|
||||
bar2.Set('chart.title', 'Sales broken down by day and person');
|
||||
bar2.Set('chart.labels', ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']);
|
||||
bar2.Set('chart.key', ['John','Brandon']);
|
||||
bar2.Set('chart.ymax', 10);
|
||||
OfficeExcel.Effects.jQuery.Reveal(bar2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function hides the canvas (whichever chart is being shown) and calls the relevant function to
|
||||
* show the desired chart. It uses the Conceal effect to hide the canvas and passes the appropriate
|
||||
* function as the "callback" which is called when the Concealeffect is done.
|
||||
*
|
||||
* The callback then clears the canvas and draws the appropriate chart on it.
|
||||
*/
|
||||
function TransitionTo(func)
|
||||
{
|
||||
// Disable both buttons
|
||||
document.getElementById("butDay").disabled = true;
|
||||
document.getElementById("butDayAndPerson").disabled = true;
|
||||
|
||||
OfficeExcel.Effects.jQuery.Conceal(document.getElementById("cvs").__object__, null, func);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initially the canvas is blabk so there is no need to clear anything. So it is sufficient to
|
||||
* just call the relevant function to show the first chart.
|
||||
*/
|
||||
window.onload = function ()
|
||||
{
|
||||
ShowChart1();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
<h4>3. The buttons that trigger the transitions</h4>
|
||||
<p>
|
||||
These are just some regular HTML buttons that trigger the transitioning to a new chart. Buttons are disabled when clicked
|
||||
so that double clicking does not cause any ill-effects. The appropriate button is then enabled when the new chart is shown.
|
||||
</p>
|
||||
|
||||
<pre class="code">
|
||||
<button onclick="TransitionTo(ShowChart1)" disabled="disabled" id="butDay">Show sales by day only</button>
|
||||
<button onclick="TransitionTo(ShowChart2)" disabled="disabled" id="butDayAndPerson">Show sales by day and person</button>
|
||||
</pre>
|
||||
|
||||
<h4>Note</h4>
|
||||
<p>
|
||||
Some effects may be unusable in this type of situation because of the references that are added to the canvas. If this situation
|
||||
arises however it is feasible to use two separate canvas tags which are positioned at the exact same point, and use the
|
||||
<i>display:</i> CSS attribute to switch between the two. This may also be necessary if you use any interactive features
|
||||
such as tooltips.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user