Overview

Namespaces

  • MOC
    • Adapter
    • Core
      • Changelog
      • Depending
      • Drive
        • Directory
        • File
      • Error
        • Register
        • Type
      • Journal
      • Proxy
      • Template
      • Xml
    • Extension
      • Excel
      • Flot
      • Mail
      • Pdf
      • Word
      • Xml
      • YUICompressor
      • Zip
    • Generic
      • Common
      • Device
        • Extension
        • Widget
    • Module
      • Database
        • Driver
      • Drive
      • Image
        • Font
      • Installer
      • Network
        • Ftp
          • Directory
          • File
          • Transport
        • Http
        • ParcelTracker
          • Carrier
      • Office
        • Chart
          • Axis
        • Document
          • Excel
            • Cell
              • Format
              • Style
                • Border
                  • Bottom
                  • Left
                  • Right
                  • Top
                • Font
            • Close
            • Page
            • Worksheet
          • Pdf
            • Close
            • Font
            • Page
              • Margin
              • Position
            • Text
          • Xml
            • Close
        • Image
        • Mail
          • Address
          • Content
      • Packer
        • Yui
        • Zip
      • Template
    • Plugin
      • Gateway
      • Repository
      • Shared
  • PHP

Classes

  • Chart
  • Document
  • Image
  • Mail
  • Music
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * LICENSE (BSD)
  4:  *
  5:  * Copyright (c) 2013, Gerd Christian Kunze
  6:  * All rights reserved.
  7:  *
  8:  * Redistribution and use in source and binary forms, with or without
  9:  * modification, are permitted provided that the following conditions are
 10:  * met:
 11:  *
 12:  *  * Redistributions of source code must retain the above copyright
 13:  *    notice, this list of conditions and the following disclaimer.
 14:  *
 15:  *  * Redistributions in binary form must reproduce the above copyright
 16:  *    notice, this list of conditions and the following disclaimer in the
 17:  *    documentation and/or other materials provided with the distribution.
 18:  *
 19:  *  * Neither the name of Gerd Christian Kunze nor the names of the
 20:  *    contributors may be used to endorse or promote products derived from
 21:  *    this software without specific prior written permission.
 22:  *
 23:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 24:  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 25:  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 26:  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 27:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 28:  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 29:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 30:  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 31:  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 32:  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 33:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 34:  *
 35:  * Chart
 36:  * 26.03.2013 14:01
 37:  */
 38: namespace MOC\Module\Office;
 39: use MOC\Api;
 40: use MOC\Generic\Device\Module;
 41: 
 42: /**
 43:  *
 44:  */
 45: class Chart implements Module{
 46:     /**
 47:      * Get Singleton/Instance
 48:      *
 49:      * @static
 50:      * @return Chart
 51:      */
 52:     public static function InterfaceInstance() {
 53:         return new Chart();
 54:     }
 55: 
 56:     /**
 57:      * Get Changelog
 58:      *
 59:      * @static
 60:      * @return \MOC\Core\Changelog
 61:      */
 62:     public static function InterfaceChangelog() {
 63:         return Api::Core()->Changelog()->Create( __CLASS__ );
 64:     }
 65: 
 66:     /**
 67:      * Get Dependencies
 68:      *
 69:      * @static
 70:      * @return \MOC\Core\Depending
 71:      */
 72:     public static function InterfaceDepending() {
 73:         return Api::Core()->Depending();
 74:     }
 75: 
 76:     /**
 77:      * @param bool $ExCanvas true
 78:      * @param bool $jQuery false
 79:      *
 80:      * @return string
 81:      */
 82:     public function Setup( $ExCanvas = true, $jQuery = false ) {
 83:         $Script = '';
 84:         if( $ExCanvas ) {
 85:             $Script .= '<script type="text/javascript" src="'.
 86:             Api::Core()->Proxy()->Url(
 87:                 Api::Core()->Drive()->File()->Handle( __DIR__.'/../../Extension/Flot/3rdParty/excanvas.min.js' )
 88:             ).'"></script>';
 89:         }
 90:         if( $jQuery ) {
 91:             $Script .= '<script type="text/javascript" src="'.
 92:             Api::Core()->Proxy()->Url(
 93:                 Api::Core()->Drive()->File()->Handle( __DIR__.'/../../Extension/Flot/3rdParty/jquery.js' )
 94:             ).'"></script>';
 95:         }
 96:         $Script .= '<script type="text/javascript" src="'.Api::Core()->Proxy()->Url( Api::Core()->Drive()->File()->Handle(
 97:             __DIR__.'/../../Extension/Flot/3rdParty/jquery.flot.js'
 98:         )).'"></script>';
 99:         // Bundled
100:         $Script .= '<script type="text/javascript" src="'.Api::Core()->Proxy()->Url( Api::Core()->Drive()->File()->Handle(
101:             __DIR__.'/../../Extension/Flot/3rdParty/jquery.flot.categories.js'
102:         )).'"></script>';
103:         $Script .= '<script type="text/javascript" src="'.Api::Core()->Proxy()->Url( Api::Core()->Drive()->File()->Handle(
104:             __DIR__.'/../../Extension/Flot/3rdParty/jquery.flot.navigate.js'
105:         )).'"></script>';
106:         $Script .= '<script type="text/javascript" src="'.Api::Core()->Proxy()->Url( Api::Core()->Drive()->File()->Handle(
107:             __DIR__.'/../../Extension/Flot/3rdParty/jquery.flot.threshold.js'
108:         )).'"></script>';
109:         // Additional
110:         $Script .= '<script type="text/javascript" src="'.Api::Core()->Proxy()->Url( Api::Core()->Drive()->File()->Handle(
111:             __DIR__.'/../../Extension/Flot/3rdParty/Plugins/flot.axislabels/jquery.flot.axislabels.js'
112:         )).'"></script>';
113:         return $Script;
114:     }
115: 
116:     /** @var Chart\Container $Container */
117:     private static $Container = null;
118:     /** @var Chart\Grid $Grid */
119:     private static $Grid = null;
120:     /** @var Chart\Axis $Axis */
121:     private static $Axis = null;
122:     /** @var Chart\Data $Data */
123:     private static $Data = null;
124:     /** @var Chart\Legend $Legend */
125:     private static $Legend = null;
126: 
127:     /**
128:      * @return Chart\Container
129:      */
130:     public function Container() {
131:         if( self::$Container === null ) {
132:             self::$Container = Chart\Container::InterfaceInstance();
133:         }
134:         return self::$Container;
135:     }
136: 
137:     /**
138:      * @return Chart\Grid
139:      */
140:     public function Grid() {
141:         if( self::$Grid === null ) {
142:             self::$Grid = Chart\Grid::InterfaceInstance();
143:         }
144:         return self::$Grid;
145:     }
146: 
147:     /**
148:      * @return Chart\Data
149:      */
150:     public function Data() {
151:         if( self::$Data === null ) {
152:             self::$Data = Chart\Data::InterfaceInstance();
153:         }
154:         return self::$Data;
155:     }
156: 
157:     /**
158:      * @return Chart\Axis
159:      */
160:     public function Axis() {
161:         if( self::$Axis === null ) {
162:             self::$Axis = Chart\Axis::InterfaceInstance();
163:         }
164:         return self::$Axis;
165:     }
166: 
167:     public function Legend() {
168: 
169:     }
170: 
171:     /**
172:      * @return string
173:      */
174:     public function Render() {
175: 
176:         $SeriesList = Api::Module()->Office()->Chart()->Data()->_getSeries();
177:         $DataList = array();
178: 
179:         foreach( (array)$SeriesList as $Label => $Data ) {
180: 
181:             $Data   = json_encode( $Data, JSON_FORCE_OBJECT );
182:             $Data   = str_replace( ',', "],[", $Data );
183:             $Data   = str_replace( ":", ",", $Data );
184:             $Data   = str_replace( '{', '[[', $Data );
185:             $Data   = str_replace( '}', ']]', $Data );
186:             $Data   = str_replace( '"', '', $Data );
187: 
188:             $Data = array( 'label' => $Label, 'data' => $Data );
189: 
190:             $Data = array_merge( $Data, Api::Module()->Office()->Chart()->Data()->Config( $Label )->_getConfiguration() );
191: 
192:             $DataList[] = $Data;
193: 
194:         }
195: 
196:         $DataList = json_encode( $DataList );
197:         $DataList   = str_replace( '"[', "[", $DataList );
198:         $DataList   = str_replace( ']"', "]", $DataList );
199: 
200:         //var_dump( $this->Axis()->_getConfiguration() );
201: 
202:         $Script = '<script type="text/javascript">'.
203:             "jQuery('#".$this->Container()->_getIdentifier()."').css({'width':'".$this->Container()->_getWidth()."','height':'".$this->Container()->_getHeight()."'});".
204:             "jQuery.plot('#".$this->Container()->_getIdentifier()."', ".$DataList.", {"
205:                 .$this->Grid()->_getConfiguration().', '
206:                 .$this->Axis()->_getConfiguration()
207:                 //.', zoom: {interactive: true}, pan: { interactive: true }, xaxis: { panRange: [1, 12], zoomRange: [3,12] }, yaxis: { zoomRange: [100000,300000] }'
208:             ."});".
209:         '</script>';
210: 
211:         $this->_doReset();
212: 
213:         return $Script;
214:     }
215: 
216:     /**
217:      * Reset Static-Properties to Default-Values
218:      *
219:      * @return Chart
220:      */
221:     public function _doReset() {
222: 
223:         self::$Container = null;
224:         self::$Grid = null;
225: 
226:         if( self::$Axis !== null ) {
227:             self::$Axis->_doReset();
228:             self::$Axis = null;
229:         }
230: 
231:         self::$Data = null;
232:         self::$Legend = null;
233: 
234:         return $this;
235:     }
236: }
237: 
API documentation generated by ApiGen 2.8.0