예제 #1
0
    def _drawLine(self, aValue, dispIdx, isLastFlag):
        """
        
        """
        groupStr = self.instGroup
        if isLastFlag == True:
            groupStr += "_lastData"
        else:
            groupStr += "_curvData"
        
        instg = InstructionGroup(group=groupStr)
        color = Color()

        if aValue > 0:
            color.rgba = self.UP_COLOR
        else:
            color.rgba = self.DOWN_COLOR
        instg.add(color)
        x1 = self.chartPos[0] + dispIdx * (self.tickWide + self.tickGap) + self.tickGap 
        y1 = self.chartPos[1] + self.baseYPos
        rectHeight = abs(aValue) * self.yscale
        if aValue < 0:
            y1 = y1 - rectHeight
        instg.add(Rectangle(pos=(x1,y1), size=(self.tickWide, rectHeight)))

        self.canvas.add(instg)
예제 #2
0
    def getLineColor(self, price1, price2):
        color = Color()

        if price1 > price2:
            color.rgba = self.DOWN_COLOR
        elif price1 < price2:
            color.rgba = self.UP_COLOR
        else:
            color.rgba = self.EQUAL_COLOR
        return color
예제 #3
0
    def _drawLine(self, preClose, aDict, dispIdx, isLastFlag):
        """
        
        """
        groupStr = self.instGroup
        if isLastFlag == True:
            groupStr += "_lastData"
        else:
            groupStr += "_curvData"

        instg = InstructionGroup(group=groupStr)
        color = Color()

        volume = aDict.get("VOL")

        closePrice = aDict.get("CP")
        if closePrice > preClose:
            color.rgba = self.UP_COLOR
            instg.add(color)
            x1 = self.chartPos[0] + dispIdx * (self.tickWide +
                                               self.tickGap) + self.tickGap
            y1 = self.chartPos[1]
            instg.add(
                Rectangle(pos=(x1, y1),
                          size=(self.tickWide,
                                (volume - self.lowestValue) * self.yscale)))
        elif closePrice < preClose:
            color.rgba = self.DOWN_COLOR
            instg.add(color)
            x1 = self.chartPos[0] + dispIdx * (self.tickWide +
                                               self.tickGap) + self.tickGap
            y1 = self.chartPos[1]
            instg.add(
                Rectangle(pos=(x1, y1),
                          size=(self.tickWide,
                                (volume - self.lowestValue) * self.yscale)))
        else:
            color.rgba = self.EQUAL_COLOR
            instg.add(color)
            x1 = self.chartPos[0] + dispIdx * (self.tickWide +
                                               self.tickGap) + self.tickGap
            y1 = self.chartPos[1]
            instg.add(
                Rectangle(pos=(x1, y1),
                          size=(self.tickWide,
                                (volume - self.lowestValue) * self.yscale)))

        self.canvas.add(instg)
예제 #4
0
    def drawCrossLine(self, index):
        if self.dataList == None or index >= len(self.dataList):
            return

        data = self.dataList[index]

        price = data.get("price")

        color = Color()
        color.rgba = self.CROSS_LINE_COLOR

        self.canvas.remove_group("cross_line")

        instg = InstructionGroup(group="cross_line")
        instg.add(color)
        x1 = int(self.pos[0] + self.shift_left + index * self.xscale)
        y1 = self.pos[1] + self.shift_bottom
        x2 = int(self.pos[0] + self.shift_left + index * self.xscale)
        y2 = self.pos[1] + self.height - self.shift_top
        instg.add(Line(points=(x1, y1, x2, y2), width=1))
        self.canvas.add(instg)

        instg = InstructionGroup(group="cross_line")
        instg.add(color)
        x1 = self.pos[0] + self.shift_left
        y1 = int(self.pos[1] + self.shift_bottom +
                 (price - self.min_price) * self.yscale)
        x2 = self.pos[0] + self.width - self.shift_right
        y2 = int(self.pos[1] + self.shift_bottom +
                 (price - self.min_price) * self.yscale)
        instg.add(Line(points=(x1, y1, x2, y2), width=1))
        self.canvas.add(instg)
예제 #5
0
 def drawCordFrame(self):
     
     # 畫一條橫線
     instg = InstructionGroup(group="frame")
     frameColor = Color()
     frameColor.rgba = self.FRAME_COLOR
     instg.add(frameColor)
     x1 = int(self.pos[0] + self.shift_left)
     y1 = int(self.pos[1] + self.shift_bottom)
     x2 = int(self.pos[0] + self.width - self.shift_right)
     y2 = int(self.pos[1] + self.shift_bottom)
     instg.add(Line(points=(x1, y1, x2, y2), width=1))        
     self.canvas.add(instg)
     
     # 畫一條豎線
     instg = InstructionGroup(group="frame")
     instg.add(frameColor)
     center_pos = int(self.pillarPoint / 2)
     self.center_xpos = int(self.pos[0] + self.shift_left + (self.min_tickNum * -1) * self.pillarSumPoint + self.ycordWidth + center_pos)
     x1 = self.center_xpos
     y1 = int(self.pos[1] + self.shift_bottom)
     x2 = self.center_xpos
     y2 = int(self.pos[1] + self.height - self.shift_top)
     instg.add(Line(points=(x1, y1, x2, y2), width=1))
     self.canvas.add(instg)
예제 #6
0
    def drawCrossLine(self, aIndex):
        """
        """
        dataNum = len(self.minTimeList)
        if dataNum == 0:
            return
        if aIndex >= dataNum:
            index = dataNum - 1
        elif aIndex < 0:
            index = 0
        else:
            index = aIndex
        self.crossLineIndex = index
        if self.infoFunc == None:
            self._showInfo(index)
        else:
            self.infoFunc(self.minTimeList[index])

        groupStr = self.instGroup + "cross_line"
        self.canvas.remove_group(groupStr)

        instg = InstructionGroup(group=groupStr)

        color = Color()
        color.rgba = self.CROSS_LINE_COLOR
        instg.add(color)
        x1 = self.start_xaxis + index * self.xscale
        y1 = self.volume_yaxis
        x2 = self.start_xaxis + index * self.xscale
        y2 = self.volume_yaxis + self.crossLine_height
        instg.add(Line(points=(x1, y1, x2, y2), width=1))
        self.canvas.add(instg)
예제 #7
0
    def add_children_container(
            self, container, drag_classes, cls, color, drag_append_end=False):
        """Gets a StageChildrenList that is added to containter.
        """
        app = _get_app()
        with KvContext():
            with cls(parent=container) as widget:
                widget.spacing = '5dp'
                widget.size_hint_y = None
                widget.orientation = 'vertical'
                widget.spacer_props = {
                    'size_hint_y': None, 'height': '40dp',
                    'size_hint_min_x': '40dp'}
                widget.drag_classes = drag_classes
                widget.drag_target_stage = self.stage
                widget.drag_append_end = drag_append_end

                widget.height @= widget.minimum_height
                widget.size_hint_min_x @= widget.minimum_width
                widget.padding @= '5dp', 0, 0, (
                    0 if widget.children and not (
                        app.drag_controller.dragging and
                        app.drag_controller.widget_dragged and
                        app.drag_controller.widget_dragged.drag_cls in
                        drag_classes)
                    else '12dp')
                widget.is_visible @= self.show_more and self.is_visible
                widget.stage_widget = self

                with widget.canvas:
                    color_back = Color()
                    color_back.rgba = 152 / 255., 153 / 255., 155 / 255., 1.

                    rect_back = Rectangle()
                    rect_back.pos ^= widget.x + dp(5), widget.y
                    rect_back.size ^= widget.width - dp(5), dp(10) if (
                        app.drag_controller.dragging and
                        app.drag_controller.widget_dragged and
                        app.drag_controller.widget_dragged.drag_cls in
                        drag_classes) else 0

                    color_inst = Color()
                    color_inst.rgba = color
                    rect = Rectangle()
                    rect.pos ^= widget.x + dp(1), widget.y
                    rect.size ^= dp(2), widget.height
        return widget
예제 #8
0
    def drawCrossLine(self, aIndex):
        """
        """
        dataNum = len(self.dataDict)
        if dataNum == 0:
            return
        if aIndex >= self.dispMax:
            index = self.dispMax - 1
        elif aIndex >= self.dispNum:
            index = self.dispNum - 1
        elif aIndex < 0:
            index = 0
        else:
            index = aIndex
        self.crossLineIndex = index
        if self.infoFunc == None:
            self._showInfo(index)
        else:
            aKey = self.keyList[self.scopeIdx[0] + index]
            aDict = self.dataDict.get(aKey)
            refDict = {}
            for aKey in aDict.keys():
                refDict[aKey] = aDict.get(aKey)
            refDict["TechType"] = self.techType
            self.infoFunc(refDict)

        if self.isDrawCrossLine == False:
            return
        groupStr = self.instGroup + "cross_line"
        self.canvas.remove_group(groupStr)

        color = Color()
        color.rgba = self.CROSS_LINE_COLOR

        instg = InstructionGroup(group=groupStr)
        instg.add(color)
        x1 = self.chartPos[0] + (index + 1) * (self.tickWide +
                                               self.tickGap) - self.backGap
        y1 = self.chartPos[1]
        x2 = x1
        y2 = self.chartPos[1] + self.chartSize[1]
        instg.add(Line(points=(x1, y1, x2, y2), width=1))
        self.canvas.add(instg)

        aKey = self.keyList[self.scopeIdx[0] + index]
        aDict = self.dataDict.get(aKey)

        instg = InstructionGroup(group=groupStr)
        instg.add(color)
        x1 = self.chartPos[0]
        y1 = self.chartPos[1] + (aDict.get("VOL") -
                                 self.lowestValue) * self.yscale
        x2 = self.chartPos[0] + self.chartSize[0]
        y2 = y1
        instg.add(Line(points=(x1, y1, x2, y2), width=1))
        self.canvas.add(instg)
예제 #9
0
    def drawVolumeGraph(self, data, curIndex):
        instg = InstructionGroup(group="data")
        volume = data.get("vol")
        color = Color()
        color.rgba = self.VOLUME_COLOR
        instg.add(color)

        x1 = int(self.pos[0] + self.shift_left + curIndex * self.xscale)
        y1 = int(self.pos[1] + self.shift_bottom)
        x2 = int(self.pos[0] + self.shift_left + curIndex * self.xscale)
        y2 = int(self.pos[1] + self.shift_bottom + volume * self.vscale)
        instg.add(Line(points=(x1, y1, x2, y2), width=1))
        self.canvas.add(instg)
예제 #10
0
파일: func_widgets.py 프로젝트: matham/Ceed
    def apply_kv(self):
        FuncWidget.apply_kv(self)
        if self.ref_func:
            return

        app = _get_app()
        with KvContext():
            with GroupFuncList(
                    parent=self, spacing='5dp', size_hint_y=None,
                    orientation='vertical') as more:
                self.more = self.children_container = more
                more.group_widget = self
                more.is_visible @= self.show_more and self.is_visible

                with KvRule(more.children, app.drag_controller.widget_dragged,
                            app.drag_controller.dragging):
                    if more.children and not (
                            app.drag_controller.dragging and
                            app.drag_controller.widget_dragged and
                            app.drag_controller.widget_dragged.drag_cls in
                            ('func', 'func_spinner')):
                        more.padding = '15dp', '5dp', 0, 0
                    else:
                        more.padding = '15dp', '5dp', 0, '12dp'

                more.height @= more.minimum_height
                more.size_hint_min_x @= more.minimum_width

                more.spacer_props = {
                    'size_hint_y': None, 'height': '50dp',
                    'size_hint_min_x': '40dp'}
                more.drag_classes = ['func', 'func_spinner']
                more.controller @= self.func
                with more.canvas:
                    color_back = Color()
                    color_back.rgba = 152 / 255., 153 / 255., 155 / 255., 1.

                    more_rect_back = Rectangle()
                    more_rect_back.pos ^= more.x + dp(15), more.y
                    more_rect_back.size ^= more.width - dp(15), dp(10) if (
                        app.drag_controller.dragging and
                        app.drag_controller.widget_dragged and
                        app.drag_controller.widget_dragged.drag_cls in
                        ('func', 'func_spinner')) else 0

                    color = Color()
                    color.rgba ^= app.theme.divider

                    more_rect = Rectangle()
                    more_rect.pos ^= more.x + dp(11), more.y
                    more_rect.size ^= dp(2), more.height - dp(2)
예제 #11
0
	def add_items(self,number):
		for item in range(0,number):
			rand = randint(1,3)
			t=TutoItem('tuto_assets/texture.png')
			t.l.opacity=0
			t.remove_widget(t.children[0])
			t.size=(256,256)
			t.size_hint=(None,None)
			Animation(pos=(randint(0,Window.width*0.5),randint(0,int(Window.height*0.8))),rotation=randint(0,360),d=0.2).start(t)
			with t.canvas.before:
				c=Color()
				c.rgba=self.colors[str(rand)]
				Rectangle(size=t.size)
			t.item['taille']=rand
			self.add_widget(t)
예제 #12
0
 def _drawVolumeLine(self, aDict, aIdx, isLastFlag):
     groupStr = self.instGroup
     if isLastFlag == True:
         groupStr += "volume_lastData"
     else:
         groupStr += "volume_curvData"
     instg = InstructionGroup(group=groupStr)
     color = Color()
     color.rgba = self.VOLUME_COLOR
     instg.add(color)
     x1 = self.start_xaxis + aIdx * self.xscale
     y1 = self.volume_yaxis
     x2 = x1
     y2 = self.volume_yaxis + aDict.get("Vol") * self.volume_yscale
     instg.add(Line(points=(x1, y1, x2, y2), width=1))
     self.canvas.add(instg)
예제 #13
0
 def _drawLine(self, preValue, aValue, dispIdx, isLastFlag):
     """
     繪製曲線
     """
     groupStr = self.instGroup
     if isLastFlag == True:
         groupStr += "_lastData"
     else:
         groupStr += "_curvData"    
     instg = InstructionGroup(group=groupStr)
     color = Color()
     color.rgba = self.CURV_COLOR
     instg.add(color)
     #(self.tickWide + self.tickGap)代表顯示一筆資料,在x軸方向所需的總點數
     x1 = self.chartPos[0] + dispIdx * (self.tickWide + self.tickGap) - self.backGap
     y1 = self.chartPos[1] + (preValue - self.lowestValue) * self.yscale
     x2 = x1 + (self.tickWide + self.tickGap)
     y2 = self.chartPos[1] + (aValue - self.lowestValue) * self.yscale
     instg.add(Line(points=(x1, y1, x2, y2), width=1))
     self.canvas.add(instg)
예제 #14
0
    def drawCrossLine(self, key):
        if len(self.profitPerNumDict) == 0:
            return
        
        aNum = self.profitPerNumDict.get(key)
        if aNum == None:
            return
        
        keyInt = int(key)
        
        index = keyInt - self.min_tickNum
        if keyInt == 0:
            shift_xpos = self.ycordWidth
        elif keyInt > 0:
            shift_xpos = self.ycordWidth * 2
        else:
            shift_xpos = 0
        
        color = Color()
        color.rgba = self.CROSS_LINE_COLOR

        self.canvas.remove_group("cross_line")
        
        center_pos = int(self.pillarPoint / 2)
        instg = InstructionGroup(group="cross_line")
        instg.add(color)
        x1 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + shift_xpos + center_pos)
        y1 = int(self.pos[1] + self.shift_bottom)
        x2 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + shift_xpos + center_pos)
        y2 = int(self.pos[1] + self.shift_bottom + self.maxNum * self.yscale)
        instg.add(Line(points=(x1, y1, x2, y2), width=1))
        self.canvas.add(instg)
                
        instg = InstructionGroup(group="cross_line")
        instg.add(color)
        x1 = self.pos[0] + self.shift_left
        y1 = int(self.pos[1] + self.shift_bottom + aNum * self.yscale)
        x2 = self.pos[0] + self.width - self.shift_right
        y2 = int(self.pos[1] + self.shift_bottom + aNum * self.yscale)
        instg.add(Line(points=(x1, y1, x2, y2), width=1))        
        self.canvas.add(instg)
예제 #15
0
    def reset_grid(self, rows, cols, box_size):
        """ Reset Grid is called when the board is reset """
        boxes = []
        self.canvas.clear()
        with self.canvas:

            for row in range(rows):
                nrow = []
                for col in range(cols):
                    nc = Color()
                    nc.rgba = self.offcolor
                    x = col * box_size[0] + self.x
                    y = row * box_size[1] + self.y
                    nsquare = CGoL_Box(size=box_size,
                                       pos=(x, y),
                                       color=nc,
                                       oncolor=self.oncolor,
                                       offcolor=self.offcolor)
                    nrow.append(nsquare)
                boxes.append(nrow)
        return boxes
예제 #16
0
 def _drawPriceLine(self, preDict, aDict, aIdx, isLastFlag):
     groupStr = self.instGroup
     if isLastFlag == True:
         groupStr += "price_lastData"
     else:
         groupStr += "price_curvData"
     instg = InstructionGroup(group=groupStr)
     color = Color()
     color.rgba = self._getPriceColor(preDict.get("CloseP"),
                                      aDict.get("CloseP"))
     instg.add(color)
     if aIdx == 0:
         x1 = self.start_xaxis
     else:
         x1 = self.start_xaxis + (aIdx - 1) * self.xscale
     y1 = self.price_yaxis + (preDict.get("CloseP") -
                              self.lowestPrice) * self.price_yscale
     x2 = self.start_xaxis + aIdx * self.xscale
     y2 = self.price_yaxis + (aDict.get("CloseP") -
                              self.lowestPrice) * self.price_yscale
     instg.add(Line(points=(x1, y1, x2, y2), width=1))
     self.canvas.add(instg)
예제 #17
0
    def _drawLine(self, aDict, dispIdx, isLastFlag):
        """
        
        """
        groupStr = self.instGroup
        if isLastFlag == True:
            groupStr += "_lastData"
        else:
            groupStr += "_curvData"
        instg = InstructionGroup(group=groupStr)
        color = Color()
        color.rgba = self.KLINE_COLOR
        instg.add(color)
        #(self.tickWide + self.tickGap)代表顯示一筆資料,在x軸方向所需的總點數
        x1 = self.chartPos[0] + (dispIdx + 1) * (self.tickWide +
                                                 self.tickGap) - self.backGap
        y1 = self.chartPos[1] + (aDict.get("HP") -
                                 self.lowestValue) * self.yscale
        x2 = x1
        y2 = self.chartPos[1] + (aDict.get("LP") -
                                 self.lowestValue) * self.yscale
        instg.add(Line(points=(x1, y1, x2, y2), width=1))
        self.canvas.add(instg)

        instg = InstructionGroup(group=groupStr)
        color = Color()

        openPrice = aDict.get("OP")
        closePrice = aDict.get("CP")
        if closePrice > openPrice:
            color.rgba = self.SOLID_COLOR
            instg.add(color)
            x1 = self.chartPos[0] + dispIdx * (self.tickWide +
                                               self.tickGap) + self.tickGap
            y1 = self.chartPos[1] + (openPrice -
                                     self.lowestValue) * self.yscale
            instg.add(
                Rectangle(pos=(x1, y1),
                          size=(self.tickWide,
                                (closePrice - openPrice) * self.yscale)))
        elif closePrice < openPrice:
            color.rgba = self.VIRTUAL_COLOR
            instg.add(color)
            x1 = self.chartPos[0] + dispIdx * (self.tickWide +
                                               self.tickGap) + self.tickGap
            y1 = self.chartPos[1] + (closePrice -
                                     self.lowestValue) * self.yscale
            instg.add(
                Rectangle(pos=(x1, y1),
                          size=(self.tickWide,
                                (openPrice - closePrice) * self.yscale)))
        else:
            color.rgba = self.KLINE_COLOR
            instg.add(color)
            x1 = self.chartPos[0] + dispIdx * (self.tickWide +
                                               self.tickGap) + self.tickGap
            y1 = self.chartPos[1] + (closePrice -
                                     self.lowestValue) * self.yscale
            x2 = self.chartPos[0] + (dispIdx + 1) * (self.tickWide +
                                                     self.tickGap)
            y2 = y1
            instg.add(Line(points=(x1, y1, x2, y2), width=1))

        self.canvas.add(instg)
예제 #18
0
    def charting(self, *args):
        """
        繪圖
        """
        self.canvas.clear()

        if self.dataList == None or len(self.dataList) == 0:
            self.drawNoDataGraph()
            return

        self.calcMaxTick()
        self.drawCordFrame()
        
        self.profitPerNumDict.clear()
        self.maxNum = 5
        tmpProfitPer = None
        aNum = None
        for profitPer in self.dataList:
            if profitPer < 0:
                tmpProfitPer = math.floor(profitPer)
                if tmpProfitPer < self.min_tickNum:
                    tmpProfitPer = self.min_tickNum
            else:
                tmpProfitPer = math.ceil(profitPer)
                if tmpProfitPer > self.max_tickNum:
                    tmpProfitPer = self.max_tickNum
                
            tmpProfitPer = int(tmpProfitPer)
            aNum = self.profitPerNumDict.get(str(tmpProfitPer))
            if aNum == None:
                aNum = 0
            aNum += 1
            self.profitPerNumDict[str(tmpProfitPer)] = aNum
            if aNum > self.maxNum:
                self.maxNum = aNum

        self.yscale = (self.height - self.shift_bottom - self.shift_top) / self.maxNum
        
        self.drawCordInfo()
        
        index = None
        shift_xpos = None
        center_pos = int(self.pillarPoint / 2)
        for i in range(self.min_tickNum, self.max_tickNum + 1):
            if i == 0:
                shift_xpos = self.ycordWidth
            elif i > 0:
                shift_xpos = self.ycordWidth * 2
            else:
                shift_xpos = 0
            index = i - self.min_tickNum
            aNum = self.profitPerNumDict.get(str(i))
            if aNum != None:
                lineColor = Color()
                lineColor.rgba = self.GRID_COLOR                
                
                instg = InstructionGroup(group="data")
                instg.add(lineColor)
                
                x1 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + shift_xpos)
                y1 = int(self.pos[1] + self.shift_bottom)
                x2 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + shift_xpos)
                y2 = int(self.pos[1] + self.shift_bottom + aNum * self.yscale)
                instg.add(Line(points=(x1, y1, x2, y2), width=1))
                self.canvas.add(instg)
                
                instg = InstructionGroup(group="data")
                instg.add(lineColor)
                
                x1 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + shift_xpos)
                y1 = int(self.pos[1] + self.shift_bottom + aNum * self.yscale)
                x2 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + self.pillarPoint - 1 + shift_xpos)
                y2 = int(self.pos[1] + self.shift_bottom + aNum * self.yscale)
                instg.add(Line(points=(x1, y1, x2, y2), width=1))
                self.canvas.add(instg)
                
                instg = InstructionGroup(group="data")
                instg.add(lineColor)
                
                x1 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + self.pillarPoint - 1 + shift_xpos)
                y1 = int(self.pos[1] + self.shift_bottom)
                x2 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + self.pillarPoint - 1 + shift_xpos)
                y2 = int(self.pos[1] + self.shift_bottom + aNum * self.yscale)
                instg.add(Line(points=(x1, y1, x2, y2), width=1))
                self.canvas.add(instg)

            x1 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + shift_xpos + center_pos)
            self.xcordDict[str(i)] = x1
예제 #19
0
    def drawFrameGrid(self):

        # Start-01: 產生一繪製外框,線條及座標之物件
        rectParamDict = {}
        rectParamDict["canvas"] = self.canvas
        rectParamDict[
            "width"] = self.width - self.shift_left - self.shift_right
        rectParamDict[
            "height"] = self.height - self.shift_bottom - self.shift_top
        rectParamDict["x_start_pos"] = self.pos[0] + self.shift_left
        rectParamDict["y_start_pos"] = self.pos[1] + self.shift_bottom
        rectParamDict["rectColor"] = self.FRAME_COLOR
        rectParamDict["rectWidth"] = 1
        rectParamDict["gridColor"] = self.GRID_COLOR
        rectParamDict["gridWidth"] = 1
        rectParamDict["instGroup"] = "StrendGraph"
        smintimeChartUtil = SMinTimeCordUtil(rectParamDict)
        # End-01.

        smintimeChartUtil.drawRectGrid()  #繪製一矩形框

        gridColor = Color()
        gridColor.rgba = self.GRID_COLOR
        tmpNum = self.xgrid_num
        while (tmpNum < self.max_tickNum):
            instg = InstructionGroup(group="grid")
            x1 = int(self.pos[0] + self.shift_left + tmpNum * self.xscale)
            y1 = self.pos[1] + self.shift_bottom
            x2 = int(self.pos[0] + self.shift_left + tmpNum * self.xscale)
            y2 = self.pos[1] + self.height - self.shift_top
            instg.add(gridColor)
            instg.add(Line(points=(x1, y1, x2, y2), width=1))
            self.canvas.add(instg)
            tmpNum += self.xgrid_num

        pscale = (self.max_price - self.min_price) / 4.0
        for i in range(0, 5):
            y1 = int(self.pos[1] + self.shift_bottom +
                     (i * pscale * self.yscale))
            y2 = int(self.pos[1] + self.shift_bottom +
                     (i * pscale * self.yscale))
            if i != 0 and i != 4:
                instg = InstructionGroup(group="grid")
                x1 = self.pos[0] + self.shift_left
                x2 = self.pos[0] + self.width - self.shift_right
                instg.add(gridColor)
                instg.add(Line(points=(x1, y1, x2, y2), width=1))
                self.canvas.add(instg)

            cordPrice = i * pscale + self.min_price
            cordPriceStr = "{:7.2f}".format(cordPrice)
            x0 = self.pos[0] + 2
            #y0 = y1 - 8
            y0 = y1
            alabel = SCordLabel(text=cordPriceStr,
                                pos=(x0, y0),
                                size_hint=(None, None))
            alabel.width = self.shift_left - 2
            alabel.height = 16
            alabel.halign = "right"
            alabel.color = self.CORD_INFO_COLOR
            self.add_widget(alabel)

        smintimeChartUtil = None
예제 #20
0
 def drawCordInfo(self):
     
     # 100-Start: 標示y軸資訊 
     
     initStepUp = 1
     if self.maxNum < 8:
         initStepUp = 1
     elif self.maxNum < 10:
         initStepUp = 2
     else:
         initStepUp = int(self.maxNum / 5)
     
     x0 = self.pos[0] + ((self.width - self.shift_left - self.shift_right) / 2) + self.shift_left - 30
     y0 = self.pos[1] + self.height - self.shift_top + 5           
     alabel = SCordLabel(pos=(x0,y0),size_hint=(None,None))
     alabel.width = 60
     alabel.height = 20        
     alabel.text = "(X軸:獲利率,Y軸:交易次數)"
     alabel.color = self.CORD_INFO_COLOR
     self.add_widget(alabel)
         
     frameColor = Color()
     frameColor.rgba = self.FRAME_COLOR
     stepUp = initStepUp
     while(stepUp <= self.maxNum):
         instg = InstructionGroup(group="frame")            
         instg.add(frameColor)            
         x1 = self.center_xpos - 5
         y1 = int(self.pos[1] + self.shift_bottom + stepUp * self.yscale)
         x2 = self.center_xpos
         y2 = int(self.pos[1] + self.shift_bottom + stepUp * self.yscale)
         instg.add(Line(points=(x1, y1, x2, y2), width=1))        
         self.canvas.add(instg)
         
         x0 = self.center_xpos - self.ycordWidth
         y0 = int(self.pos[1] + self.shift_bottom + stepUp * self.yscale) - 10
         alabel = SCordLabel(pos=(x0,y0),size_hint=(None,None))
         alabel.width = 36
         alabel.height = 20
         alabel.text = str(stepUp)
         alabel.color = self.CORD_INFO_COLOR
         self.add_widget(alabel)
         stepUp += initStepUp
     # 100-End.
     
     # 200-Start: 標示x軸資訊 
     center_pos = int(self.pillarPoint / 2)
     remainder = None
     for i in range(self.min_tickNum, self.max_tickNum + 1):
         remainder = i % 10
         if remainder != 0 and i != -1 and i != 0 and i != 1 and i != self.min_tickNum and i != self.max_tickNum:
             continue
         index = i - self.min_tickNum
         if i >= 0:
             tmp = self.max_tickNum - i
             if tmp <= 8 and i != self.max_tickNum:
                 continue
             if i == 0:
                 shift_xpos = self.ycordWidth
             else:
                 shift_xpos = self.ycordWidth * 2
         else:
             if index <= 8 and i != self.min_tickNum:
                 continue
             shift_xpos = 0            
         instg = InstructionGroup(group="frame")            
         instg.add(frameColor)            
         x1 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + center_pos + shift_xpos)
         y1 = int(self.pos[1] + self.shift_bottom)
         x2 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + center_pos + shift_xpos)
         y2 = int(self.pos[1] + self.shift_bottom - 5)
         instg.add(Line(points=(x1, y1, x2, y2), width=1))        
         self.canvas.add(instg)
         
         x0 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + center_pos + shift_xpos - 18)
         y0 = int(self.pos[1] + self.shift_bottom) - 25
         alabel = SCordLabel(pos=(x0,y0),size_hint=(None,None))
         alabel.width = 36
         alabel.height = 20
         if i == self.min_tickNum:
             alabel.text = "<=" + str(i) + "%"
         elif i == self.max_tickNum:
             alabel.text = ">=" + str(i) + "%"
         else:
             alabel.text = str(i) + "%"
         alabel.color = self.CORD_INFO_COLOR
         self.add_widget(alabel)