Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:add a definition of done
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 7b66e5d647e91259b54e19490bd4fdc8d423ebe772de5d1e796d0075ca984f10
User & Date: jack 2024-05-14 10:45:15
Context
2024-09-19
06:08
allow for column access in user-supplied function check-in: 88737e42c9 user: jack tags: master, trunk
2024-05-14
10:45
add a definition of done check-in: 7b66e5d647 user: jack tags: master, trunk
08:13
[wip] minor tweaks, resume development check-in: 19689689ea user: jack tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Code/clim-mixins.lisp.

︙︙
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
                                                stream
                                                (view <polyclot-view>)
                                                &rest args)
  (declare (ignore type args))
  (c:with-bounding-rectangle* (x1 y1 x2 y2) object
    (setf (tl-presentation object)
          (c:with-output-as-presentation (stream object 'tl-handler)
            (c:draw-rectangle* stream x1 y1 (+ x1 20) (+ y1 20) :ink c:+transparent-ink+)))
    (setf (bl-presentation object)
          (c:with-output-as-presentation (stream object 'br-handler)
            (c:draw-rectangle* stream x2 y2 (- x2 20) (- y2 20) :ink c:+transparent-ink+)))))

(c:define-presentation-method c:highlight-presentation
    ((type handler) record stream state)
  (ecase state
    (:highlight
     (c:draw-design stream record :ink c:+blue+))
    (:unhighlight
     (c:dispatch-repaint stream record))))

(c:define-command (com-reshape-object :command-table polyclot)
    ((o '<resizeable-object-mixin>)
     (b 'c:standard-bounding-rectangle))
  (setf (c:rectangle-edges* o) (c:bounding-rectangle* b)))







|


|





|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
                                                stream
                                                (view <polyclot-view>)
                                                &rest args)
  (declare (ignore type args))
  (c:with-bounding-rectangle* (x1 y1 x2 y2) object
    (setf (tl-presentation object)
          (c:with-output-as-presentation (stream object 'tl-handler)
            (c:draw-rectangle* stream x1 y1 (+ x1 20) (+ y1 20))))
    (setf (bl-presentation object)
          (c:with-output-as-presentation (stream object 'br-handler)
            (c:draw-rectangle* stream x2 y2 (- x2 20) (- y2 20))))))

(c:define-presentation-method c:highlight-presentation
    ((type handler) record stream state)
  (ecase state
    (:highlight
     (c:draw-design stream (climi::copy-bounding-rectangle record) :ink c:+blue+))
    (:unhighlight
     (c:dispatch-repaint stream record))))

(c:define-command (com-reshape-object :command-table polyclot)
    ((o '<resizeable-object-mixin>)
     (b 'c:standard-bounding-rectangle))
  (setf (c:rectangle-edges* o) (c:bounding-rectangle* b)))
︙︙

Changes to Code/plot.lisp.

︙︙
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
                                         stream
                                         (view <polyclot-view>)
                                         &rest args)
  (declare (ignore args))
  (with-theme (plot)
    (let ((offset-x 0)
          (offset-y 0))
      ;;c:formatting-item-list (t :x-spacing 20 :y-spacing 10 :n-columns 2)
      (do-facets (facet plot)
        (c:with-translation (stream offset-x offset-y)
          (let ((coords (coords facet))
                (scales (scales facet)))
            (progn                       ;c:formatting-cell (*standard-output*)
              (c:draw-rectangle* *standard-output* 0 0 1 1
                                 :ink c:+grey+ :filled nil)
              (with-coords (coords scales)
                (dolist (layer (layers plot))
                  (render-geom layer coords (trained-dataset facet layer))))
              (render-guides plot coords))))
        (if (zerop offset-x)
            (incf offset-x)
            (setf offset-x 0
                  offset-y 1))))))

(defun polyclot (*plot* *standard-output*)
  (train-plot *plot*)
  (c:present *plot* <polyclot>
             :view (<polyclot-view>)
             :sensitive nil
             :allow-sensitive-inferiors t))







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
                                         stream
                                         (view <polyclot-view>)
                                         &rest args)
  (declare (ignore args))
  (with-theme (plot)
    (let ((offset-x 0)
          (offset-y 0))
      (progn;c:formatting-item-list (t :x-spacing 20 :y-spacing 10 :n-columns 2)
       (do-facets (facet plot)
         (c:with-translation (stream offset-x offset-y)
           (let ((coords (coords facet))
                 (scales (scales facet)))
             (progn;c:formatting-cell (*standard-output*)
               (c:draw-rectangle* *standard-output* 0 0 1 1
                                  :ink c:+grey+ :filled nil)
               (with-coords (coords scales)
                 (dolist (layer (layers plot))
                   (render-geom layer coords (trained-dataset facet layer))))
               (render-guides plot coords))))
         (if (zerop offset-x)
             (incf offset-x)
             (setf offset-x 0
                   offset-y 1)))))))

(defun polyclot (*plot* *standard-output*)
  (train-plot *plot*)
  (c:present *plot* <polyclot>
             :view (<polyclot-view>)
             :sensitive nil
             :allow-sensitive-inferiors t))

Changes to Code/theme.lisp.

︙︙
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
;;; FIXME can we leverege McCLIM space requirement and layout protocols?

(defgeneric call-with-theme (theme cont))

;;; Estabilishes a context for drawing at the current cursor position as a unit
;;; box [0 0 1 1] and adds the plot decorations.
(defmethod call-with-theme ((theme <theme>) cont)

  (when (climi::null-bounding-rectangle-p theme)
    (multiple-value-bind (cx cy) (c:stream-cursor-position *standard-output*)
      (setf (c:rectangle-edges* theme)
            (values cx cy (+ cx (width theme)) (+ cy (height theme))))))
  (c:with-bounding-rectangle* (x0 y0 :width width :height height) theme
    (c:with-translation (t x0 y0)
      (c:with-scaling (t width height)
        (funcall cont)))))

(defmacro with-theme ((theme) &body body)
  `(call-with-theme ,theme (lambda () ,@body)))







>
|
|
|
|
|
|
|
|



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;; FIXME can we leverege McCLIM space requirement and layout protocols?

(defgeneric call-with-theme (theme cont))

;;; Estabilishes a context for drawing at the current cursor position as a unit
;;; box [0 0 1 1] and adds the plot decorations.
(defmethod call-with-theme ((theme <theme>) cont)
  (c:surrounding-output-with-border (t :outline-ink c:+light-blue+ :ink c:+white+ :filled t)
   (when (climi::null-bounding-rectangle-p theme)
     (multiple-value-bind (cx cy) (c:stream-cursor-position *standard-output*)
       (setf (c:rectangle-edges* theme)
             (values cx cy (+ cx (width theme)) (+ cy (height theme))))))
   (c:with-bounding-rectangle* (x0 y0 :width width :height height) theme
     (c:with-translation (t x0 y0)
       (c:with-scaling (t width height)
         (funcall cont))))))

(defmacro with-theme ((theme) &body body)
  `(call-with-theme ,theme (lambda () ,@body)))

Changes to Demo/cl-bench-results.lisp.

︙︙
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
                for file in (directory (merge-pathnames "CL-benchmark*.*" output-dir))
                for form = (with-open-file (stream file :direction :input)
                             (read stream))
                append (process-result form)))))

(define-demo-plot *bench*
    (let ((dataset (read-data "~/Warsztat/Repo/cl-bench/output/")))
    (<polyclot> :title "Common Lisp Benchmark"
                :width 400 :height 300
                :dataset dataset
                :aesthetics (list :x "Test" :y "Time" :ink "Lisp")
                :layers (list (<geom-bar>
                               :bin-width (/ 1 20)
                               :statistical-transformation i::+stat-identity+
                               :position-adjustment (i::<position-dodge>)))
                :scales (list (make-scale :discrete :x)
                              (make-scale :continuous :y)
                              (make-scale :discrete :ink))))
  "Common Lisp Bencharks example plot")
;; (find-application-frame 'a-repl :width 800 :height 600)








|
|
|
|
|
|
|
|
|
|
|



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
                for file in (directory (merge-pathnames "CL-benchmark*.*" output-dir))
                for form = (with-open-file (stream file :direction :input)
                             (read stream))
                append (process-result form)))))

(define-demo-plot *bench*
    (let ((dataset (read-data "~/Warsztat/Repo/cl-bench/output/")))
      (<polyclot> :title "Common Lisp Benchmark"
                  :width 400 :height 300
                  :dataset dataset
                  :aesthetics (list :x "Test" :y "Time" :ink "Lisp")
                  :layers (list (<geom-bar>
                                 :bin-width (/ 1 20)
                                 :statistical-transformation i::+stat-identity+
                                 :position-adjustment (i::<position-dodge>)))
                  :scales (list (make-scale :discrete :x)
                                (make-scale :continuous :y)
                                (make-scale :discrete :ink))))
  "Common Lisp Bencharks example plot")
;; (find-application-frame 'a-repl :width 800 :height 600)

Changes to Demo/demo.lisp.

︙︙
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

(defmethod display ((frame polyclot-demo-frame) *standard-output*)
  (format-items (mapcar 'symbol-value (plots frame)) :printer #'present*)
  (terpri)
  (let ((active (active frame)))
    (if (null active)
        (format t "(select a plot)")
        (formatting-item-list (*standard-output* :row-wise nil)
          (dolist (plot active)
            (formatting-cell ()
              (polyclot plot *standard-output*)))))))

(defparameter *frame*
  (find-application-frame 'polyclot-demo-frame
                          :plots *demo-plots*))







|

|





130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

(defmethod display ((frame polyclot-demo-frame) *standard-output*)
  (format-items (mapcar 'symbol-value (plots frame)) :printer #'present*)
  (terpri)
  (let ((active (active frame)))
    (if (null active)
        (format t "(select a plot)")
        (progn;formatting-item-list (*standard-output* :row-wise t)
          (dolist (plot active)
            (progn;formatting-cell ()
              (polyclot plot *standard-output*)))))))

(defparameter *frame*
  (find-application-frame 'polyclot-demo-frame
                          :plots *demo-plots*))

Changes to README.org.

︙︙
80
81
82
83
84
85
86











87
88
89
90
91
92
93
|----------+-------------+------------------------------------------------------|
| labels   | :label      | text on the plot                                     |
| hjust    | :align-x    | text alignment (:left :center :right)                |
| vjust    | :align-y    | text alignment (:top :center :baseline :bottom)      |

* Development notes                                                :noexport:












** Architecture

The central piece is the instance of the class <polyclot>. It has the following
slots:

- dataset :: raw dataset [fixme] document dataset-head, dataset-body, streams
- aesthetics :: default mapping between data and aesthetics (inherited [layers])







>
>
>
>
>
>
>
>
>
>
>







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|----------+-------------+------------------------------------------------------|
| labels   | :label      | text on the plot                                     |
| hjust    | :align-x    | text alignment (:left :center :right)                |
| vjust    | :align-y    | text alignment (:top :center :baseline :bottom)      |

* Development notes                                                :noexport:

** Releases

*** 1.0 MVP requirements

- [X] prototype :: implement basic layered grammar of graphics framework
- [ ] validation :: write a program that manages cl-bench and draws barcharts
- [ ] polishing :: ensure that the application is easy and pleasant to use
- [ ] specification :: extract and document essential protocols and api
- [ ] documentation :: provide compelling examples and write user manual
- [ ] application :: write a rudimentary user interface for polyclot

** Architecture

The central piece is the instance of the class <polyclot>. It has the following
slots:

- dataset :: raw dataset [fixme] document dataset-head, dataset-body, streams
- aesthetics :: default mapping between data and aesthetics (inherited [layers])
︙︙