aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/chart.el31
1 files changed, 16 insertions, 15 deletions
diff --git a/lisp/emacs-lisp/chart.el b/lisp/emacs-lisp/chart.el
index c0a42038e94..6d641f90862 100644
--- a/lisp/emacs-lisp/chart.el
+++ b/lisp/emacs-lisp/chart.el
@@ -60,6 +60,7 @@
60;; with all the bitmaps you want to use. 60;; with all the bitmaps you want to use.
61 61
62(require 'eieio) 62(require 'eieio)
63(eval-when-compile (require 'cl-generic))
63 64
64;;; Code: 65;;; Code:
65(define-obsolete-variable-alias 'chart-map 'chart-mode-map "24.1") 66(define-obsolete-variable-alias 'chart-map 'chart-mode-map "24.1")
@@ -156,7 +157,7 @@ Returns the newly created buffer."
156 ) 157 )
157 "Superclass for all charts to be displayed in an Emacs buffer.") 158 "Superclass for all charts to be displayed in an Emacs buffer.")
158 159
159(defmethod initialize-instance :AFTER ((obj chart) &rest _fields) 160(cl-defmethod initialize-instance :after ((obj chart) &rest _fields)
160 "Initialize the chart OBJ being created with FIELDS. 161 "Initialize the chart OBJ being created with FIELDS.
161Make sure the width/height is correct." 162Make sure the width/height is correct."
162 (oset obj x-width (- (window-width) 10)) 163 (oset obj x-width (- (window-width) 10))
@@ -201,7 +202,7 @@ Make sure the width/height is correct."
201 :initform vertical)) 202 :initform vertical))
202 "Subclass for bar charts (vertical or horizontal).") 203 "Subclass for bar charts (vertical or horizontal).")
203 204
204(defmethod chart-draw ((c chart) &optional buff) 205(cl-defmethod chart-draw ((c chart) &optional buff)
205 "Start drawing a chart object C in optional BUFF. 206 "Start drawing a chart object C in optional BUFF.
206Erases current contents of buffer." 207Erases current contents of buffer."
207 (save-excursion 208 (save-excursion
@@ -221,19 +222,19 @@ Erases current contents of buffer."
221 (message "Rendering chart...done") 222 (message "Rendering chart...done")
222 )) 223 ))
223 224
224(defmethod chart-draw-title ((c chart)) 225(cl-defmethod chart-draw-title ((c chart))
225 "Draw a title upon the chart. 226 "Draw a title upon the chart.
226Argument C is the chart object." 227Argument C is the chart object."
227 (chart-display-label (oref c title) 'horizontal 0 0 (window-width) 228 (chart-display-label (oref c title) 'horizontal 0 0 (window-width)
228 (oref c title-face))) 229 (oref c title-face)))
229 230
230(defmethod chart-size-in-dir ((c chart) dir) 231(cl-defmethod chart-size-in-dir ((c chart) dir)
231 "Return the physical size of chart C in direction DIR." 232 "Return the physical size of chart C in direction DIR."
232 (if (eq dir 'vertical) 233 (if (eq dir 'vertical)
233 (oref c y-width) 234 (oref c y-width)
234 (oref c x-width))) 235 (oref c x-width)))
235 236
236(defmethod chart-draw-axis ((c chart)) 237(cl-defmethod chart-draw-axis ((c chart))
237 "Draw axis into the current buffer defined by chart C." 238 "Draw axis into the current buffer defined by chart C."
238 (let ((ymarg (oref c y-margin)) 239 (let ((ymarg (oref c y-margin))
239 (xmarg (oref c x-margin)) 240 (xmarg (oref c x-margin))
@@ -247,7 +248,7 @@ Argument C is the chart object."
247 ymarg (+ ymarg xlen))) 248 ymarg (+ ymarg xlen)))
248 ) 249 )
249 250
250(defmethod chart-axis-draw ((a chart-axis) &optional dir margin zone start end) 251(cl-defmethod chart-axis-draw ((a chart-axis) &optional dir margin zone start end)
251 "Draw some axis for A in direction DIR with MARGIN in boundary. 252 "Draw some axis for A in direction DIR with MARGIN in boundary.
252ZONE is a zone specification. 253ZONE is a zone specification.
253START and END represent the boundary." 254START and END represent the boundary."
@@ -257,7 +258,7 @@ START and END represent the boundary."
257 1 0)) 258 1 0))
258 start end (oref a name-face))) 259 start end (oref a name-face)))
259 260
260(defmethod chart-translate-xpos ((c chart) x) 261(cl-defmethod chart-translate-xpos ((c chart) x)
261 "Translate in chart C the coordinate X into a screen column." 262 "Translate in chart C the coordinate X into a screen column."
262 (let ((range (oref (oref c x-axis) bounds))) 263 (let ((range (oref (oref c x-axis) bounds)))
263 (+ (oref c x-margin) 264 (+ (oref c x-margin)
@@ -266,7 +267,7 @@ START and END represent the boundary."
266 (float (- (cdr range) (car range)))))))) 267 (float (- (cdr range) (car range))))))))
267 ) 268 )
268 269
269(defmethod chart-translate-ypos ((c chart) y) 270(cl-defmethod chart-translate-ypos ((c chart) y)
270 "Translate in chart C the coordinate Y into a screen row." 271 "Translate in chart C the coordinate Y into a screen row."
271 (let ((range (oref (oref c y-axis) bounds))) 272 (let ((range (oref (oref c y-axis) bounds)))
272 (+ (oref c x-margin) 273 (+ (oref c x-margin)
@@ -276,7 +277,7 @@ START and END represent the boundary."
276 (float (- (cdr range) (car range))))))))) 277 (float (- (cdr range) (car range)))))))))
277 ) 278 )
278 279
279(defmethod chart-axis-draw ((a chart-axis-range) &optional dir margin zone _start _end) 280(cl-defmethod chart-axis-draw ((a chart-axis-range) &optional dir margin zone _start _end)
280 "Draw axis information based upon a range to be spread along the edge. 281 "Draw axis information based upon a range to be spread along the edge.
281A is the chart to draw. DIR is the direction. 282A is the chart to draw. DIR is the direction.
282MARGIN, ZONE, START, and END specify restrictions in chart space." 283MARGIN, ZONE, START, and END specify restrictions in chart space."
@@ -313,7 +314,7 @@ MARGIN, ZONE, START, and END specify restrictions in chart space."
313 (setq i (+ i j)))) 314 (setq i (+ i j))))
314) 315)
315 316
316(defmethod chart-translate-namezone ((c chart) n) 317(cl-defmethod chart-translate-namezone ((c chart) n)
317 "Return a dot-pair representing a positional range for a name. 318 "Return a dot-pair representing a positional range for a name.
318The name in chart C of the Nth name resides. 319The name in chart C of the Nth name resides.
319Automatically compensates for direction." 320Automatically compensates for direction."
@@ -329,7 +330,7 @@ Automatically compensates for direction."
329 (+ m -1 (round (* lpn (+ 1.0 (float n)))))) 330 (+ m -1 (round (* lpn (+ 1.0 (float n))))))
330 )) 331 ))
331 332
332(defmethod chart-axis-draw ((a chart-axis-names) &optional dir margin zone _start _end) 333(cl-defmethod chart-axis-draw ((a chart-axis-names) &optional dir margin zone _start _end)
333 "Draw axis information based upon A range to be spread along the edge. 334 "Draw axis information based upon A range to be spread along the edge.
334Optional argument DIR is the direction of the chart. 335Optional argument DIR is the direction of the chart.
335Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing." 336Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing."
@@ -368,7 +369,7 @@ Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing
368 s (cdr s)))) 369 s (cdr s))))
369) 370)
370 371
371(defmethod chart-draw-data ((c chart-bar)) 372(cl-defmethod chart-draw-data ((c chart-bar))
372 "Display the data available in a bar chart C." 373 "Display the data available in a bar chart C."
373 (let* ((data (oref c sequences)) 374 (let* ((data (oref c sequences))
374 (dir (oref c direction)) 375 (dir (oref c direction))
@@ -413,7 +414,7 @@ Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing
413 (setq data (cdr data)))) 414 (setq data (cdr data))))
414 ) 415 )
415 416
416(defmethod chart-add-sequence ((c chart) &optional seq axis-label) 417(cl-defmethod chart-add-sequence ((c chart) &optional seq axis-label)
417 "Add to chart object C the sequence object SEQ. 418 "Add to chart object C the sequence object SEQ.
418If AXIS-LABEL, then the axis stored in C is updated with the bounds of SEQ, 419If AXIS-LABEL, then the axis stored in C is updated with the bounds of SEQ,
419or is created with the bounds of SEQ." 420or is created with the bounds of SEQ."
@@ -445,7 +446,7 @@ or is created with the bounds of SEQ."
445 446
446;;; Charting optimizers 447;;; Charting optimizers
447 448
448(defmethod chart-trim ((c chart) max) 449(cl-defmethod chart-trim ((c chart) max)
449 "Trim all sequences in chart C to be at most MAX elements long." 450 "Trim all sequences in chart C to be at most MAX elements long."
450 (let ((s (oref c sequences))) 451 (let ((s (oref c sequences)))
451 (while s 452 (while s
@@ -455,7 +456,7 @@ or is created with the bounds of SEQ."
455 (setq s (cdr s)))) 456 (setq s (cdr s))))
456 ) 457 )
457 458
458(defmethod chart-sort ((c chart) pred) 459(cl-defmethod chart-sort ((c chart) pred)
459 "Sort the data in chart C using predicate PRED. 460 "Sort the data in chart C using predicate PRED.
460See `chart-sort-matchlist' for more details." 461See `chart-sort-matchlist' for more details."
461 (let* ((sl (oref c sequences)) 462 (let* ((sl (oref c sequences))