Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2012 Brian H. Clowers 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 from muntjac.api import VerticalLayout, HorizontalLayout, TextField, \ 16 PasswordField, Button, Alignment, AbsoluteLayout 17 from muntjac.ui.button import IClickListener 18 19 from muntjac.api import Label, Window, Application 20 21 from muntjac.ui.window import Notification 22 23 from muntjac.terminal.gwt.server.application_servlet import ApplicationServlet 24 25 from paste.urlmap import URLMap 26 from paste.session import SessionMiddleware 27 from paste.fileapp import DirectoryApp 28 29 from wsgiref.simple_server import make_server 30 31 from muntjac.terminal.sizeable \ 32 import ISizeable 33 34 from muntjac.addon.invient.invient_charts \ 35 import ChartZoomListener, DateTimePoint, InvientCharts, DateTimeSeries, \ 36 SeriesType, XYSeries, DecimalPoint, PointClickListener, \ 37 ChartSVGAvailableListener, ChartClickListener, ChartResetZoomListener, \ 38 SeriesClickListerner, SeriesHideListerner, SeriesShowListerner, \ 39 SeriesLegendItemClickListerner, PointRemoveListener, PointSelectListener, \ 40 PointUnselectListener, PieChartLegendItemClickListener 41 42 from muntjac.addon.invient.invient_charts_config \ 43 import DateTimePlotBand, DateTimeRange, InvientChartsConfig, Margin, \ 44 DateTimeAxis, NumberYAxis, AxisTitle, LineConfig, SymbolMarker, \ 45 MarkerState, ZoomType, YAxisDataLabel, Grid, AreaConfig, SeriesState, \ 46 CategoryAxis, NumberPlotLine, Legend, Layout, Position, HorzAlign, \ 47 VertAlign, NumberValue, NumberXAxis, ScatterConfig, DataLabel, \ 48 SeriesConfig, Stacking, AxisTitleAlign, BarConfig, Tooltip, ColumnConfig, \ 49 XAxisDataLabel, Spacing, Tick, TickmarkPlacement, Symbol, NumberPlotBand, \ 50 NumberRange, AreaSplineConfig, PieConfig, PieDataLabel, PointConfig, \ 51 SplineConfig, ImageMarker, MinorGrid, PlotLabel, ChartLabel, \ 52 ChartLabelItem, DashStyle 53 54 from muntjac.addon.invient.color \ 55 import RGBA, RGB 56 57 from muntjac.addon.invient.gradient \ 58 import LinearColorStop, LinearGradient 59 60 from muntjac.util \ 61 import totalseconds, OrderedSet 62 63 import numpy as N 64 65 import time69 _TREE_ITEM_CAPTION_PROP_ID = 'PlotChartWindow' 70 71 _SEPARATOR = '|' 7218474 super(PlotWindow, self).__init__() 75 76 self.mainLayout = VerticalLayout() 77 self.setContent(self.mainLayout) 78 79 self.setCaption('Basic Example') 80 infoBar = HorizontalLayout() 81 self.mainLayout.addComponent(infoBar) 82 infoBar.setHeight('50px') 83 infoBar.setWidth('100%') 84 85 86 self.showPlot()87 88 89 @classmethod91 if len(values) > 0 and isinstance(values[0], (float, int)): 92 points = OrderedSet() 93 for value in values: 94 points.add(DecimalPoint(series, value)) 95 return points 96 else: 97 points = OrderedSet() 98 for value in values: 99 y = None 100 if len(value) == 0: 101 continue 102 if len(value) == 2: 103 x = value[0] 104 y = value[1] 105 else: 106 x = value[0] 107 points.add(DecimalPoint(series, x, y)) 108 return points109111 chartConfig = InvientChartsConfig() 112 chartConfig.getGeneralChartConfig().setType(SeriesType.LINE) 113 chartConfig.getGeneralChartConfig().setZoomType(ZoomType.XY) 114 115 chartConfig.getTitle().setText( 116 'Invient Test') 117 chartConfig.getSubtitle().setText('Numpy Random') 118 119 120 xAxis = NumberXAxis() 121 xAxis.setTitle(AxisTitle('Data #')) 122 xAxis.setStartOnTick(True) 123 xAxis.setEndOnTick(True) 124 xAxis.setShowLastLabel(True) 125 xAxesSet = set() 126 xAxesSet.add(xAxis) 127 chartConfig.setXAxes(xAxesSet) 128 129 yAxis = NumberYAxis() 130 yAxis.setTitle(AxisTitle('Value')) 131 yAxesSet = set() 132 yAxesSet.add(yAxis) 133 chartConfig.setYAxes(yAxesSet) 134 135 legend = Legend() 136 legend.setLayout(Layout.VERTICAL) 137 legendPos = Position() 138 legendPos.setAlign(HorzAlign.LEFT) 139 legendPos.setVertAlign(VertAlign.TOP) 140 legendPos.setX(100) 141 legendPos.setY(70) 142 legend.setPosition(legendPos) 143 legend.setFloating(True) 144 legend.setBorderWidth(1) 145 legend.setBackgroundColor(RGB(255, 255, 255)) 146 chartConfig.setLegend(legend) 147 148 plotCfg = LineConfig() 149 150 151 marker = SymbolMarker(False) 152 plotCfg.setMarker(marker) 153 154 plotCfg.setColor(RGBA(223, 83, 83, 0.5)) 155 plotCfg.setAllowPointSelect(False) 156 plotCfg.setEnableMouseTracking(False) # Controls whether or not you can highlight a dataset 157 plotCfg.setAnimation(False) 158 159 chartConfig.addSeriesConfig(plotCfg) 160 series = XYSeries('Set 1', plotCfg) 161 series.setSeriesPoints(self.setData(series)) 162 163 164 chart = InvientCharts(chartConfig) 165 chart.addSeries(series) 166 167 self.addChart(chart)168 171172 - def addChart(self, chart, isPrepend=False, isRegisterEvents=True, 173 isRegisterSVGEvent=True, isSetHeight=True):174 175 chart.setSizeFull() 176 chart.setStyleName('v-chart-min-width') 177 if isSetHeight: 178 chart.setHeight('410px') 179 180 181 self.mainLayout.removeAllComponents() 182 # Add chart 183 self.mainLayout.addComponent(chart)198 199 200 if __name__ == '__main__': 201 from muntjac.main import muntjac 202 muntjac(HelloPlot, nogui=True, debug=True, contextRoot='.') 203189 """Init is invoked on application load (when a user accesses 190 the application for the first time). 191 """ 192 # Application.init is called once for each application. Here it 193 # creates the UI and connects it to the business logic. 194 # Create the main layout for our application 195 mainWindow = PlotWindow() 196 197 self.setMainWindow(mainWindow)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Apr 20 16:53:08 2013 | http://epydoc.sourceforge.net |