NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

graphsutil.py (1614B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\graphs\graphsutil.py
      2 import math
      3 
      4 def MovingOp(values, op, n):
      5     returnValues = []
      6     for i in xrange(len(values)):
      7         start = max(i - n, 0)
      8         end = i + 1
      9         v = op(values[start:end])
     10         returnValues.append(v)
     11 
     12     return returnValues
     13 
     14 
     15 def MovingHigh(values, n = 5):
     16     return MovingOp(values, max, n)
     17 
     18 
     19 def MovingLow(values, n = 5):
     20     return MovingOp(values, min, n)
     21 
     22 
     23 def MovingAvg(values, n = 5):
     24     return MovingOp(values, lambda l: sum(l) / len(l), n)
     25 
     26 
     27 def AdjustMaxValue(height, maxValue, minGridLineHeight):
     28     magnitude = math.trunc(math.log10(maxValue))
     29     magnitudeValue = pow(10, magnitude)
     30     dividerValues = [25.0,
     31      10.0,
     32      5.0,
     33      4.0,
     34      2.0,
     35      1.0]
     36     for divider in dividerValues:
     37         adjustedMaxValue = math.floor(maxValue / magnitudeValue) * magnitudeValue
     38         numGridLines = int(math.floor(maxValue / magnitudeValue) * divider)
     39         while adjustedMaxValue < maxValue:
     40             adjustedMaxValue += magnitudeValue / divider
     41             numGridLines += 1
     42 
     43         gridLineHeight = int(height / numGridLines)
     44         if gridLineHeight > minGridLineHeight:
     45             break
     46 
     47     return (adjustedMaxValue, numGridLines)
     48 
     49 
     50 def GetGraphY(y, minimum, maximum, height):
     51     return height * (1.0 - (y - minimum) / (maximum - minimum))
     52 
     53 
     54 def GetGraphX(index, width, zoom):
     55     return (index + 0.5) * float(width + 1) / zoom
     56 
     57 
     58 def GetGraphVolume(volume, minVol, maxVol):
     59     relative = (volume - minVol) / (maxVol - minVol)
     60     return 100 * relative