| Home | Trees | Indices | Help |
|
|---|
|
|
1 # @INVIENT_COPYRIGHT@
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 """Utility functions used by L{InvientCharts} to write its state to
16 the UIDL stream. The state includes properties of L{InvientCharts} such
17 as L{InvientChartsConfig}, L{Series}, L{Point} and various chart events.
18
19 In general, only non-null properties/attributes of a chart are written to
20 the UIDL stream.
21
22 @author: Invient
23 @author: Richard Lincoln
24 """
25
26 from datetime \
27 import datetime
28
29 from muntjac.util \
30 import totalseconds
31
32 from muntjac.addon.invient.invient_charts_config \
33 import AreaConfig, AreaSplineConfig, DateTimeRange, DateTimeValue, \
34 Grid, NumberRange, NumberValue, Tick, BarConfig, CategoryAxis, \
35 ColumnConfig, DateTimeAxis, ImageMarker, LineConfig, \
36 NonLinearSeriesState, NumberAxis, NumberXAxis, NumberYAxis, PieConfig, \
37 PieDataLabel, ScatterConfig, SplineConfig, SymbolMarker, XAxisDataLabel
38
39
41 """Writes configuration attributes common to chart title and subtitle.
42
43 @param target
44 @param titleBaseOptions
45 @throws PaintException
46 """
47 if titleBaseOptions.getText() is not None:
48 target.addAttribute('text', titleBaseOptions.getText())
49 if titleBaseOptions.getX() is not None:
50 target.addAttribute('x', titleBaseOptions.getX())
51 if titleBaseOptions.getY() is not None:
52 target.addAttribute('y', titleBaseOptions.getY())
53 if titleBaseOptions.getFloating() is not None:
54 target.addAttribute('floating', titleBaseOptions.getFloating())
55 if titleBaseOptions.getAlign() is not None:
56 target.addAttribute('align', titleBaseOptions.getAlign().getName())
57 if titleBaseOptions.getVertAlign() is not None:
58 target.addAttribute('verticalAlign',
59 titleBaseOptions.getVertAlign().getName())
60 if titleBaseOptions.getStyle() is not None:
61 target.addAttribute('style', titleBaseOptions.getStyle())
62
63
65 """Writes configuration attributes of the chart title.
66
67 @param target
68 @param titleOptions
69 @throws PaintException
70 """
71 target.startTag('title')
72 writeTitleBaseOptions(target, titleOptions)
73 if titleOptions.getMargin() is not None:
74 target.addAttribute('margin', titleOptions.getMargin())
75 target.endTag('title')
76
77
79 """Writes configuration attributes of the chart subtitle. Only those
80 attributes are written who have got non-null values.
81
82 @param target
83 @param subtitleOptions
84 @throws PaintException
85 """
86 target.startTag('subtitle')
87 writeTitleBaseOptions(target, subtitleOptions)
88 target.endTag('subtitle')
89
90
92 """Writes configuration attributes of the chart subtitle.
93
94 @param target
95 @param creditOptions
96 @throws PaintException
97 """
98 target.startTag('credit')
99
100 if creditOptions.getEnabled() is not None:
101 target.addAttribute('enabled', creditOptions.getEnabled())
102
103 target.startTag('position')
104
105 if creditOptions.getPosition() is not None:
106 if creditOptions.getPosition().getAlign() is not None:
107 target.addAttribute('align',
108 creditOptions.getPosition().getAlign().getName())
109 if creditOptions.getPosition().getVertAlign() is not None:
110 target.addAttribute('verticalAlign',
111 creditOptions.getPosition().getVertAlign().getName())
112 if creditOptions.getPosition().getX() is not None:
113 target.addAttribute('x', creditOptions.getPosition().getX())
114 if creditOptions.getPosition().getY() is not None:
115 target.addAttribute('y', creditOptions.getPosition().getY())
116
117 target.endTag('position')
118
119 if creditOptions.getLink() is not None:
120 target.addAttribute('href', creditOptions.getLink())
121 if creditOptions.getStyle() is not None:
122 target.addAttribute('style', creditOptions.getStyle())
123 if creditOptions.getText() is not None:
124 target.addAttribute('text', creditOptions.getText())
125
126 target.endTag('credit')
127
128
130 """Writes configuration attributes of the chart legend.
131
132 @param target
133 @param legendOptions
134 @throws PaintException
135 """
136 target.startTag('legend')
137 if legendOptions.getBackgroundColor() is not None:
138 target.addAttribute('backgroundColor',
139 legendOptions.getBackgroundColor().getString())
140 if legendOptions.getBorderColor() is not None:
141 target.addAttribute('borderColor',
142 legendOptions.getBorderColor().getString())
143 if legendOptions.getBorderRadius() is not None:
144 target.addAttribute('borderRadius',
145 legendOptions.getBorderRadius())
146 if legendOptions.getBorderWidth() is not None:
147 target.addAttribute('borderWidth', legendOptions.getBorderWidth())
148 if legendOptions.getEnabled() is not None:
149 target.addAttribute('enabled', legendOptions.getEnabled())
150 if legendOptions.getFloating() is not None:
151 target.addAttribute('floating', legendOptions.getFloating())
152 if legendOptions.getItemHiddenStyle() is not None:
153 target.addAttribute('itemHiddenStyle',
154 legendOptions.getItemHiddenStyle())
155 if legendOptions.getItemHoverStyle() is not None:
156 target.addAttribute('itemHoverStyle',
157 legendOptions.getItemHoverStyle())
158 if legendOptions.getItemStyle() is not None:
159 target.addAttribute('itemStyle', legendOptions.getItemStyle())
160 if legendOptions.getItemWidth() is not None:
161 target.addAttribute('itemWidth', legendOptions.getItemWidth())
162 if legendOptions.getLayout() is not None:
163 target.addAttribute('layout', legendOptions.getLayout().getName())
164 if legendOptions.getLabelFormatterJsFunc() is not None:
165 target.addAttribute('labelFormatter',
166 legendOptions.getLabelFormatterJsFunc())
167 if legendOptions.getMargin() is not None:
168 target.addAttribute('margin', legendOptions.getMargin())
169 if legendOptions.getReversed() is not None:
170 target.addAttribute('reversed', legendOptions.getReversed())
171 if legendOptions.getShadow() is not None:
172 target.addAttribute('shadow', legendOptions.getShadow())
173 if legendOptions.getSymbolPadding() is not None:
174 target.addAttribute('symbolPadding',
175 legendOptions.getSymbolPadding())
176 if legendOptions.getSymbolWidth() is not None:
177 target.addAttribute('symbolWidth', legendOptions.getSymbolWidth())
178 if legendOptions.getWidth() is not None:
179 target.addAttribute('width', legendOptions.getWidth())
180 if legendOptions.getPosition() is not None:
181 if legendOptions.getPosition().getAlign() is not None:
182 target.addAttribute('align',
183 legendOptions.getPosition().getAlign().getName())
184 if legendOptions.getPosition().getVertAlign() is not None:
185 target.addAttribute('verticalAlign',
186 legendOptions.getPosition().getVertAlign().getName())
187 if legendOptions.getPosition().getX() is not None:
188 target.addAttribute('x', legendOptions.getPosition().getX())
189 if legendOptions.getPosition().getY() is not None:
190 target.addAttribute('y', legendOptions.getPosition().getY())
191 target.endTag('legend')
192
193
195 """Writes configuration attributes of the chart tooltip.
196
197 @param target
198 @param tooltipOptions
199 @throws PaintException
200 """
201 target.startTag('tooltip')
202 if tooltipOptions.getBackgroundColor() is not None:
203 target.addAttribute('backgroundColor',
204 tooltipOptions.getBackgroundColor().getString())
205 if tooltipOptions.getBorderColor() is not None:
206 target.addAttribute('borderColor',
207 tooltipOptions.getBorderColor().getString())
208 if tooltipOptions.getBorderRadius() is not None:
209 target.addAttribute('borderRadius',
210 tooltipOptions.getBorderRadius())
211 if tooltipOptions.getBorderWidth() is not None:
212 target.addAttribute('borderWidth', tooltipOptions.getBorderWidth())
213 if tooltipOptions.getCrosshairs() is not None:
214 target.addAttribute('crosshairs', tooltipOptions.getCrosshairs())
215 if tooltipOptions.getEnabled() is not None:
216 target.addAttribute('enabled', tooltipOptions.getEnabled())
217 if tooltipOptions.getFormatterJsFunc() is not None:
218 target.addAttribute('formatter',
219 tooltipOptions.getFormatterJsFunc())
220 if tooltipOptions.getShadow() is not None:
221 target.addAttribute('shadow', tooltipOptions.getShadow())
222 if tooltipOptions.getShared() is not None:
223 target.addAttribute('shared', tooltipOptions.getShared())
224 if tooltipOptions.getSnap() is not None:
225 target.addAttribute('snap', tooltipOptions.getSnap())
226 if tooltipOptions.getStyle() is not None:
227 target.addAttribute('style', tooltipOptions.getStyle())
228 target.endTag('tooltip')
229
230
232 """Writes configuration attributes of the chart itself.
233
234 @param target
235 @param chartOptions
236 @throws PaintException
237 """
238 target.startTag('chart')
239 if chartOptions.getType() is not None:
240 target.addAttribute('type', chartOptions.getType().getName())
241 if chartOptions.getWidth() is not None:
242 target.addAttribute('width', chartOptions.getWidth())
243 if chartOptions.getHeight() is not None:
244 target.addAttribute('height', chartOptions.getHeight())
245 if chartOptions.getBackgroundColor() is not None:
246 target.addAttribute('backgroundColor',
247 chartOptions.getBackgroundColor().getString())
248 if chartOptions.getBorderColor() is not None:
249 target.addAttribute('borderColor',
250 chartOptions.getBorderColor().getString())
251 if chartOptions.getBorderRadius() is not None:
252 target.addAttribute('borderRadius', chartOptions.getBorderRadius())
253 if chartOptions.getBorderWidth() is not None:
254 target.addAttribute('borderWidth', chartOptions.getBorderWidth())
255 if chartOptions.getIgnoreHiddenSeries() is not None:
256 target.addAttribute('ignoreHiddenSeries',
257 chartOptions.getIgnoreHiddenSeries())
258 if chartOptions.getInverted() is not None:
259 target.addAttribute('inverted', chartOptions.getInverted())
260 if chartOptions.getMargin() is not None:
261 if chartOptions.getMargin().getTop() is not None:
262 target.addAttribute('marginTop',
263 chartOptions.getMargin().getTop())
264 if chartOptions.getMargin().getLeft() is not None:
265 target.addAttribute('marginLeft',
266 chartOptions.getMargin().getLeft())
267 if chartOptions.getMargin().getBottom() is not None:
268 target.addAttribute('marginBottom',
269 chartOptions.getMargin().getBottom())
270 if chartOptions.getMargin().getRight() is not None:
271 target.addAttribute('marginRight',
272 chartOptions.getMargin().getRight())
273 if chartOptions.getSpacing() is not None:
274 if chartOptions.getSpacing().getTop() is not None:
275 target.addAttribute('spacingTop',
276 chartOptions.getSpacing().getTop())
277 if chartOptions.getSpacing().getLeft() is not None:
278 target.addAttribute('spacingLeft',
279 chartOptions.getSpacing().getLeft())
280 if chartOptions.getSpacing().getBottom() is not None:
281 target.addAttribute('spacingBottom',
282 chartOptions.getSpacing().getBottom())
283 if chartOptions.getSpacing().getRight() is not None:
284 target.addAttribute('spacingRight',
285 chartOptions.getSpacing().getRight())
286 if chartOptions.getShowAxes() is not None:
287 target.addAttribute('showAxes', chartOptions.getShowAxes())
288 if chartOptions.getZoomType() is not None:
289 target.addAttribute('zoomType',
290 chartOptions.getZoomType().getName())
291 target.addAttribute('clientZoom', chartOptions.isClientZoom())
292 if chartOptions.getAlignTicks() is not None:
293 target.addAttribute('alignTicks', chartOptions.getAlignTicks())
294 if chartOptions.getAnimation() is not None:
295 target.addAttribute('animation', chartOptions.getAnimation())
296 if chartOptions.getClassName() is not None:
297 target.addAttribute('className', chartOptions.getClassName())
298 if chartOptions.getPlot() is not None:
299 if chartOptions.getPlot().getBackgroundColor() is not None:
300 target.addAttribute('plotBackgroundColor',
301 chartOptions.getPlot().getBackgroundColor().getString())
302 if chartOptions.getPlot().getBorderColor() is not None:
303 target.addAttribute('plotBorderColor',
304 chartOptions.getPlot().getBorderColor().getString())
305 if chartOptions.getPlot().getBackgroundImage() is not None:
306 target.addAttribute('plotBackgroundImage',
307 chartOptions.getPlot().getBackgroundImage())
308 if chartOptions.getPlot().getBorderWidth() is not None:
309 target.addAttribute('plotBorderWidth',
310 chartOptions.getPlot().getBorderWidth())
311 if chartOptions.getPlot().getShadow() is not None:
312 target.addAttribute('plotShadow',
313 chartOptions.getPlot().getShadow())
314 if chartOptions.getReflow() is not None:
315 target.addAttribute('reflow', chartOptions.getReflow())
316 if chartOptions.getShadow() is not None:
317 target.addAttribute('shadow', chartOptions.getShadow())
318 if chartOptions.getStyle() is not None:
319 target.addAttribute('style', chartOptions.getStyle())
320 target.endTag('chart')
321
322
324 """Writes configuration attributes of every series type. The series
325 type can be one of the line, spline, scatter, area, areaspline, bar,
326 column and pie.
327
328 @param target
329 @param seriesOptions
330 @throws PaintException
331 """
332 target.startTag('seriesOptionsPerSeriesType')
333 # For each SeriesType have separate tag
334 for k, seriesEntryOptions in seriesOptions.iteritems():
335 tagName = k.getName()
336 target.startTag(tagName)
337 # Write options for appropriate series type
338 writeSeriesConfig(target, seriesEntryOptions)
339 target.endTag(tagName)
340 target.endTag('seriesOptionsPerSeriesType')
341
342
344 """Writes configuration attributes of a single series.
345
346 @param target
347 @param series
348 @raise PaintException:
349 """
350 # Write options for appropriate series type
351 if isinstance(series, LineConfig):
352 writeLineOptions(target, series)
353 elif isinstance(series, ScatterConfig):
354 writeScatterOptions(target, series)
355 elif isinstance(series, SplineConfig):
356 writeSplineOptions(target, series)
357 elif isinstance(series, AreaConfig):
358 writeAreaOptions(target, series)
359 elif isinstance(series, AreaSplineConfig):
360 writeAreaSplineOptions(target, series)
361 elif isinstance(series, ColumnConfig):
362 writeColumnOptions(target, series)
363 elif isinstance(series, BarConfig):
364 writeBarOptions(target, series)
365 elif isinstance(series, PieConfig):
366 writePieOptions(target, series)
367 else:
368 # Common series attributes
369 writeCommonSeriesOptions(target, series)
370
371
373 """Writes configuration attributes common to all types of series.
374
375 @param target
376 @param seriesOptions
377 @throws PaintException
378 """
379 if seriesOptions.getAllowPointSelect() is not None:
380 target.addAttribute('allowPointSelect',
381 seriesOptions.getAllowPointSelect())
382 if seriesOptions.getAnimation() is not None:
383 target.addAttribute('animation',
384 seriesOptions.getAnimation())
385 if seriesOptions.getCursor() is not None:
386 target.addAttribute('cursor', seriesOptions.getCursor())
387 if seriesOptions.getColor() is not None:
388 target.addAttribute('color', seriesOptions.getColor().getString())
389 if seriesOptions.getEnableMouseTracking() is not None:
390 target.addAttribute('enableMouseTracking',
391 seriesOptions.getEnableMouseTracking())
392 # if (seriesOptions.getSelected() != null) {
393 # target.addAttribute("selected", seriesOptions.getSelected());
394 # }
395 if seriesOptions.getShowCheckbox() is not None:
396 target.addAttribute('showCheckbox',
397 seriesOptions.getShowCheckbox())
398 if seriesOptions.getShowInLegend() is not None:
399 target.addAttribute('showInLegend',
400 seriesOptions.getShowInLegend())
401 if seriesOptions.getStacking() is not None:
402 target.addAttribute('stacking',
403 seriesOptions.getStacking().getName())
404 if seriesOptions.getShadow() is not None:
405 target.addAttribute('shadow', seriesOptions.getShadow())
406 if seriesOptions.getVisible() is not None:
407 target.addAttribute('visible', seriesOptions.getVisible())
408 # Data Label
409 writeSeriesDataLabel(target, seriesOptions.getDataLabel())
410 # State
411 writeSeriesState(target, seriesOptions.getHoverState())
412
413
415 """Writes configuration attributes of a series hover state.
416
417 @param target
418 @param seriesState
419 @throws PaintException
420 """
421 target.startTag('state')
422 if seriesState is not None:
423 target.startTag('hover')
424 if seriesState.getEnabled() is not None:
425 target.addAttribute('enabled', seriesState.getEnabled())
426 if seriesState.getLineWidth() is not None:
427 target.addAttribute('lineWidth', seriesState.getLineWidth())
428 if (isinstance(seriesState, NonLinearSeriesState)
429 and seriesState.getBrightness() is not None):
430 target.addAttribute('brightness', seriesState.getBrightness())
431 target.endTag('hover')
432 target.endTag('state')
433
434
436 """Writes configuration attributes common to all types of series. It
437 takes care of specific data labels in case of pie.
438
439 @param target
440 @param dataLabel
441 @raise PaintException
442 """
443 target.startTag('dataLabel')
444 if dataLabel is not None:
445 if isinstance(dataLabel, PieDataLabel):
446 writePieDataLabel(target, dataLabel)
447 else:
448 writeDataLabel(target, dataLabel)
449 target.endTag('dataLabel')
450
451
453 """Writes configuration attributes of a series data labels.
454
455 @param target
456 @param dataLabel
457 @raise PaintException
458 """
459 if dataLabel.getAlign() is not None:
460 target.addAttribute('align', dataLabel.getAlign().getName())
461 if dataLabel.getEnabled() is not None:
462 target.addAttribute('enabled', dataLabel.getEnabled())
463 if dataLabel.getFormatterJsFunc() is not None:
464 target.addAttribute('formatter', dataLabel.getFormatterJsFunc())
465 if dataLabel.getRotation() is not None:
466 target.addAttribute('rotation', dataLabel.getRotation())
467 if dataLabel.getStyle() is not None:
468 target.addAttribute('style', dataLabel.getStyle())
469 if dataLabel.getX() is not None:
470 target.addAttribute('x', dataLabel.getX())
471 if dataLabel.getY() is not None:
472 target.addAttribute('y', dataLabel.getY())
473 if dataLabel.getColor() is not None:
474 target.addAttribute('color', dataLabel.getColor().getString())
475
476
478 """Writes configuration attributes of a pie chart's data label.
479
480 @param target
481 @param dataLabel
482 @raise PaintException
483 """
484 writeDataLabel(target, dataLabel)
485 if dataLabel.getConnectorWidth() is not None:
486 target.addAttribute('connectorWidth',
487 dataLabel.getConnectorWidth())
488 if dataLabel.getConnectorPadding() is not None:
489 target.addAttribute('connectorPadding',
490 dataLabel.getConnectorPadding())
491 if dataLabel.getConnectorColor() is not None:
492 target.addAttribute('connectorColor',
493 dataLabel.getConnectorColor().getString())
494 if dataLabel.getDistance() is not None:
495 target.addAttribute('distance', dataLabel.getDistance())
496
497
499 """Writes configuration attributes of an axis data labels.
500
501 @param target
502 @param dataLabel
503 @raise PaintException
504 """
505 writeDataLabel(target, dataLabel)
506 if dataLabel.getStep() is not None:
507 target.addAttribute('step', dataLabel.getStep())
508
509
511 """Writes configuration attributes of an x-axis data labels.
512
513 @param target
514 @param dataLabel
515 @raise PaintException
516 """
517 target.startTag('label')
518 if dataLabel is not None:
519 writeAxisDataLabel(target, dataLabel)
520 if dataLabel.getStaggerLines() is not None:
521 target.addAttribute('staggerLines',
522 dataLabel.getStaggerLines())
523 target.endTag('label')
524
525
527 """Writes configuration attributes of y-axis data labels.
528
529 @param target
530 @param dataLabel
531 @raise PaintException
532 """
533 target.startTag('label')
534 if dataLabel is not None:
535 writeAxisDataLabel(target, dataLabel)
536 target.endTag('label')
537
538
540 """Writes configuration attributes of a marker. It takes care of
541 handling image or symbol marker.
542
543 @param target
544 @param markerOptions
545 @raise PaintException
546 """
547 target.startTag('marker')
548 if markerOptions is not None:
549 if markerOptions.getEnabled() is not None:
550 target.addAttribute('enabled', markerOptions.getEnabled())
551 if isinstance(markerOptions, ImageMarker):
552 target.addAttribute('markerType', 'image')
553 writeImageMarkerOptions(target, markerOptions)
554 elif isinstance(markerOptions, SymbolMarker):
555 target.addAttribute('markerType', 'symbol')
556 writeSymbolMarkerOptions(target, markerOptions)
557 writeMarkerStates(target, markerOptions)
558 target.endTag('marker')
559
560
562 """Writes configuration attributes of a marker states hover and select
563
564 @param target
565 @param marker
566 @raise PaintException
567 """
568 target.startTag('states')
569 target.startTag('hover')
570 if marker.getHoverState() is not None:
571 writeMarkerState(target, marker.getHoverState())
572 target.endTag('hover')
573 target.startTag('select')
574 if marker.getSelectState() is not None:
575 writeMarkerState(target, marker.getSelectState())
576 target.endTag('select')
577 target.endTag('states')
578
579
581 """Writes configuration attributes of an image marker
582
583 @param target
584 @param imgMarker
585 @raise PaintException
586 """
587 if imgMarker.getImageURL() is not None:
588 target.addAttribute('symbol', imgMarker.getImageURL())
589
590
592 """Writes configuration attributes of a symbol marker
593
594 @param target
595 @param symbolMarker
596 @raise PaintException
597 """
598 if symbolMarker.getFillColor() is not None:
599 target.addAttribute('fillColor',
600 symbolMarker.getFillColor().getString())
601 if symbolMarker.getLineColor() is not None:
602 target.addAttribute('lineColor',
603 symbolMarker.getLineColor().getString())
604 if symbolMarker.getLineWidth() is not None:
605 target.addAttribute('lineWidth',
606 symbolMarker.getLineWidth())
607 if symbolMarker.getRadius() is not None:
608 target.addAttribute('radius',
609 symbolMarker.getRadius())
610 if symbolMarker.getSymbol() is not None:
611 target.addAttribute('symbol',
612 symbolMarker.getSymbol().getName())
613
614
616 """Writes configuration attributes of a marker
617
618 @param target
619 @param markerState
620 @raise PaintException
621 """
622 if markerState.getEnabled() is not None:
623 target.addAttribute('enabled', markerState.getEnabled())
624 if markerState.getFillColor() is not None:
625 target.addAttribute('fillColor',
626 markerState.getFillColor().getString())
627 if markerState.getLineColor() is not None:
628 target.addAttribute('lineColor',
629 markerState.getLineColor().getString())
630 if markerState.getLineWidth() is not None:
631 target.addAttribute('lineWidth', markerState.getLineWidth())
632 if markerState.getRadius() is not None:
633 target.addAttribute('radius', markerState.getRadius())
634
635
637 """Writes configuration attributes common to all lines series such
638 as line, spline and area.
639
640 @param target
641 @param baseLineOptions
642 @raise PaintException
643 """
644 writeCommonSeriesOptions(target, baseLineOptions)
645 if baseLineOptions.getDashStyle() is not None:
646 target.addAttribute('dashStyle',
647 baseLineOptions.getDashStyle().getName())
648 if baseLineOptions.getLineWidth() is not None:
649 target.addAttribute('lineWidth', baseLineOptions.getLineWidth())
650 if baseLineOptions.getPointInterval() is not None:
651 target.addAttribute('pointInterval',
652 baseLineOptions.getPointInterval())
653 if baseLineOptions.getPointStart() is not None:
654 target.addAttribute('pointStart', baseLineOptions.getPointStart())
655 if baseLineOptions.getStickyTracking() is not None:
656 target.addAttribute('stickyTracking',
657 baseLineOptions.getStickyTracking())
658 writeMarkerOptions(target, baseLineOptions.getMarker())
659
660
662 """Writes configuration attributes of a spline series
663
664 @param target
665 @param splineOptions
666 @raise PaintException
667 """
668 writeBaseLineOptions(target, splineOptions)
669
670
672 """Writes configuration attributes of s scatter series
673
674 @param target
675 @param scatterOptions
676 @raise PaintException
677 """
678 writeBaseLineOptions(target, scatterOptions)
679
680
682 """Writes configuration attributes of a line series
683
684 @param target
685 @param lineOptions
686 @raise PaintException
687 """
688 writeBaseLineOptions(target, lineOptions)
689 if lineOptions.getStep() is not None:
690 target.addAttribute('step', lineOptions.getStep())
691
692
694 """Writes configuration attributes of an area series
695
696 @param target
697 @param areaOptions
698 @raise PaintException
699 """
700 writeBaseLineOptions(target, areaOptions)
701 if areaOptions.getFillColor() is not None:
702 target.addAttribute('fillColor',
703 areaOptions.getFillColor().getString())
704 if areaOptions.getFillOpacity() is not None:
705 target.addAttribute('fillOpacity', areaOptions.getFillOpacity())
706 if areaOptions.getLineColor() is not None:
707 target.addAttribute('lineColor',
708 areaOptions.getLineColor().getString())
709 if areaOptions.getThreshold() is not None:
710 target.addAttribute('threshold', areaOptions.getThreshold())
711
712
714 """Writes configuration attributes of an area-spline
715
716 @param target
717 @param areaSplineOptions
718 @raise PaintException
719 """
720 writeAreaOptions(target, areaSplineOptions)
721
722
724 """Writes configuration attributes of a pie series
725
726 @param target
727 @param pieOptions
728 @raise PaintException
729 """
730 writeCommonSeriesOptions(target, pieOptions)
731 if pieOptions.getBorderColor() is not None:
732 target.addAttribute('borderColor',
733 pieOptions.getBorderColor().getString())
734 if pieOptions.getBorderWidth() is not None:
735 target.addAttribute('borderWidth', pieOptions.getBorderWidth())
736 if pieOptions.getCenterX() is not None:
737 target.addAttribute('centerX', pieOptions.getCenterX())
738 if pieOptions.getCenterY() is not None:
739 target.addAttribute('centerY', pieOptions.getCenterY())
740 if pieOptions.getInnerSize() is not None:
741 target.addAttribute('innerSize', pieOptions.getInnerSize())
742 if pieOptions.getSize() is not None:
743 target.addAttribute('size', pieOptions.getSize())
744 if pieOptions.getSlicedOffset() is not None:
745 target.addAttribute('slicedOffset', pieOptions.getSlicedOffset())
746
747
749 """Writes configuration attributes common to columnar series such as
750 bar and column
751
752 @param target
753 @param baseBarOptions
754 @raise PaintException
755 """
756 writeCommonSeriesOptions(target, baseBarOptions)
757 if baseBarOptions.getBorderColor() is not None:
758 target.addAttribute('borderColor',
759 baseBarOptions.getBorderColor().getString())
760 if baseBarOptions.getBorderRadius() is not None:
761 target.addAttribute('borderRadius',
762 baseBarOptions.getBorderRadius())
763 if baseBarOptions.getBorderWidth() is not None:
764 target.addAttribute('borderWidth',
765 baseBarOptions.getBorderWidth())
766 if baseBarOptions.getColorByPoint() is not None:
767 target.addAttribute('colorByPoint',
768 baseBarOptions.getColorByPoint())
769 if baseBarOptions.getGroupPadding() is not None:
770 target.addAttribute('groupPadding',
771 baseBarOptions.getGroupPadding())
772 if baseBarOptions.getMinPointLength() is not None:
773 target.addAttribute('minPointLength',
774 baseBarOptions.getMinPointLength())
775 if baseBarOptions.getPointPadding() is not None:
776 target.addAttribute('pointPadding',
777 baseBarOptions.getPointPadding())
778 if baseBarOptions.getPointWidth() is not None:
779 target.addAttribute('pointWidth',
780 baseBarOptions.getPointWidth())
781
782
784 """Writes configuration attributes of a bar series
785
786 @param target
787 @param barOptions
788 @raise PaintException
789 """
790 writeBaseBarOptions(target, barOptions)
791
792
794 """Writes configuration attributes of a column series
795
796 @param target
797 @param columnOptions
798 @raise PaintException
799 """
800 writeBaseBarOptions(target, columnOptions)
801
802
804 """Writes data of each series of the chart. It transforms data into
805 a form which is usable by the Muntjac terminal class. It also writes
806 configuration attributes specific to each series, if any.
807
808 @param target
809 @param chartSeriesType
810 @param data
811 @param xAxes
812 @param yAxes
813 @throws PaintException
814 """
815 if data is None:
816 return
817 for series in data:
818 target.startTag('series')
819 if series.getName() is not None and len(series.getName()) > 0:
820 target.addAttribute('name', series.getName())
821 if series.getType() is not None:
822 target.addAttribute('type', series.getType().getName())
823 if series.getStack() is not None and len(series.getStack()) > 0:
824 target.addAttribute('stack', series.getStack())
825 target.addAttribute('xAxis', getXAxisIndex(series.getXAxis(),
826 xAxes))
827 target.addAttribute('yAxis', getYAxisIndex(series.getYAxis(),
828 yAxes))
829 seriesOptionsTagName = chartSeriesType.getName()
830 if series.getType() is not None:
831 seriesOptionsTagName = series.getType().getName()
832 target.startTag(seriesOptionsTagName)
833 if series.getConfig() is not None:
834 writeSeriesConfig(target, series.getConfig())
835 target.endTag(seriesOptionsTagName)
836 target.startTag('points')
837 if series.getPoints() is not None:
838 writePoints(target, series.getPoints())
839 target.endTag('points')
840 target.endTag('series')
841
842
844 """Writes point data (x, y) and its configuration attributes, if any.
845 If a point does not have x and y values then the point is skipped.
846 However, for such points empty tags is created without any attributes
847 or children.
848
849 @param target
850 @param points
851 @throws PaintException
852 """
853 from muntjac.addon.invient.invient_charts import DecimalPoint
854
855 if points is None:
856 return
857 for point in points:
858 target.startTag('point')
859 if (point.getX() is not None) or (point.getY() is not None):
860 if point.getId() is not None and len(point.getId()) > 0:
861 target.addAttribute('id', point.getId())
862 if point.getName() is not None and len(point.getName()) > 0:
863 target.addAttribute('name', point.getName())
864 if point.getX() is not None:
865 if isinstance(point, DecimalPoint):
866 target.addAttribute('x', float(point.getX()))
867 else:
868 target.addAttribute('x', getDate(point.getX(),
869 point.getSeries().isIncludeTime()))
870
871 if point.getY() is not None:
872 target.addAttribute('y', float(point.getY()))
873
874 target.addAttribute('isShift', point.isShift())
875
876 # Point config
877 if point.getConfig() is not None:
878 if point.getConfig().getSliced() is not None:
879 target.addAttribute('sliced',
880 point.getConfig().getSliced())
881 if point.getConfig().getSelected() is not None:
882 target.addAttribute('selected',
883 point.getConfig().getSelected())
884 if point.getConfig().getColor() is not None:
885 target.addAttribute('color',
886 point.getConfig().getColor().getString())
887 if point.getConfig().getMarker() is not None:
888 writeMarkerOptions(target,
889 point.getConfig().getMarker())
890 target.endTag('point')
891
892
894 """Writes configuration attributes common to all types of axis.
895
896 @param target
897 @param axis
898 @param axes
899 @throws PaintException
900 """
901 if axis.getAlternateGridColor() is not None:
902 target.addAttribute('alternateGridColor',
903 axis.getAlternateGridColor().getString())
904 if axis.getEndOnTick() is not None:
905 target.addAttribute('endOnTick', axis.getEndOnTick())
906 if axis.getGrid() is not None:
907 writeAxisGrid(target, axis.getGrid())
908 if axis.getId() is not None and len(axis.getId()) > 0:
909 target.addAttribute('id', axis.getId())
910 if axis.getLineColor() is not None:
911 target.addAttribute('lineColor', axis.getLineColor().getString())
912 if axis.getLineWidth() is not None:
913 target.addAttribute('lineWidth', axis.getLineWidth())
914 if axis.getLinkedTo() is not None:
915 target.addAttribute('linkedTo',
916 getAxisIndex(axis.getLinkedTo(), axes))
917 if axis.getMaxPadding() is not None:
918 target.addAttribute('maxPadding', axis.getMaxPadding())
919 if axis.getMaxZoom() is not None:
920 target.addAttribute('maxZoom', axis.getMaxZoom())
921 if axis.getMinPadding() is not None:
922 target.addAttribute('minPadding', axis.getMinPadding())
923 if axis.getMinorGrid() is not None:
924 writeAxisMinorGrid(target, axis.getMinorGrid())
925 if axis.getMinorTick() is not None:
926 writeAxisMinorTick(target, axis.getMinorTick())
927 if axis.getOffset() is not None:
928 target.addAttribute('offset', axis.getOffset())
929 if axis.getOpposite() is not None:
930 target.addAttribute('opposite', axis.getOpposite())
931 if axis.getReversed() is not None:
932 target.addAttribute('reversed', axis.getReversed())
933 if axis.getShowFirstLabel() is not None:
934 target.addAttribute('showFirstLabel', axis.getShowFirstLabel())
935 if axis.getShowLastLabel() is not None:
936 target.addAttribute('showLastLabel', axis.getShowLastLabel())
937 if axis.getStartOfWeek() is not None:
938 target.addAttribute('startOfWeek', axis.getStartOfWeek().ordinal())
939 if axis.getStartOnTick() is not None:
940 target.addAttribute('startOnTick', axis.getStartOnTick())
941 if axis.getTick() is not None:
942 writeAxisTick(target, axis.getTick())
943 if axis.getType() is not None:
944 target.addAttribute('type', axis.getType().getName())
945
946 # Title
947 writeAxisTitle(target, axis.getTitle())
948
949 # Labels
950 if isinstance(axis.getLabel(), XAxisDataLabel):
951 writeXAxisDataLabel(target, axis.getLabel())
952 else:
953 writeYAxisDataLabel(target, axis.getLabel())
954
955 if isinstance(axis, NumberAxis):
956 writePlotBands(target, axis.getPlotBands())
957 writePlotLines(target, axis.getPlotLines())
958 elif isinstance(axis, DateTimeAxis):
959 writePlotBands(target, axis.getPlotBands())
960 writePlotLines(target, axis.getPlotLines())
961 elif isinstance(axis, CategoryAxis):
962 writePlotBands(target, axis.getPlotBands())
963 writePlotLines(target, axis.getPlotLines())
964
965
967 """Returns an index of an x-axis in a list of x-axis only if the
968 x-axis exists otherwise null
969
970 @param indexOfXAxis
971 @param xAxes
972 @return: Retrieves Retrieves an index of an x-axis in a list of x-axis
973 only if the x-axis exists otherwise null
974 """
975 return getAxisIndex(indexOfXAxis, xAxes)
976
977
979 """Returns an index of a y-axis in a list of y-axis only if the y-axis
980 exists otherwise null
981
982 @param indexOfYAxis
983 @param yAxes
984 @return: Returns index of a y-axis in a list of y-axis only if the
985 y-axis exists otherwise null
986 """
987 return getAxisIndex(indexOfYAxis, yAxes)
988
989
991 """Returns an index of an axis in a list of axis only if the axis
992 exists otherwise null
993
994 @param indexOfAxis
995 @param axes
996 @return: Returns an index of an axis in a list of axis only if the
997 axis exists otherwise null
998 """
999 if ((indexOfAxis is None) or (axes is None)) or (len(axes) == 0):
1000 return 0
1001
1002 index = 0
1003 for axis in axes:
1004 if axis == indexOfAxis:
1005 return index
1006 index += 1
1007
1008 return None
1009
1010
1012 """Writes configuration attributes of the plotbands associated with
1013 an axis.
1014
1015 @param target
1016 @param plotBands
1017 @throws PaintException
1018 """
1019 target.startTag('plotBands')
1020 if plotBands is not None:
1021 for plotBand in plotBands:
1022 target.startTag('plotBand')
1023 if plotBand.getColor() is not None:
1024 target.addAttribute('color',
1025 plotBand.getColor().getString())
1026 if plotBand.getId() is not None:
1027 target.addAttribute('id', plotBand.getId())
1028 if plotBand.getZIndex() is not None:
1029 target.addAttribute('zIndex', plotBand.getZIndex())
1030 writePlotLabel(target, plotBand.getLabel())
1031 writePlotBandRange(target, plotBand.getRange())
1032 target.endTag('plotBand')
1033 target.endTag('plotBands')
1034
1035
1037 """Writes configuration attributes of a plotlabel.
1038
1039 @param target
1040 @param plotLabel
1041 @throws PaintException
1042 """
1043 target.startTag('label')
1044 if plotLabel is not None:
1045 if plotLabel.getAlign() is not None:
1046 target.addAttribute('align', plotLabel.getAlign().getName())
1047 if plotLabel.getRotation() is not None:
1048 target.addAttribute('rotation', plotLabel.getRotation())
1049 if plotLabel.getStyle() is not None:
1050 target.addAttribute('style', plotLabel.getStyle())
1051 if plotLabel.getText() is not None:
1052 target.addAttribute('text', plotLabel.getText())
1053 if plotLabel.getTextAlign() is not None:
1054 target.addAttribute('textAlign',
1055 plotLabel.getTextAlign().getName())
1056 if plotLabel.getVertAlign() is not None:
1057 target.addAttribute('verticalAlign',
1058 plotLabel.getVertAlign().getName())
1059 if plotLabel.getX() is not None:
1060 target.addAttribute('x', plotLabel.getX())
1061 if plotLabel.getY() is not None:
1062 target.addAttribute('y', plotLabel.getY())
1063 target.endTag('label')
1064
1065
1067 """Writes from/to value for a plotband. It considers date and number
1068 values separately.
1069
1070 @param target
1071 @param plotBandRange
1072 @throws PaintException
1073 """
1074 target.startTag('rangeValue')
1075 if plotBandRange is not None:
1076 if isinstance(plotBandRange, NumberRange):
1077 target.addAttribute('valueType', 'number')
1078 numberRange = plotBandRange
1079 if numberRange.getFrom() is not None:
1080 target.addAttribute('from', numberRange.getFrom())
1081 if numberRange.getTo() is not None:
1082 target.addAttribute('to', numberRange.getTo())
1083 elif isinstance(plotBandRange, DateTimeRange):
1084 target.addAttribute('valueType', 'date')
1085 dateRange = plotBandRange
1086 target.startTag('from')
1087 if dateRange.getFrom() is not None:
1088 target.addAttribute('year',
1089 getYearFromDate(dateRange.getFrom()))
1090 target.addAttribute('month',
1091 getMonthFromDate(dateRange.getFrom()))
1092 target.addAttribute('day',
1093 getDayFromDate(dateRange.getFrom()))
1094 target.endTag('from')
1095 target.startTag('to')
1096 if dateRange.getTo() is not None:
1097 target.addAttribute('year',
1098 getYearFromDate(dateRange.getTo()))
1099 target.addAttribute('month',
1100 getMonthFromDate(dateRange.getTo()))
1101 target.addAttribute('day',
1102 getDayFromDate(dateRange.getTo()))
1103 target.endTag('to')
1104 target.endTag('rangeValue')
1105
1106
1108 """Writes configuration attributes of the plotlines
1109
1110 @param target
1111 @param plotLines
1112 @throws PaintException
1113 """
1114 target.startTag('plotLines')
1115 if plotLines is not None:
1116 for plotLine in plotLines:
1117 target.startTag('plotLine')
1118 if plotLine.getColor() is not None:
1119 target.addAttribute('color',
1120 plotLine.getColor().getString())
1121 if plotLine.getDashStyle() is not None:
1122 target.addAttribute('dashStyle',
1123 plotLine.getDashStyle().getName())
1124 if plotLine.getId() is not None:
1125 target.addAttribute('id', plotLine.getId())
1126 if plotLine.getWidth() is not None:
1127 target.addAttribute('width', plotLine.getWidth())
1128 if plotLine.getZIndex() is not None:
1129 target.addAttribute('zIndex', plotLine.getZIndex())
1130 writePlotLabel(target, plotLine.getLabel())
1131 writePlotLineValue(target, plotLine.getValue())
1132 target.endTag('plotLine')
1133 target.endTag('plotLines')
1134
1135
1137 """Writes value of a plotline. It considers date and number value
1138 separately.
1139
1140 @param target
1141 @param plotLineValue
1142 @throws PaintException
1143 """
1144 target.startTag('lineValue')
1145 if plotLineValue is not None:
1146 if (isinstance(plotLineValue, NumberValue)
1147 and plotLineValue.getValue() is not None):
1148 target.addAttribute('valueType', 'number')
1149 target.addAttribute('value', plotLineValue.getValue())
1150 elif (isinstance(plotLineValue, DateTimeValue)
1151 and plotLineValue.getValue() is not None):
1152 target.addAttribute('valueType', 'date')
1153 date = plotLineValue.getValue()
1154 target.addAttribute('year', getYearFromDate(date))
1155 target.addAttribute('month', getMonthFromDate(date))
1156 target.addAttribute('day', getDayFromDate(date))
1157 target.endTag('lineValue')
1158
1159
1161 writeAxisMinorTick(target, tick)
1162 if tick.getPixelInterval() is not None:
1163 target.addAttribute('tickPixelInterval', tick.getPixelInterval())
1164 if tick.getPlacement() is not None:
1165 target.addAttribute('tickmarkPlacement',
1166 tick.getPlacement().getName())
1167
1168
1170 """Writes configuration attributes of an axis. Depending on type of
1171 the argument tick, it either writes attributes for L{MinorTick} or
1172 L{Tick}
1173
1174 @param target
1175 @param tick
1176 @raise PaintException
1177 """
1178 attNameColor = 'minorTickColor'
1179 attNameInterval = 'minorTickInterval'
1180 attNameLength = 'minorTickLength'
1181 attNamePosition = 'minorTickPosition'
1182 attNameWidth = 'minorTickWidth'
1183 if isinstance(tick, Tick):
1184 attNameColor = 'tickColor'
1185 attNameInterval = 'tickInterval'
1186 attNameLength = 'tickLength'
1187 attNamePosition = 'tickPosition'
1188 attNameWidth = 'tickWidth'
1189 if tick.getColor() is not None:
1190 target.addAttribute(attNameColor, tick.getColor().getString())
1191 if tick.getInterval() is not None:
1192 target.addAttribute(attNameInterval, tick.getInterval())
1193 if tick.getLength() is not None:
1194 target.addAttribute(attNameLength, tick.getLength())
1195 if tick.getPosition() is not None:
1196 target.addAttribute(attNamePosition, tick.getPosition().getName())
1197 if tick.getWidth() is not None:
1198 target.addAttribute(attNameWidth, tick.getWidth())
1199
1200
1202 writeAxisMinorGrid(target, grid)
1203
1204
1206 """Writes configuration attributes of an axis. Depending on type of
1207 the argument tick, it either writes attributes for L{MinorGrid} or
1208 L{Grid}
1209
1210 @param target
1211 @param grid
1212 @raise PaintException
1213 """
1214 attNameLineColor = 'minorGridLineColor'
1215 attNameLineWidth = 'minorGridLineWidth'
1216 attNameLineDashStyle = 'minorGridLineDashStyle'
1217 if isinstance(grid, Grid):
1218 attNameLineColor = 'gridLineColor'
1219 attNameLineWidth = 'gridLineWidth'
1220 attNameLineDashStyle = 'gridLineDashStyle'
1221 if grid.getLineColor() is not None:
1222 target.addAttribute(attNameLineColor,
1223 grid.getLineColor().getString())
1224 if grid.getLineWidth() is not None:
1225 target.addAttribute(attNameLineWidth, grid.getLineWidth())
1226 if grid.getLineDashStyle() is not None:
1227 target.addAttribute(attNameLineDashStyle,
1228 grid.getLineDashStyle().getName())
1229
1230
1232 target.startTag('title')
1233 if title is not None:
1234 if title.getAlign() is not None:
1235 target.addAttribute('align', title.getAlign().getName())
1236 if title.getMargin() is not None:
1237 target.addAttribute('margin', title.getMargin())
1238 if title.getRotation() is not None:
1239 target.addAttribute('rotation', title.getRotation())
1240 if title.getStyle() is not None:
1241 target.addAttribute('style', title.getStyle())
1242 if title.getText() is not None:
1243 target.addAttribute('text', title.getText())
1244 target.endTag('title')
1245
1246
1248 """Iteratively processes each x-axis and writes configuration
1249 attributes of each axis based on type of the axis e.g. L{NumberAxis},
1250 L{DateTimeAxis} and L{CategoryAxis}
1251
1252 @param target
1253 @param axes
1254 @raise PaintException
1255 """
1256 target.startTag('xAxes')
1257 if axes is not None:
1258 for xAxis in axes:
1259 target.startTag('xAxis')
1260 writeBaseAxis(target, xAxis, axes)
1261 if isinstance(xAxis, NumberXAxis):
1262 writeNumberAxis(target, xAxis)
1263 elif isinstance(xAxis, CategoryAxis):
1264 writeCategoryAxis(target, xAxis)
1265 elif isinstance(xAxis, DateTimeAxis):
1266 # Check if time should be included as part of a date value.
1267 # If any of the datetime series
1268 writeDateTimeAxis(target, xAxis,
1269 isIncludeTime(xAxis,
1270 config.getInvientCharts().getAllSeries()))
1271 target.endTag('xAxis')
1272 target.endTag('xAxes')
1273
1274
1276 from muntjac.addon.invient.invient_charts import DateTimeSeries
1277
1278 for series in chartSeries:
1279 if (isinstance(series, DateTimeSeries)
1280 and series.getXAxis() == axis):
1281 return series.isIncludeTime()
1282
1283 return False
1284
1285
1287 if numberAxis.getAllowDecimals() is not None:
1288 target.addAttribute('allowDecimals', numberAxis.getAllowDecimals())
1289 if numberAxis.getMax() is not None:
1290 target.addAttribute('max', numberAxis.getMax())
1291 if numberAxis.getMin() is not None:
1292 target.addAttribute('min', numberAxis.getMin())
1293
1294
1296 """Returns milliseconds of the date argument dt. If the argument
1297 isIncludeTime is false then the returned milliseconds does not include
1298 time.
1299 """
1300 if not isIncludeTime:
1301 dt2 = datetime(dt.year, dt.month, dt.day)
1302 dt = dt2
1303 return long(totalseconds(dt - datetime(1970, 1, 1)) * 1e03)
1304
1305
1307 """@param target
1308 @param dateTimeAxis
1309 @raise PaintException
1310 """
1311 if dateTimeAxis.getMax() is not None:
1312 target.addAttribute('max', getDate(dateTimeAxis.getMax(),
1313 isIncludeTime))
1314 if dateTimeAxis.getMin() is not None:
1315 target.addAttribute('min', getDate(dateTimeAxis.getMin(),
1316 isIncludeTime))
1317 if dateTimeAxis.getDateTimeLabelFormat() is not None:
1318 target.startTag('dateTimeLabelFormats')
1319 dateTimeLabelFormat = dateTimeAxis.getDateTimeLabelFormat()
1320 if dateTimeLabelFormat.getSecond() is not None:
1321 target.addAttribute('second',
1322 dateTimeAxis.getDateTimeLabelFormat().getSecond())
1323 if dateTimeLabelFormat.getMinute() is not None:
1324 target.addAttribute('minute',
1325 dateTimeAxis.getDateTimeLabelFormat().getMinute())
1326 if dateTimeLabelFormat.getHour() is not None:
1327 target.addAttribute('hour',
1328 dateTimeAxis.getDateTimeLabelFormat().getHour())
1329 if dateTimeLabelFormat.getDay() is not None:
1330 target.addAttribute('day',
1331 dateTimeAxis.getDateTimeLabelFormat().getDay())
1332 if dateTimeLabelFormat.getWeek() is not None:
1333 target.addAttribute('week',
1334 dateTimeAxis.getDateTimeLabelFormat().getWeek())
1335 if dateTimeLabelFormat.getMonth() is not None:
1336 target.addAttribute('month',
1337 dateTimeAxis.getDateTimeLabelFormat().getMonth())
1338 if dateTimeLabelFormat.getYear() is not None:
1339 target.addAttribute('year',
1340 dateTimeAxis.getDateTimeLabelFormat().getYear())
1341 target.endTag('dateTimeLabelFormats')
1342
1343
1345 target.startTag('categories')
1346 if (categoryAxis.getCategories() is not None
1347 and len(categoryAxis.getCategories()) > 0):
1348 for category in categoryAxis.getCategories():
1349 target.startTag('category')
1350 target.addAttribute('name', category)
1351 target.endTag('category')
1352 target.endTag('categories')
1353
1354
1356 target.startTag('yAxes')
1357 if axes is not None:
1358 for yAxis in axes:
1359 target.startTag('yAxis')
1360 writeBaseAxis(target, yAxis, axes)
1361 if isinstance(yAxis, NumberYAxis):
1362 writeNumberAxis(target, yAxis)
1363 target.endTag('yAxis')
1364 target.endTag('yAxes')
1365
1366
1368 """Writes configuration attributes of the chart labels.
1369 """
1370 target.startTag('labels')
1371 if (chartLabel is not None and chartLabel.getLabels() is not None
1372 and len(chartLabel.getLabels()) > 0):
1373 if chartLabel.getStyle() is not None:
1374 target.addAttribute('style', chartLabel.getStyle())
1375 target.startTag('items')
1376 for label in chartLabel.getLabels():
1377 if ((label.getHtml() is not None)
1378 or (label.getStyle() is not None)):
1379 target.startTag('item')
1380 if label.getHtml() is not None:
1381 target.addAttribute('html', label.getHtml())
1382 if label.getStyle() is not None:
1383 target.addAttribute('style', label.getStyle())
1384 target.endTag('item')
1385 target.endTag('items')
1386 target.endTag('labels')
1387
1388
1390 """@return: Returns year of the argument date."""
1391 if date is None:
1392 return None
1393 return str(date.year)
1394
1395
1397 """@return: Returns month of the argument date. The returned values
1398 is based on zero-index i.e. for month January, the values
1399 returned is "0"
1400 """
1401 if date is None:
1402 return None
1403 return str(date.month - 1)
1404
1405
1410
1411
1413 """Writes information about which series were added, removed or
1414 updated. This information is used by Muntjac terminal class to decide
1415 whether to add a new series or remove/delete an existing series.
1416 Basically, this information helps client to update only a portion of
1417 the chart instead of full chart.
1418 """
1419 for seriesName in seriesCURMap.keys():
1420 seriesCURSet = seriesCURMap.get(seriesName)
1421 if seriesCURSet is not None and len(seriesCURSet) > 0:
1422 for seriesCUR in seriesCURSet:
1423 target.startTag('seriesDataUpdate')
1424 target.addAttribute('seriesName', seriesCUR.getName())
1425 target.addAttribute('operation',
1426 seriesCUR.getType().getName())
1427 target.addAttribute('isReloadPoints',
1428 seriesCUR.isReloadPoints())
1429 target.startTag('pointsAdded')
1430 if len(seriesCUR.getPointsAdded()) > 0:
1431 writePoints(target, seriesCUR.getPointsAdded())
1432 target.endTag('pointsAdded')
1433 target.startTag('pointsRemoved')
1434 if len(seriesCUR.getPointsRemoved()) > 0:
1435 writePoints(target, seriesCUR.getPointsRemoved())
1436 target.endTag('pointsRemoved')
1437 target.endTag('seriesDataUpdate')
1438
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Jul 6 19:33:19 2013 | http://epydoc.sourceforge.net |