...
 
Commits (15)

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = gitlab@gitlab.ai.vub.ac.be:ehai/libraries.git
branch = master
commit = 84463e7994e54e46f58b536978674eb13c2cc020
parent = 6a41b1f032f08eea6e81dd2d2e1941b08c1a9056
method = merge
cmdver = 0.4.0
This diff is collapsed.
********************************* ************************************************************************
LIBRARIES LICENSES
********************************* ************************************************************************
cl-google-charts FreeBSD License
cl-json MIT License
cldoc GNU LGPL License
graph-utils LLGPL
gtfl_0.1.3 BSD-style license
local-time BSD-style license
lw-add-ons-0.10.3 BSD-style license
lw-compat MIT License
lw-doc-0.3.6 FreeBSD License
s-dot-1_2 Modified BSD License
slime-extensions Created by the group, no license on it, present in the previous release
snooze LLGPL License
stanford-postagger-2016-10-31 GNU GPL
cl-google-charts
================
Lisp library for access to google chart API.
LICENSE
-------
Copyright (c) 2012, Michael Spranger (http://www.michael-spranger.com).
All rights reserved.
Redistribution and use 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
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 AUTHOR 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.
;;; Copyright (c) 2011, Michael Spranger (http://www.michael-spranger.com).
;;; All rights reserved.
;;; Redistribution and use 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.
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; 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 AUTHOR 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.
(in-package :cl-google-charts)
(defclass chart ()
((id :initarg :id :accessor id :initform (make-id 'chart))
(options :initarg :options :accessor options :initform nil
:documentation "the options for the chart. if you want total control then
just pass a string here that will be given to the js chart object
otherwise you can use a notation similar to ((\"theme\" . \"test\") (\"chartArea.top\" . 12)
which translates to \"[\"theme\":\"test\",\"chartArea.top\":12]
please see chart-examples.lisp")
(data-source
:initarg :data :accessor data
:initarg :data-source :accessor data-source
:initform nil
:documentation "the source of data")
(refresh-interval :initarg :refresh-interval
:accessor refresh-interval :initform 1
:documentation "how often the server should poll for data (only needed if data is dynamic)")))
(defmethod initialize-instance :after ((chart chart) &key data-source data)
;; you can pass a list to data-source and this will try and make a data table
;; out of it, first row will be interpreted as column definition
(let ((d (or data data-source)))
(when (and (listp d)
(not (null d)))
(setf (data chart)
(make-instance 'data-table :data d)))))
(defclass area-chart (chart) ())
(defclass bar-chart (chart)
())
(defclass bubble-chart (chart)
())
(defclass candlestick-chart (chart)
())
(defclass column-chart (chart)
())
(defclass combo-chart (chart)
())
(defclass gauge (chart)
())
(defclass geo-chart (chart)
())
(defclass line-chart (chart)
())
(defclass pie-chart (chart)
())
(defclass scatter-chart (chart)
())
(defclass stepped-area-chart (chart)
())
(defclass table (chart)
())
(defclass tree-map (chart)
())
(defclass motion-chart (chart)
())
(defclass annotated-time-line (chart)
())
(defclass intensity-map (chart)
())
;;; Copyright (c) 2012-2013, Michael Spranger (http://www.michael-spranger.com).
;;; All rights reserved.
;;; Redistribution and use 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.
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; 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 AUTHOR 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.
(in-package :asdf)
(defsystem :cl-google-charts
:depends-on (:split-sequence
:hunchentoot)
:serial t
:components
((:file "package")
(:file "helpers")
(:file "helpers-json")
(:file "data-source")
(:file "charts")
(:file "html")))
This diff is collapsed.
This diff is collapsed.
;;; Copyright (c) 2012, Michael Spranger (http://www.michael-spranger.com).
;;; All rights reserved.
;;; Redistribution and use 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.
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; 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 AUTHOR 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.
;;; This file has been adapted from writer.lisp from jsown
;;; see https://github.com/madnificent/jsown.git
(in-package :cl-google-charts)
(declaim (optimize (speed 3) (debug 3) (safety 0)))
(defgeneric to-json (object &key)
(:documentation "Writes the given object to json in a generic way."))
(defmethod to-json ((string string) &key stream)
(format stream "'~{~a~}'"
(loop for char across string
collect (case char
(#\newline "\\n")
(#\return "\\r")
(#\tab "\\t")
(#\" "\\\"")
(#\' "\\\'")
(t char)))))
(defmethod to-json ((number number) &key stream)
(if stream
(format stream "~a" number)
number))
(defmethod to-json ((ratio ratio) &key stream)
(to-json (coerce ratio 'float) :stream stream))
(defmethod to-json ((list list) &key stream)
;; *pretty-print* makes printing very slow, internal json objects needn't have this
(let ((*print-pretty* nil))
(if (eq (car list) :obj)
(object-to-json (cdr list) :stream stream)
(list-to-json list :stream stream))))
(defmethod to-json ((true (eql t)) &key stream)
(format stream "true"))
(defmethod to-json ((true (eql :t)) &key stream)
(format stream "true"))
(defmethod to-json ((true (eql :true)) &key stream)
(format stream "true"))
(defmethod to-json ((false (eql :false)) &key stream)
(format stream "false"))
(defmethod to-json ((false (eql :f)) &key stream)
(format stream "false"))
(defmethod to-json ((false (eql :null)) &key stream)
(format stream "null"))
(defmethod to-json ((false (eql :n)) &key stream)
(format stream "null"))
(defmethod to-json ((false (eql :undefined)) &key stream)
(format stream "undefined"))
(defun object-to-json (list &key stream)
(format stream "{~{~{~A:~A~}~^,~}}"
(loop for item in list collect
(list (to-json (car item))
(to-json (cdr item))))))
(defun list-to-json (list &key stream)
(format stream "[~{~A~^,~}]"
(mapcar #'to-json list)))
;;; Copyright (c) 2012, Michael Spranger (http://www.michael-spranger.com).
;;; All rights reserved.
;;; Redistribution and use 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.
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; 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 AUTHOR 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.
(in-package :cl-google-charts)
(defun hyphen->camel-case (string)
"takes a string of the form test-tost or TEST-TOST and turns them into TestTost"
(apply 'concatenate 'string
(loop for s in (split-sequence:split-sequence #\- string)
collect (string-capitalize (string-downcase s)))))
(defparameter *sig-counter* 0)
(defun get-new-sig ()
(incf *sig-counter*)
*sig-counter*)
(defparameter *id-counter* 0)
(defun make-id (symb &key omit-minus)
(incf *id-counter*)
(if omit-minus
(make-symbol (format nil "~a~a" symb *id-counter*))
(make-symbol (format nil "~a-~a" symb *id-counter*))))
;;; Copyright (c) 2012, Michael Spranger (http://www.michael-spranger.com).
;;; All rights reserved.
;;; Redistribution and use 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.
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; 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 AUTHOR 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.
(in-package :cl-google-charts)
;; default for dynamic data source provider
(defparameter *dynamic-data-source-url* "http://localhost:8000/gdata")
(defparameter *google-api-url* "http://www.google.com/jsapi")
(defparameter *google-chart-init-js* "google.load('visualization', '1', {'packages': ['table', 'corechart', 'geochart','gauge','treemap', 'motionchart','intensitymap','orgchart','annotatedtimeline']});")
(defun get-head-html (&key stream)
"Include the code generated from this function in the head of your html page
It loads the google library and the loads packages from the library necessary
to create the charts"
(format stream "<script type=\"text/javascript\" src=~s></script><script type=\"text/javascript\">~a</script>"
*google-api-url*
*google-chart-init-js*))
;; (get-head-html)
(defun chart->html (chart &key stream
style
(url *dynamic-data-source-url*))
"generates a div and javascript that loads the chart, returns a string
behaves differently for dynamic or static data sources
id - the id of the div for the graph
stream - if you want that the string is written to some stream
url - the url of the dynamic data source, this defaults to http://localhost:8000/gdata (only for dynamic graphs)
dynamic-query-var - the variable holding the dynamic query, if nil, then delete is called (only for dynamic graphs)"
(let ((chart-name (hyphen->camel-case (symbol-name (type-of chart))))
(options (if (options chart)
(if (stringp (options chart))
(options chart)
(object-to-json (options chart))))))
(cond
((typep (data chart) 'dynamic-data-source)
;; dynamic graph
(format stream "<div id='~a'~@[ style='~a'~]></div>
<script type=\"text/javascript\">new google.visualization.ChartWrapper({chartType: '~a', dataSourceUrl: '~a?data-id=~a', refreshInterval: ~a~@[, options: ~a~], containerId: '~a'}).draw();</script>"
(id chart)
style
chart-name
url
(id (data chart))
(refresh-interval chart)
options
(id chart)))
;; external data source
((typep (data chart) 'external-data-source)
(format stream "<div id='~a'~@[ style='~a'~]></div>
<script type=\"text/javascript\">new google.visualization.ChartWrapper({chartType: '~a', dataSourceUrl: '~a'~@[, query: '~a'~]~@[, refreshInterval: ~a~]~@[, options: ~a~], containerId: '~a'}).draw();</script>"
(id chart)
style
chart-name
(source-url (data chart))
(query (data chart))
(refresh-interval chart)
options
(id chart)))
;; static graph
(t
(format stream "<div id='~a'~@[ style='~a'~]></div><script type=\"text/javascript\">new google.visualization.~a(document.getElementById('~a')).draw(new google.visualization.DataTable(~a)~@[,~a~]);</script>"
(id chart) style chart-name
(id chart)
(to-json (data chart))
options)))))
;;; Copyright (c) 2012, Michael Spranger (http://www.michael-spranger.com).
;;; All rights reserved.
;;; Redistribution and use 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.
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; 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 AUTHOR 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.
(in-package :common-lisp-user)
(defpackage :cl-google-charts
(:documentation "A package for support of the google charts api (js)")
(:use :common-lisp :hunchentoot)
(:export :date
:data-table :columns :rows :data-id
:dynamic-data-source :add-dynamic-data-source :reset-dynamic-data-sources :update-dynamic-data-source
:external-data-source
:chart :area-chart :bar-chart :bubble-chart
:candlestick-chart :candlestick-chart
:column-chart :combo-chart :gauge :geo-chart
:line-chart :pie-chart :scatter-chart
:stepped-area-chart :table :tree-map
:motion-chart
:annotated-time-line :intensity-map :org-chart
:chart->html))