Beispiel #1
0
    def __init__(self):
        GChart.__init__(self, XChartSize=300, YChartSize=450)
        self.setChartTitle("<h2>2<sup>x</sup> vs x</h2>")
        self.addCurve()
        self.getCurve().getSymbol().setHovertextTemplate(
            formatAsHovertext("${y}=2^${x}"))
        self.getCurve().setLegendLabel("<b>2<sup>x</sup></b>")
        self.getCurve().getSymbol().setBackgroundColor("red")
        self.getCurve().getSymbol().setBorderColor("black")
        self.getCurve().getSymbol().setWidth(9)
        self.getCurve().getSymbol().setHeight(9)

        # add (log10-transformed) powers of 2 from 1/4 to 8
        for i in range(-2, 4):
            self.getCurve().addPoint(i, log10(math.pow(2, i)))

        # GChart's "=10^" NumberFormat prefix inverts the log10
        # transform
        self.getYAxis().setTickLabelFormat("=10^#.##")
        # add conventional log-scaled ticks from .1 to 10
        self.getYAxis().addTick(log10(0.1))
        x = 0.1
        while x < 10:
            for y in range(2, 11):
                self.getYAxis().addTick(log10(x * y))
            x *= 10

        self.getXAxis().setAxisLabel("<b>x</b>")
        self.getXAxis().setHasGridlines(True)
        self.getXAxis().setTickCount(6)

        self.getYAxis().setAxisLabel("<b>2<sup>x</sup></b>")
        self.getYAxis().setHasGridlines(True)
Beispiel #2
0
    def __init__(self):
        GChart.__init__(self)

        self.setChartTitle(
        "Click on chart, then use left/right arrows to switch selected point")
        self.setHoverTouchingEnabled(True)
        self.setChartSize(500, 150)
        self.setPadding("10px")
        self.getXAxis().setTickCount(11)
        self.getYAxis().setTickCount(11)
        self.addCurve()
        for i in range(N_POINTS+1):
            self.getCurve().addPoint(i, math.sin((2* math.pi * i)/N_POINTS))

        self.getCurve().getSymbol().setWidth(5)
        self.getCurve().getSymbol().setBorderColor(BLUE)
        self.getCurve().getSymbol().setBackgroundColor(SKY_BLUE)
        self.getCurve().getSymbol().setHoverSelectionBackgroundColor(BLUE)
        self.getCurve().getSymbol().setHoverSelectionBorderColor(SKY_BLUE)
        self.getCurve().getSymbol().setSymbolType(
                                SymbolType.VBAR_BASELINE_CENTER)
        self.getCurve().getSymbol().setHoverLocation(
                                AnnotationLocation.NORTH)
        self.getCurve().getSymbol().setHoverYShift(5)
        self.setPixelSize(self.getXChartSizeDecorated(),
                            self.getYChartSizeDecorated())
Beispiel #3
0
    def __init__(self):
        GChart.__init__(self)
        self.setChartSize(300, 300)
        self.setBorderStyle("none")
        """
        * So selection changing requires the user to click
        * (not just mouseover a point). This allows the
        * selection to stay put while user moves to click the
        * y-changing buttons.
        *
        """
        self.setHoverTouchingEnabled(False)
        self.addCurve()
        # make a y-changer pop up when they click a point
        self.getCurve().getSymbol().setHoverWidget(YChanger(self))
        # Configure hover annotation so it appears below chart
        self.getCurve().getSymbol().setHoverAnnotationSymbolType(
                                    SymbolType.ANCHOR_SOUTH)
        self.getCurve().getSymbol().setHoverLocation(AnnotationLocation.SOUTH)
        self.getCurve().getSymbol().setHoverYShift(-30)
        # 3px, external point selection border
        self.getCurve().getSymbol().setHoverSelectionBorderWidth(-3)

        # configure curve as a baseline-based bar chart
        self.getCurve().getSymbol().setSymbolType(SymbolType.VBAR_BASELINE_EAST)
        self.getCurve().getSymbol().setModelWidth(1)
        self.getCurve().getSymbol().setBorderWidth(1)
        self.getCurve().getSymbol().setBorderColor("black")
        self.getCurve().getSymbol().setBackgroundColor("blue")
        # add a simple y = 2*x curve
        for iPoint in range(10):
            self.getCurve().addPoint(iPoint, 2*iPoint)
Beispiel #4
0
    def __init__(self):
        GChart.__init__(self, XChartSize=300, YChartSize=450)
        self.setChartTitle("<h2>2<sup>x</sup> vs x</h2>")
        self.addCurve()
        self.getCurve().getSymbol().setHovertextTemplate(
                        formatAsHovertext("${y}=2^${x}"))
        self.getCurve().setLegendLabel("<b>2<sup>x</sup></b>")
        self.getCurve().getSymbol().setBackgroundColor("red")
        self.getCurve().getSymbol().setBorderColor("black")
        self.getCurve().getSymbol().setWidth(9)
        self.getCurve().getSymbol().setHeight(9)

        # add (log10-transformed) powers of 2 from 1/4 to 8
        for i in range(-2, 4):
            self.getCurve().addPoint(i,log10(math.pow(2,i)))

        # GChart's "=10^" NumberFormat prefix inverts the log10
        # transform
        self.getYAxis().setTickLabelFormat("=10^#.##")
        # add conventional log-scaled ticks from .1 to 10
        self.getYAxis().addTick(log10(0.1))
        x = 0.1
        while x < 10:
            for y in range(2, 11):
                self.getYAxis().addTick(log10(x*y))
            x *= 10

        self.getXAxis().setAxisLabel("<b>x</b>")
        self.getXAxis().setHasGridlines(True)
        self.getXAxis().setTickCount(6)

        self.getYAxis().setAxisLabel("<b>2<sup>x</sup></b>")
        self.getYAxis().setHasGridlines(True)
Beispiel #5
0
    def __init__(self):
        GChart.__init__(self)
        self.setChartSize(300, 300)
        self.setBorderStyle("none")
        """
        * So selection changing requires the user to click
        * (not just mouseover a point). This allows the
        * selection to stay put while user moves to click the
        * y-changing buttons.
        *
        """
        self.setHoverTouchingEnabled(False)
        self.addCurve()
        # make a y-changer pop up when they click a point
        self.getCurve().getSymbol().setHoverWidget(YChanger(self))
        # Configure hover annotation so it appears below chart
        self.getCurve().getSymbol().setHoverAnnotationSymbolType(
            SymbolType.ANCHOR_SOUTH)
        self.getCurve().getSymbol().setHoverLocation(AnnotationLocation.SOUTH)
        self.getCurve().getSymbol().setHoverYShift(-30)
        # 3px, external point selection border
        self.getCurve().getSymbol().setHoverSelectionBorderWidth(-3)

        # configure curve as a baseline-based bar chart
        self.getCurve().getSymbol().setSymbolType(
            SymbolType.VBAR_BASELINE_EAST)
        self.getCurve().getSymbol().setModelWidth(1)
        self.getCurve().getSymbol().setBorderWidth(1)
        self.getCurve().getSymbol().setBorderColor("black")
        self.getCurve().getSymbol().setBackgroundColor("blue")
        # add a simple y = 2*x curve
        for iPoint in range(10):
            self.getCurve().addPoint(iPoint, 2 * iPoint)
Beispiel #6
0
    def __init__(self):
        GChart.__init__(self)

        self.SELECTION_CURVE = 0 # curve index of selection cursor
        self.p1 = Point(); # first corner (@mousedown) of selection rect
        self.p2 = Point(); # second corner (@mouseup) of selection rect
        self.selecting = False
        self.moving = False
        self.ctrlPressed = False; # as evaluated at mouse down
        self.altPressed = False
        # (# zoom ins) - (# zoom outs) since selection rect created
        # lets us know when to restore initial plot area limits/cursor
        self.zoomIndex = 0
        self.zoomController = ZoomController(self)
        # min plot area fraction zoom selection cursor must capture
        
        self.initialPlotRegion = Region()
        self.initialSelectionRegion = Region()
    
        self.setChartTitle(
        "Drag to pan; Press Ctrl while drag-selecting a rectangle to zoom")
        self.setChartSize(500, 150)
        a = Hyperlink("huh?")
        a.setPixelSize(10, 500)
        self.getYAxis().setAxisLabel(a)
        # another option is to use clipToDecoratedChart(True) instead.
        self.setClipToPlotArea(True)
        self.addCurve()
        for i in range(N_POINTS):
            self.getCurve().addPoint(i, math.sin((2* math.pi * i)/N_POINTS)*
                        math.sin(10*(2* math.pi * i)/N_POINTS))
        
        self.getCurve().getSymbol().setSymbolType(SymbolType.LINE)
        
        # will use this curve to create the selection cursor
        self.addCurve()
        self.getCurve().addPoint(-Double.MAX_VALUE, -Double.MAX_VALUE)
        self.getCurve().setVisible(False)
        # preferentially selects cursor over ordinary curves:
        self.getCurve().getSymbol().setDistanceMetric(0,0)
        self.getCurve().getSymbol().setHoverWidget(self.zoomController)
        self.getCurve().getSymbol().setHoverLocation( AnnotationLocation.CENTER)
        # hides hover-buttons when mouse is outside zoom-cursor
        self.getCurve().getSymbol().setBrushSize(0, 0)
        self.SELECTION_CURVE = self.getNCurves()-1
        # give them some x-panning space
        self.getXAxis().setAxisMin(0.25*N_POINTS)
        self.getXAxis().setAxisMax(0.75*N_POINTS)
        
        self.getYAxis().setTickLabelThickness(50)
        self.getYAxis().setAxisMin(-0.5)
        self.getYAxis().setAxisMax(0.5)
        
        """
        self.addClickListener(self)
        """
        self.addMouseListener(self)
Beispiel #7
0
 def __init__(self):
     GChart.__init__(self)
     self.setChartTitle("<b>x<sup>2</sup> vs x</b>")
     self.setChartSize(150, 150)
     self.addCurve()
     for i in range(10):
         self.getCurve().addPoint(i, i * i)
     self.getCurve().setLegendLabel("x<sup>2</sup>")
     self.getXAxis().setAxisLabel("x")
     self.getYAxis().setAxisLabel("x<sup>2</sup>")
Beispiel #8
0
 def __init__(self):
     GChart.__init__(self)
     self.setChartTitle("<b>x<sup>2</sup> vs x</b>")
     self.setChartSize(150, 150)
     self.addCurve()
     for i in range(10):
         self.getCurve().addPoint(i,i*i)
     self.getCurve().setLegendLabel("x<sup>2</sup>")
     self.getXAxis().setAxisLabel("x")
     self.getYAxis().setAxisLabel("x<sup>2</sup>")
Beispiel #9
0
    def __init__(self):
        GChart.__init__(self)

        self.updateButton = Button(
            "<b><big>Generate New Simulated Revenues</big></b>")

        self.setChartSize(WIDTH, HEIGHT)
        self.setChartTitle("<b><big><big>" + "Simulated Quarterly Revenues" +
                           "</big></big><br>&nbsp;</b>")
        self.updateButton.addClickListener(self)
        self.setChartFootnotes(self.updateButton)

        for iCurve in range(len(barLabels)):
            self.addCurve()  # one curve per quarter
            self.getCurve().getSymbol().setSymbolType(
                SymbolType.VBAR_SOUTHWEST)
            self.getCurve().getSymbol().setBackgroundColor(barColors[iCurve])
            self.getCurve().setLegendLabel(barLabels[iCurve])
            self.getCurve().getSymbol().setHovertextTemplate(
                formatAsHovertext(barLabels[iCurve] + " revenue=${y}"))
            self.getCurve().getSymbol().setModelWidth(1.0)
            self.getCurve().getSymbol().setBorderColor("black")
            self.getCurve().getSymbol().setBorderWidth(1)
            for jGroup in range(len(groupLabels)):
                # the '+1' creates a bar-sized gap between groups
                y = rnd() * MAX_REVENUE
                print "x, y", 1 + iCurve + jGroup * (len(barLabels) + 1), y
                self.getCurve().addPoint(
                    1 + iCurve + jGroup * (len(barLabels) + 1), y)
                self.getCurve().getPoint().setAnnotationText(barLabels[iCurve])
                self.getCurve().getPoint().setAnnotationLocation(
                    AnnotationLocation.NORTH)

        for i in range(len(groupLabels)):
            # formula centers tick-label horizontally on each group
            self.getXAxis().addTick(
                len(barLabels) / 2. + i * (len(barLabels) + 1), groupLabels[i])

        self.getXAxis().setTickLabelFontSize(20.0)
        self.getXAxis().setTickLabelThickness(40.0)
        self.getXAxis().setTickLength(6.0)
        # small tick-like gap...
        self.getXAxis().setTickThickness(0)
        # but with invisible ticks
        self.getXAxis().setAxisMin(0)
        # keeps first bar on chart

        self.getYAxis().setAxisMin(0)
        # Based on sim revenue range
        self.getYAxis().setAxisMax(MAX_REVENUE)
        # of 0 to MAX_REVENUE.
        self.getYAxis().setTickCount(11)
        self.getYAxis().setHasGridlines(True)
        self.getYAxis().setTickLabelFormat("$#,###")
Beispiel #10
0
 def __init__(self):
     GChart.__init__(self)
     self.setChartTitle("<b>x<sup>2</sup> vs x</b>")
     self.setChartSize(150, 150)
     self.addCurve()
     self.getCurve().getSymbol().setFillThickness(2)
     self.getCurve().getSymbol().setFillSpacing(5)
     for i in range(10):
         self.getCurve().addPoint(i,i*i)
     self.getCurve().setLegendLabel("x<sup>2</sup>")
     self.getXAxis().setAxisLabel("x")
     self.getYAxis().setAxisLabel("x<sup>2</sup>")
Beispiel #11
0
    def __init__(self):
        GChart.__init__(self)


        self.updateButton = Button("<b><big>Generate New Simulated Revenues</big></b>")

        self.setChartSize(WIDTH, HEIGHT)
        self.setChartTitle("<b><big><big>" +
                    "Simulated Quarterly Revenues" +
                    "</big></big><br>&nbsp;</b>")
        self.updateButton.addClickListener(self)
        self.setChartFootnotes(self.updateButton)

        for iCurve in range(len(barLabels)):
            self.addCurve()     # one curve per quarter
            self.getCurve().getSymbol().setSymbolType(SymbolType.VBAR_SOUTHWEST)
            self.getCurve().getSymbol().setBackgroundColor(barColors[iCurve])
            self.getCurve().setLegendLabel(barLabels[iCurve])
            self.getCurve().getSymbol().setHovertextTemplate(
                formatAsHovertext(barLabels[iCurve] + " revenue=${y}"))
            self.getCurve().getSymbol().setModelWidth(1.0)
            self.getCurve().getSymbol().setBorderColor("black")
            self.getCurve().getSymbol().setBorderWidth(1)
            for jGroup in range(len(groupLabels)):
                # the '+1' creates a bar-sized gap between groups
                y = rnd()*MAX_REVENUE
                print "x, y", 1+iCurve+jGroup*(len(barLabels)+1), y
                self.getCurve().addPoint(1+iCurve+jGroup*(len(barLabels)+1), y)
                self.getCurve().getPoint().setAnnotationText(barLabels[iCurve])
                self.getCurve().getPoint().setAnnotationLocation(
                                    AnnotationLocation.NORTH)



        for i in range(len(groupLabels)):
            # formula centers tick-label horizontally on each group
            self.getXAxis().addTick(
                        len(barLabels)/2. + i*(len(barLabels)+1),
                        groupLabels[i])

        self.getXAxis().setTickLabelFontSize(20.0)
        self.getXAxis().setTickLabelThickness(40.0)
        self.getXAxis().setTickLength(6.0);    # small tick-like gap...
        self.getXAxis().setTickThickness(0); # but with invisible ticks
        self.getXAxis().setAxisMin(0);       # keeps first bar on chart

        self.getYAxis().setAxisMin(0);           # Based on sim revenue range
        self.getYAxis().setAxisMax(MAX_REVENUE); # of 0 to MAX_REVENUE.
        self.getYAxis().setTickCount(11)
        self.getYAxis().setHasGridlines(True)
        self.getYAxis().setTickLabelFormat("$#,###")
Beispiel #12
0
    def __init__(self):
        GChart.__init__(self)

        self.setChartSize(200, 200)
        self.setBorderWidth("0px")
        self.setHoverParameterInterpreter(
                            CurveNumberHoverParameterInterpreter())
        template = formatAsHovertext(
                            "Curve #${curveNumber}:<br>x=${x}, y=${y}")
        for iCurve in range(3):
            self.addCurve()
            self.getCurve().getSymbol().setHovertextTemplate(template)
            for iPoint in range(10):
                self.getCurve().addPoint(iPoint, (iCurve+1)*iPoint)
Beispiel #13
0
    def __init__(self):
        GChart.__init__(self)

        self.setChartSize(200, 200)
        self.setBorderWidth("0px")
        self.setHoverParameterInterpreter(
            CurveNumberHoverParameterInterpreter())
        template = formatAsHovertext(
            "Curve #${curveNumber}:<br>x=${x}, y=${y}")
        for iCurve in range(3):
            self.addCurve()
            self.getCurve().getSymbol().setHovertextTemplate(template)
            for iPoint in range(10):
                self.getCurve().addPoint(iPoint, (iCurve + 1) * iPoint)
Beispiel #14
0
    def __init__(self):
        GChart.__init__(self)

        do_axis2 = True

        self.setChartTitle("<h2>10x and x<sup>2</sup></h2>")
        self.setChartSize(300, 300)
        self.addCurve()
        self.getCurve().setLegendLabel("<i>10x</i>")
        self.getCurve().setYAxis(Y_AXIS)
        self.getCurve().getSymbol().setSymbolType(SymbolType.VBAR_SOUTH)
        self.getCurve().getSymbol().setBackgroundColor("#DDF")
        self.getCurve().getSymbol().setBorderColor("red")
        self.getCurve().getSymbol().setBorderWidth(1)
        self.getCurve().getSymbol().setModelWidth(0.5)
        for i in range(10):
            self.getCurve().addPoint(i, i * 10)

        if do_axis2:
            self.addCurve()
            self.getCurve().setLegendLabel("<i>x<sup>2</sup></i>")
            self.getCurve().setYAxis(Y2_AXIS)
            self.getCurve().getSymbol().setSymbolType(SymbolType.BOX_CENTER)
            self.getCurve().getSymbol().setWidth(5)
            self.getCurve().getSymbol().setHeight(5)
            self.getCurve().getSymbol().setBorderWidth(0)
            self.getCurve().getSymbol().setBackgroundColor("navy")
            self.getCurve().getSymbol().setFillThickness(2)
            self.getCurve().getSymbol().setFillSpacing(5)

            for i in range(self.getCurve(0).getNPoints()):
                self.getCurve().addPoint(i, i * i)

        self.getXAxis().setAxisLabel("<i>x</i>")
        self.getXAxis().setHasGridlines(True)
        self.getXAxis().setTickThickness(0)
        # hide tick marks...
        self.getXAxis().setTickLength(3)
        # but leave a small gap
        self.getYAxis().setAxisLabel("<i>10x</i>")
        self.getYAxis().setAxisMax(100)
        self.getYAxis().setAxisMin(0)
        self.getYAxis().setTickLabelFormat("#.#")
        self.getYAxis().setTickCount(11)
        if do_axis2:
            self.getY2Axis().setAxisLabel("<i>x<sup>2</sup></i>")
            self.getY2Axis().setHasGridlines(True)
            # last bar 'sticks out' over right edge, so extend 'grid' right:
            self.getY2Axis().setTickLength(15)
    def __init__(self):
        GChart.__init__(self)

        do_axis2 = True

        self.setChartTitle("<h2>10x and x<sup>2</sup></h2>")
        self.setChartSize(300, 300)
        self.addCurve()
        self.getCurve().setLegendLabel("<i>10x</i>")
        self.getCurve().setYAxis(Y_AXIS)
        self.getCurve().getSymbol().setSymbolType(SymbolType.VBAR_SOUTH)
        self.getCurve().getSymbol().setBackgroundColor("#DDF")
        self.getCurve().getSymbol().setBorderColor("red")
        self.getCurve().getSymbol().setBorderWidth(1)
        self.getCurve().getSymbol().setModelWidth(0.5)
        for i in range(10):
            self.getCurve().addPoint(i,i*10)
        
        if do_axis2:
            self.addCurve()
            self.getCurve().setLegendLabel("<i>x<sup>2</sup></i>")
            self.getCurve().setYAxis(Y2_AXIS)
            self.getCurve().getSymbol().setSymbolType(SymbolType.BOX_CENTER)
            self.getCurve().getSymbol().setWidth(5)
            self.getCurve().getSymbol().setHeight(5)
            self.getCurve().getSymbol().setBorderWidth(0)
            self.getCurve().getSymbol().setBackgroundColor("navy")
            self.getCurve().getSymbol().setFillThickness(2)
            self.getCurve().getSymbol().setFillSpacing(5)
            
            for i in range(self.getCurve(0).getNPoints()):
                self.getCurve().addPoint(i,i*i)
            
        
        self.getXAxis().setAxisLabel("<i>x</i>")
        self.getXAxis().setHasGridlines(True)
        self.getXAxis().setTickThickness(0); # hide tick marks...
        self.getXAxis().setTickLength(3);    # but leave a small gap
        self.getYAxis().setAxisLabel("<i>10x</i>")
        self.getYAxis().setAxisMax(100)
        self.getYAxis().setAxisMin(0)
        self.getYAxis().setTickLabelFormat("#.#")
        self.getYAxis().setTickCount(11)
        if do_axis2:
            self.getY2Axis().setAxisLabel("<i>x<sup>2</sup></i>")
            self.getY2Axis().setHasGridlines(True)
            # last bar 'sticks out' over right edge, so extend 'grid' right:
            self.getY2Axis().setTickLength(15)
 def __init__(self):
     GChart.__init__(self)
     self.setChartTitle("<b>x<sup>2</sup> vs x</b>")
     self.setChartSize(150, 150)
     self.addCurve()
     for i in range(10):
         self.getCurve().addPoint(i,i*i)
     self.getCurve().setLegendLabel("x<sup>2</sup>")
     self.getCurve().getSymbol().setSymbolType(SymbolType.VBAR_SOUTH)
     self.getCurve().getSymbol().setBackgroundColor("red")
     self.getCurve().getSymbol().setBorderColor("black")
     self.getCurve().getSymbol().setModelWidth(1.0)
     self.getXAxis().setAxisLabel("<b>x</b>")
     self.getXAxis().setHasGridlines(True)
     self.getYAxis().setAxisLabel("<b>x<sup>2</sup></b>")
     self.getYAxis().setHasGridlines(True)
Beispiel #17
0
 def __init__(self):
     GChart.__init__(self)
     self.setChartTitle("<b>x<sup>2</sup> vs x</b>")
     self.setChartSize(150, 150)
     self.addCurve()
     for i in range(10):
         self.getCurve().addPoint(i,i*i)
     self.getCurve().setLegendLabel("x<sup>2</sup>")
     self.getCurve().getSymbol().setSymbolType(SymbolType.VBAR_SOUTH)
     self.getCurve().getSymbol().setBackgroundColor("red")
     self.getCurve().getSymbol().setBorderColor("black")
     self.getCurve().getSymbol().setModelWidth(1.0)
     self.getXAxis().setAxisLabel("<b>x</b>")
     self.getXAxis().setHasGridlines(True)
     self.getYAxis().setAxisLabel("<b>x<sup>2</sup></b>")
     self.getYAxis().setHasGridlines(True)
    def __init__(self):
        GChart.__init__(self)
        self.first = True
        self._steps = None
        self._end_step = None
        self._testrun_states = None
        self._timedeltas = None
        self._no_of_runs = None
        DEVICE_GROUP = None # Fixme
        self.remote = DataService()
        self.remote.get_total_no_of_testruns(DEVICE_GROUP, self)
        self.remote.get_event_sequence(self)
        #
        self.backButton = Button("<b><<</b>")
        self.backButton.addClickListener(self.onBack)

        self.forwardButton = Button("<b>>></b>")
        self.forwardButton.addClickListener(self.onForward)
        self.setChartFootnotes("")
    def __init__(self):
        GChart.__init__(self)
        self.first = True
        self._steps = None
        self._end_step = None
        self._testrun_states = None
        self._timedeltas = None
        self._no_of_runs = None
        DEVICE_GROUP = None  # Fixme
        self.remote = DataService()
        self.remote.get_total_no_of_testruns(DEVICE_GROUP, self)
        self.remote.get_event_sequence(self)
        #
        self.backButton = Button("<b><<</b>")
        self.backButton.addClickListener(self.onBack)

        self.forwardButton = Button("<b>>></b>")
        self.forwardButton.addClickListener(self.onForward)
        self.setChartFootnotes("")
Beispiel #20
0
    def __init__(self):
        GChart.__init__(self, XChartSize=400,YChartSize=400) # bit bigger so 29 curve legend fits
        self.setChartTitle(GChartTestAppUtil.getTitle(self))
        self.setChartFootnotes("Check: Rendering consistent with SymbolType on legend.")
        for i in range(len(symbolTypes)):
            self.addCurve()
            self.getCurve(i).addPoint(i, i)
            self.getCurve(i).getSymbol().setSymbolType(symbolTypes[i])
            self.getCurve(i).getSymbol().setHeight(7)
            self.getCurve(i).getSymbol().setWidth(7)
            self.getCurve(i).setLegendLabel("%d %s " % (i, symbolNames[i]))

        self.setLegendFontSize(8)
        self.getXAxis().setTickLabelFontSize(8)
        self.getXAxis().setHasGridlines(True)
        self.getXAxis().setTickCount(len(symbolTypes))
        self.getYAxis().setTickLabelFontSize(8)
        self.getYAxis().setHasGridlines(True)
        self.getYAxis().setTickCount(len(symbolTypes))
Beispiel #21
0
    def __init__(self):
        GChart.__init__(self)
        self.setChartTitle("<b><i>Market Share by Region</i></b>")
        SIZE = 200
        self.setChartSize(SIZE, SIZE)
        region = ["USA", "Canada", "Mexico", "India", "France", "Iceland"]
        # elements in this array must sum to 100.
        percent = [35, 25, 15, 10, 10, 5]
        colors = ["red", "green", "yellow", "fuchsia", "silver", "aqua"]
        sum = 0
        for i in range(len(percent) - 1, -1, -1):
            self.addCurve()
            self.getCurve().getSymbol().setSymbolType(SymbolType.BOX_SOUTHEAST)
            self.getCurve().getSymbol().setModelHeight(percent[i])
            self.getCurve().getSymbol().setBackgroundColor(colors[i])
            self.getCurve().getSymbol().setBorderColor(colors[i])
            self.getCurve().getSymbol().setWidth(SIZE)
            self.getCurve().getSymbol().setHoverAnnotationSymbolType(
                SymbolType.ANCHOR_MOUSE_SNAP_TO_Y)
            self.getCurve().getSymbol().setHoverLocation(
                AnnotationLocation.SOUTHEAST)

            ht = "%s, %d%%" % (region[i], percent[i])
            ht = formatAsHovertext(ht)
            self.getCurve().getSymbol().setHovertextTemplate(ht)
            self.getCurve().setLegendLabel(region[i])
            self.getCurve().addPoint(0, 100 - sum)
            self.getCurve().getPoint().setAnnotationText(region[i])
            self.getCurve().getPoint().setAnnotationFontWeight("bold")
            self.getCurve().getPoint().setAnnotationLocation(
                AnnotationLocation.CENTER)
            sum += percent[i]

        self.getXAxis().setTickCount(0)
        self.getXAxis().setTickThickness(0)
        self.getXAxis().setAxisMin(0)
        self.getXAxis().setAxisMax(SIZE)
        self.getYAxis().setTickCount(0)
        self.getYAxis().setTickThickness(0)
        self.getYAxis().setAxisMin(0)
        self.getYAxis().setAxisMax(100)
Beispiel #22
0
    def __init__(self, imageId, targetArea):
        GChart.__init__(self, XChartSize=500,YChartSize=200)
        self.setChartTitle(GChartTestAppUtil.getTitle(self)+" imageId="+str(imageId)+ " targetArea=" + str(targetArea))

        self.setChartFootnotes(msg[targetArea][imageId])
        self.addCurve()
        if targetArea==0:
            self.setBlankImageURL(imageURL[imageId])

        elif targetArea == 1:
            self.getCurve().getSymbol().setImageURL(imageURL[imageId])

        elif targetArea == 2:
            self.setPlotAreaImageURL(imageURL[imageId])

        if targetArea==0:
            if self.getBlankImageURL() != imageURL[imageId]:
                raise IllegalStateException("getBlankImageURL method failed.")


        elif targetArea == 1:
            if self.getCurve().getSymbol().getImageURL() != imageURL[imageId]:
                raise IllegalStateException("getImageURL method failed.")


        elif targetArea == 2:
            if self.getPlotAreaImageURL() != imageURL[imageId]:
                raise IllegalStateException("getPlotAreaImageURL method failed.");



        self.getCurve().getSymbol().setModelHeight(1)
        self.getCurve().getSymbol().setModelWidth(1)
        self.getCurve().getSymbol().setBorderWidth(0)
        self.getCurve().addPoint(1, 1)
        self.getCurve().addPoint(2, 2)
        self.getCurve().addPoint(3, 3)
        self.getCurve().setLegendLabel("Curve 0")
        # restore default blank image URL for any future tests
        self.update()
        self.setBlankImageURL(GChartConsts.DEFAULT_BLANK_IMAGE_URL)
Beispiel #23
0
    def __init__(self):
        GChart.__init__(self)
        self.setChartTitle("<b><i>Market Share by Region</i></b>")
        SIZE = 200
        self.setChartSize(SIZE, SIZE)
        region = ["USA", "Canada", "Mexico", "India", "France", "Iceland"]
        # elements in this array must sum to 100.
        percent = [35, 25, 15, 10, 10, 5]
        colors = ["red", "green", "yellow", "fuchsia", "silver", "aqua"]
        sum = 0
        for i in range(len(percent)-1, -1, -1):
            self.addCurve()
            self.getCurve().getSymbol().setSymbolType(SymbolType.BOX_SOUTHEAST)
            self.getCurve().getSymbol().setModelHeight(percent[i])
            self.getCurve().getSymbol().setBackgroundColor(colors[i])
            self.getCurve().getSymbol().setBorderColor(colors[i])
            self.getCurve().getSymbol().setWidth(SIZE)
            self.getCurve().getSymbol().setHoverAnnotationSymbolType(
                                        SymbolType.ANCHOR_MOUSE_SNAP_TO_Y)
            self.getCurve().getSymbol().setHoverLocation(
                                        AnnotationLocation.SOUTHEAST)

            ht = "%s, %d%%" % (region[i], percent[i])
            ht = formatAsHovertext(ht)
            self.getCurve().getSymbol().setHovertextTemplate(ht)
            self.getCurve().setLegendLabel(region[i])
            self.getCurve().addPoint(0, 100-sum)
            self.getCurve().getPoint().setAnnotationText(region[i])
            self.getCurve().getPoint().setAnnotationFontWeight("bold")
            self.getCurve().getPoint().setAnnotationLocation(
                                            AnnotationLocation.CENTER)
            sum += percent[i]

        self.getXAxis().setTickCount(0)
        self.getXAxis().setTickThickness(0)
        self.getXAxis().setAxisMin(0)
        self.getXAxis().setAxisMax(SIZE)
        self.getYAxis().setTickCount(0)
        self.getYAxis().setTickThickness(0)
        self.getYAxis().setAxisMin(0)
        self.getYAxis().setAxisMax(100)
Beispiel #24
0
    def __init__(self):
        GChart.__init__(self, XChartSize=400,
                        YChartSize=400)  # bit bigger so 29 curve legend fits
        self.setChartTitle(GChartTestAppUtil.getTitle(self))
        self.setChartFootnotes(
            "Check: Rendering consistent with SymbolType on legend.")
        for i in range(len(symbolTypes)):
            self.addCurve()
            self.getCurve(i).addPoint(i, i)
            self.getCurve(i).getSymbol().setSymbolType(symbolTypes[i])
            self.getCurve(i).getSymbol().setHeight(7)
            self.getCurve(i).getSymbol().setWidth(7)
            self.getCurve(i).setLegendLabel("%d %s " % (i, symbolNames[i]))

        self.setLegendFontSize(8)
        self.getXAxis().setTickLabelFontSize(8)
        self.getXAxis().setHasGridlines(True)
        self.getXAxis().setTickCount(len(symbolTypes))
        self.getYAxis().setTickLabelFontSize(8)
        self.getYAxis().setHasGridlines(True)
        self.getYAxis().setTickCount(len(symbolTypes))
Beispiel #25
0
    def __init__(self, imageId, targetArea):
        GChart.__init__(self, XChartSize=500, YChartSize=200)
        self.setChartTitle(
            GChartTestAppUtil.getTitle(self) + " imageId=" + str(imageId) +
            " targetArea=" + str(targetArea))

        self.setChartFootnotes(msg[targetArea][imageId])
        self.addCurve()
        if targetArea == 0:
            self.setBlankImageURL(imageURL[imageId])

        elif targetArea == 1:
            self.getCurve().getSymbol().setImageURL(imageURL[imageId])

        elif targetArea == 2:
            self.setPlotAreaImageURL(imageURL[imageId])

        if targetArea == 0:
            if self.getBlankImageURL() != imageURL[imageId]:
                raise IllegalStateException("getBlankImageURL method failed.")

        elif targetArea == 1:
            if self.getCurve().getSymbol().getImageURL() != imageURL[imageId]:
                raise IllegalStateException("getImageURL method failed.")

        elif targetArea == 2:
            if self.getPlotAreaImageURL() != imageURL[imageId]:
                raise IllegalStateException(
                    "getPlotAreaImageURL method failed.")

        self.getCurve().getSymbol().setModelHeight(1)
        self.getCurve().getSymbol().setModelWidth(1)
        self.getCurve().getSymbol().setBorderWidth(0)
        self.getCurve().addPoint(1, 1)
        self.getCurve().addPoint(2, 2)
        self.getCurve().addPoint(3, 3)
        self.getCurve().setLegendLabel("Curve 0")
        # restore default blank image URL for any future tests
        self.update()
        self.setBlankImageURL(GChartConsts.DEFAULT_BLANK_IMAGE_URL)
 def __init__(self):
     GChart.__init__(self)
     pieMarketShare = [0.65,0.20,0.10,0.05]
     pieTypes = ["Apple", "Cherry", "Pecan", "Bannana"]
     pieColors = ["green", "red", "maroon", "yellow"]
     
     self.setChartSize(300, 200)
     self.setChartTitle("<h3>2008 Sales by Pie Flavor" +
                         "<br>(Puny Pies, Inc.) </h3>")
     self.setLegendVisible(False)
     self.getXAxis().setAxisVisible(False)
     self.getYAxis().setAxisVisible(False)
     self.getXAxis().setAxisMin(0)
     self.getXAxis().setAxisMax(10)
     self.getXAxis().setTickCount(0)
     self.getYAxis().setAxisMin(0)
     self.getYAxis().setAxisMax(10)
     self.getYAxis().setTickCount(0)
     # this line orients the center of the first slice (apple) due east
     self.setInitialPieSliceOrientation(0.75 - pieMarketShare[0]/2)
     for i in range(len(pieMarketShare)):
         self.addCurve()
         self.getCurve().addPoint(5,5)
         self.getCurve().getSymbol().setSymbolType(
                                 SymbolType.PIE_SLICE_OPTIMAL_SHADING)
         self.getCurve().getSymbol().setBorderColor("white")
         self.getCurve().getSymbol().setBackgroundColor(pieColors[i])
         # next two lines define pie diameter in x-axis model units
         self.getCurve().getSymbol().setModelWidth(6)
         self.getCurve().getSymbol().setHeight(0)
         self.getCurve().getSymbol().setFillSpacing(0)
         self.getCurve().getSymbol().setFillThickness(3)
         self.getCurve().getSymbol().setHovertextTemplate(
                 formatAsHovertext(pieTypes[i] + ", " +
                         "%d%%" % round(100*pieMarketShare[i])))
         self.getCurve().getSymbol().setPieSliceSize(pieMarketShare[i])
         self.getCurve().getPoint().setAnnotationText(pieTypes[i])
         self.getCurve().getPoint().setAnnotationLocation(
                                 AnnotationLocation.OUTSIDE_PIE_ARC)
Beispiel #27
0
    def __init__(self):
        GChart.__init__(self)
        pieMarketShare = [0.65, 0.20, 0.10, 0.05]
        pieTypes = ["Apple", "Cherry", "Pecan", "Bannana"]
        pieColors = ["green", "red", "maroon", "yellow"]

        self.setChartSize(300, 200)
        self.setChartTitle("<h3>2008 Sales by Pie Flavor" +
                           "<br>(Puny Pies, Inc.) </h3>")
        self.setLegendVisible(False)
        self.getXAxis().setAxisVisible(False)
        self.getYAxis().setAxisVisible(False)
        self.getXAxis().setAxisMin(0)
        self.getXAxis().setAxisMax(10)
        self.getXAxis().setTickCount(0)
        self.getYAxis().setAxisMin(0)
        self.getYAxis().setAxisMax(10)
        self.getYAxis().setTickCount(0)
        # this line orients the center of the first slice (apple) due east
        self.setInitialPieSliceOrientation(0.75 - pieMarketShare[0] / 2)
        for i in range(len(pieMarketShare)):
            self.addCurve()
            self.getCurve().addPoint(5, 5)
            self.getCurve().getSymbol().setSymbolType(
                SymbolType.PIE_SLICE_OPTIMAL_SHADING)
            self.getCurve().getSymbol().setBorderColor("white")
            self.getCurve().getSymbol().setBackgroundColor(pieColors[i])
            # next two lines define pie diameter in x-axis model units
            self.getCurve().getSymbol().setModelWidth(6)
            self.getCurve().getSymbol().setHeight(0)
            self.getCurve().getSymbol().setFillSpacing(0)
            self.getCurve().getSymbol().setFillThickness(3)
            self.getCurve().getSymbol().setHovertextTemplate(
                formatAsHovertext(pieTypes[i] + ", " +
                                  "%d%%" % round(100 * pieMarketShare[i])))
            self.getCurve().getSymbol().setPieSliceSize(pieMarketShare[i])
            self.getCurve().getPoint().setAnnotationText(pieTypes[i])
            self.getCurve().getPoint().setAnnotationLocation(
                AnnotationLocation.OUTSIDE_PIE_ARC)
Beispiel #28
0
    def __init__(self):
        GChart.__init__(self)


        self.phase = 0
        self.btn = Button("Update", self)
        self.setChartFootnotes(self.btn)

        self.setChartSize(1000,100)
        self.setChartTitle("<big><i>Sine vs Time</i></big>")
        self.setPadding("2px")

        self.getXAxis().setAxisLabel("<small><i>Time (seconds)</i></small>")
        self.getXAxis().setHasGridlines(True)
        self.getXAxis().setTickCount(6)
        self.getXAxis().setTickLabelFormat("#.##")
        self.getXAxis().setAxisMin(0)
        self.getXAxis().setAxisMax(PERIOD*N_PERIODS)

        self.getYAxis().setHasGridlines(True)
        self.getYAxis().setTickCount(5)
        self.getYAxis().setAxisMin(-1)
        self.getYAxis().setAxisMax(1)
        self.getYAxis().setTickLabelThickness(10)

        self.addCurve()
        self.getCurve().getSymbol().setSymbolType(SymbolType.VBAR_BASELINE_CENTER)
        self.getCurve().getSymbol().setBorderWidth(0)
        self.getCurve().getSymbol().setBackgroundColor("blue")
        self.getCurve().getSymbol().setFillSpacing(Double.NaN)
        self.getCurve().getSymbol().setFillThickness(0)
        self.getCurve().getSymbol().setHeight(1)
        self.getCurve().getSymbol().setWidth(1)

        for i in range(N_PERIODS):
            DeferredCommand.add(IncrementalUpdate(self, i, 0, 1))
Beispiel #29
0
    def __init__(self):
        GChart.__init__(self)

        self.phase = 0
        self.btn = Button("Update", self)
        self.setChartFootnotes(self.btn)

        self.setChartSize(1000, 100)
        self.setChartTitle("<big><i>Sine vs Time</i></big>")
        self.setPadding("2px")

        self.getXAxis().setAxisLabel("<small><i>Time (seconds)</i></small>")
        self.getXAxis().setHasGridlines(True)
        self.getXAxis().setTickCount(6)
        self.getXAxis().setTickLabelFormat("#.##")
        self.getXAxis().setAxisMin(0)
        self.getXAxis().setAxisMax(PERIOD * N_PERIODS)

        self.getYAxis().setHasGridlines(True)
        self.getYAxis().setTickCount(5)
        self.getYAxis().setAxisMin(-1)
        self.getYAxis().setAxisMax(1)
        self.getYAxis().setTickLabelThickness(10)

        self.addCurve()
        self.getCurve().getSymbol().setSymbolType(
            SymbolType.VBAR_BASELINE_CENTER)
        self.getCurve().getSymbol().setBorderWidth(0)
        self.getCurve().getSymbol().setBackgroundColor("blue")
        self.getCurve().getSymbol().setFillSpacing(Double.NaN)
        self.getCurve().getSymbol().setFillThickness(0)
        self.getCurve().getSymbol().setHeight(1)
        self.getCurve().getSymbol().setWidth(1)

        for i in range(N_PERIODS):
            DeferredCommand.add(IncrementalUpdate(self, i, 0, 1))
Beispiel #30
0
    def __init__(self):
        GChart.__init__(self)

        # labels/values for color selection drop-down list:
        self.colorSelector = ObjectSelectorDropdownList( \
                            [["Red", ColorSpec("red", "#F88")],
                            ["Fuchsia", ColorSpec("#F0F", "#F8F")],
                            ["Lime", ColorSpec("#0F0", "#8F8")],
                            ["Blue", ColorSpec("#00F", "#88F")],
                            ["Aqua", ColorSpec("#0FF", "#8FF")],
                            ["Maroon", ColorSpec("#800", "#C88")],
                            ["Purple", ColorSpec("#808", "#C8C")],
                            ["Green", ColorSpec("#080", "#8C8")],
                            ["Olive", ColorSpec("#880", "#CC8")],
                            ["Navy", ColorSpec("#008", "#88C")],
                            ["Teal", ColorSpec("#088", "#8CC")]])

        # labels/values for slice shading pattern drop-down list
        self.shadingSelector = ObjectSelectorDropdownList( \
            [["Vertical shading", SymbolType.PIE_SLICE_VERTICAL_SHADING],
            ["Horizontal shading", SymbolType.PIE_SLICE_HORIZONTAL_SHADING],
            ["Optimal shading", SymbolType.PIE_SLICE_OPTIMAL_SHADING]])

        # labels/values for pie slice size (as percentage) drop-down list
        self.sliceSizeSelector = ObjectSelectorDropdownList(
            [["0%", int(0)], ["5%", int(5)], ["10%", int(10)],
             ["15%", int(15)], ["20%", int(20)], ["25%", int(25)],
             ["30%", int(30)], ["35%", int(35)], ["40%", int(40)],
             ["45%", int(45)], ["50%", int(50)], ["55%", int(55)],
             ["60%", int(60)], ["65%", int(65)], ["70%", int(70)],
             ["75%", int(75)], ["80%", int(80)], ["85%", int(85)],
             ["90%", int(90)], ["95%", int(95)], ["100%", int(100)]])

        self.theSliceEditor = SliceEditor(self)

        SOURCE_CODE_LINK = \
        "<a href='GChartExample20.txt' target='_blank'>Source code</a>"
        self.setChartSize(100, 100)
        self.setBorderStyle("none")
        self.setChartTitle("<big>Click pie to edit!</big>")
        self.setChartTitleThickness(20)
        self.setChartFootnotes(SOURCE_CODE_LINK)
        self.setChartFootnotesThickness(20)
        # initial slice sizes
        initSliceSize = [0.3, 0.2, 0.1, 0.2, 0.2]

        self.addClickListener(self.theSliceEditor)

        for iCurve in range(N_SLICES):
            self.addCurve()
            self.getCurve().getSymbol().setBorderWidth(1)
            self.getCurve().getSymbol().setFillThickness(4)
            self.getCurve().getSymbol().setFillSpacing(4)
            self.getCurve().getSymbol().setHoverLocation(
                AnnotationLocation.ON_PIE_ARC)
            self.getCurve().getSymbol().setBorderColor(
                self.colorSelector.getObject(iCurve).borderColor)
            self.getCurve().getSymbol().setBackgroundColor(
                self.colorSelector.getObject(iCurve).backgroundColor)
            # selection flips border and background colors
            self.getCurve().getSymbol().setHoverSelectionBackgroundColor(
                self.colorSelector.getObject(iCurve).borderColor)
            self.getCurve().getSymbol().setHoverSelectionBorderColor(
                self.colorSelector.getObject(iCurve).backgroundColor)
            self.getCurve().getSymbol().setSymbolType(
                SymbolType.PIE_SLICE_HORIZONTAL_SHADING)
            self.getCurve().getSymbol().setPieSliceSize(initSliceSize[iCurve])
            self.getCurve().getSymbol().setModelHeight(1.0)
            #diameter = yMax-yMin
            self.getCurve().getSymbol().setModelWidth(0)
            self.getCurve().addPoint(0.5, 0.5)
            # pie centered in world units

        self.getXAxis().setAxisMin(0)
        # so 0.5,0.5 (see above) centers pie
        self.getXAxis().setAxisMax(1)
        self.getYAxis().setAxisMin(0)
        self.getYAxis().setAxisMax(1)
        self.getXAxis().setHasGridlines(False)
        # hides axes, ticks, etc.
        self.getXAxis().setAxisVisible(False)
        # (not needed for the pie)
        self.getXAxis().setTickCount(0)
        self.getYAxis().setHasGridlines(False)
        self.getYAxis().setAxisVisible(False)
        self.getYAxis().setTickCount(0)
        self.update()
Beispiel #31
0
    def __init__(self, testCanvas):
        GChart.__init__(self, XChartSize=300, YChartSize=300)
        self.setChartTitle(GChartTestAppUtil.getTitle(self))
        self.setClipToPlotArea(True)
        self.setChartFootnotes(
            "Check: an unclipped point at each corner.<br> No x-ticks.<br>Line clipped at plot area limits<br>Three clipped-off pies visible<br>Every at-least-partly visible symbol labeled."
        )

        self.getXAxis().setHasGridlines(True)
        self.getY2Axis().setHasGridlines(True)
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setYAxis(GChartConsts.Y_AXIS)
        self.getCurve().addPoint(0, -95)
        # clipped
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(0, -90)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(0, 0)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(0, 5)
        # clipped
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())

        self.getCurve().setLegendLabel("On Y")
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setYAxis(GChartConsts.Y2_AXIS)
        self.getCurve().addPoint(90, -50)
        # clipped
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(90, -45)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(90, 45)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(90, 50)
        # clipped
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        self.getCurve().setLegendLabel("On Y2")

        # continuous line whose edges self.get clipped off
        self.addCurve()
        self.getCurve().setLegendLabel("clipped line")
        self.getCurve().getSymbol().setBackgroundColor("blue")
        self.getCurve().getSymbol().setBorderColor("blue")
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        else:
            self.getCurve().getSymbol().setFillSpacing(10)

        self.getCurve().getSymbol().setFillThickness(3)
        self.getCurve().setYAxis(GChartConsts.Y_AXIS)
        #     self.getCurve().addPoint(50,-50)
        self.getCurve().addPoint(0, -100)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        #     self.getCurve().addPoint(50,-50)
        self.getCurve().addPoint(100, 0)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())

        # this should be entirely visible
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setLegendLabel("inside pie")
        self.getCurve().getSymbol().setSymbolType(
            SymbolType.PIE_SLICE_HORIZONTAL_SHADING)
        self.getCurve().getSymbol().setFillThickness(1)
        self.getCurve().getSymbol().setWidth(100)
        self.getCurve().getSymbol().setHeight(0)
        self.getCurve().setYAxis(GChartConsts.Y_AXIS)
        self.getCurve().addPoint(45, 0)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())

        # this should be entirely clipped.
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setLegendLabel("outside right pie")
        self.getCurve().getSymbol().setSymbolType(
            SymbolType.PIE_SLICE_HATCHED_SHADING)
        self.getCurve().getSymbol().setFillThickness(1)
        self.getCurve().getSymbol().setWidth(100)
        self.getCurve().getSymbol().setHeight(0)
        self.getCurve().setYAxis(GChartConsts.Y2_AXIS)
        self.getCurve().addPoint(95, 0)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())
        # this should be entirely clipped
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setLegendLabel("outside bottom pie")
        self.getCurve().getSymbol().setSymbolType(
            SymbolType.PIE_SLICE_VERTICAL_SHADING)
        self.getCurve().getSymbol().setFillThickness(1)
        self.getCurve().getSymbol().setWidth(100)
        self.getCurve().getSymbol().setHeight(0)
        self.getCurve().setYAxis(GChartConsts.Y_AXIS)
        self.getCurve().addPoint(45, -95)
        self.getCurve().getPoint().setAnnotationText(
            self.getCurve().getPoint().getHovertext())

        self.getXAxis().setAxisLabel(
            "<small><small><small>X</small></small></small>")
        self.getXAxis().setTickCount(0)
        self.getXAxis().setAxisMin(0.)
        self.getXAxis().setAxisMax(90.)
        self.getYAxis().setAxisMin(-90.)
        self.getYAxis().setAxisMax(0.)
        self.getY2Axis().setAxisMin(-45.)
        self.getY2Axis().setAxisMax(45)
Beispiel #32
0
 def __init__(self):
     GChart.__init__(self, XChartSize=150, YChartSize=150)
     self.setChartTitle(GChartTestAppUtil.getTitle(self))
     self.setChartFootnotes(
         "Check: Consistent with a 'no data' chart (and it doesn't crash).")
Beispiel #33
0
 def __init__(self):
     GChart.__init__(self, XChartSize=150, YChartSize=150)
     self.setChartTitle(GChartTestAppUtil.getTitle(self))
     self.setChartFootnotes("Check: Consistent with a 'no data' chart (and it doesn't crash).")
Beispiel #34
0
    def __init__(self, testCanvas):
        GChart.__init__(self, XChartSize=300,YChartSize=300)
        self.setChartTitle(GChartTestAppUtil.getTitle(self))
        self.setClipToPlotArea(True)
        self.setChartFootnotes("Check: an unclipped point at each corner.<br> No x-ticks.<br>Line clipped at plot area limits<br>Three clipped-off pies visible<br>Every at-least-partly visible symbol labeled.")

        self.getXAxis().setHasGridlines(True)
        self.getY2Axis().setHasGridlines(True)
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setYAxis(GChartConsts.Y_AXIS)
        self.getCurve().addPoint(0,-95); # clipped
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(0,-90)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(0,0)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(0,5);   # clipped
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())

        self.getCurve().setLegendLabel("On Y")
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setYAxis(GChartConsts.Y2_AXIS)
        self.getCurve().addPoint(90,-50); # clipped
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(90,-45)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(90,45)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        self.getCurve().addPoint(90,50);  # clipped
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        self.getCurve().setLegendLabel("On Y2")

        # continuous line whose edges self.get clipped off
        self.addCurve()
        self.getCurve().setLegendLabel("clipped line")
        self.getCurve().getSymbol().setBackgroundColor("blue")
        self.getCurve().getSymbol().setBorderColor("blue")
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        else:
            self.getCurve().getSymbol().setFillSpacing(10)

        self.getCurve().getSymbol().setFillThickness(3)
        self.getCurve().setYAxis(GChartConsts.Y_AXIS)
        #     self.getCurve().addPoint(50,-50)
        self.getCurve().addPoint(0,-100)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        #     self.getCurve().addPoint(50,-50)
        self.getCurve().addPoint(100,0)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())

        # this should be entirely visible
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setLegendLabel("inside pie")
        self.getCurve().getSymbol().setSymbolType(
                            SymbolType.PIE_SLICE_HORIZONTAL_SHADING)
        self.getCurve().getSymbol().setFillThickness(1)
        self.getCurve().getSymbol().setWidth(100)
        self.getCurve().getSymbol().setHeight(0)
        self.getCurve().setYAxis(GChartConsts.Y_AXIS)
        self.getCurve().addPoint(45,0)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())

        # this should be entirely clipped.
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setLegendLabel("outside right pie")
        self.getCurve().getSymbol().setSymbolType(
                            SymbolType.PIE_SLICE_HATCHED_SHADING)
        self.getCurve().getSymbol().setFillThickness(1)
        self.getCurve().getSymbol().setWidth(100)
        self.getCurve().getSymbol().setHeight(0)
        self.getCurve().setYAxis(GChartConsts.Y2_AXIS)
        self.getCurve().addPoint(95,0)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())
        # this should be entirely clipped
        self.addCurve()
        if testCanvas:
            self.getCurve().getSymbol().setFillSpacing(0)

        self.getCurve().setLegendLabel("outside bottom pie")
        self.getCurve().getSymbol().setSymbolType(
                            SymbolType.PIE_SLICE_VERTICAL_SHADING)
        self.getCurve().getSymbol().setFillThickness(1)
        self.getCurve().getSymbol().setWidth(100)
        self.getCurve().getSymbol().setHeight(0)
        self.getCurve().setYAxis(GChartConsts.Y_AXIS)
        self.getCurve().addPoint(45,-95)
        self.getCurve().getPoint().setAnnotationText(self.getCurve().getPoint().getHovertext())

        self.getXAxis().setAxisLabel("<small><small><small>X</small></small></small>")
        self.getXAxis().setTickCount(0)
        self.getXAxis().setAxisMin(0.)
        self.getXAxis().setAxisMax(90.)
        self.getYAxis().setAxisMin(-90.)
        self.getYAxis().setAxisMax(0.)
        self.getY2Axis().setAxisMin(-45.)
        self.getY2Axis().setAxisMax(45)
    def __init__(self):
        GChart.__init__(self)

        # labels/values for color selection drop-down list:
        self.colorSelector = ObjectSelectorDropdownList( \
                            [["Red", ColorSpec("red", "#F88")],
                            ["Fuchsia", ColorSpec("#F0F", "#F8F")],
                            ["Lime", ColorSpec("#0F0", "#8F8")],
                            ["Blue", ColorSpec("#00F", "#88F")],
                            ["Aqua", ColorSpec("#0FF", "#8FF")],
                            ["Maroon", ColorSpec("#800", "#C88")],
                            ["Purple", ColorSpec("#808", "#C8C")],
                            ["Green", ColorSpec("#080", "#8C8")],
                            ["Olive", ColorSpec("#880", "#CC8")],
                            ["Navy", ColorSpec("#008", "#88C")],
                            ["Teal", ColorSpec("#088", "#8CC")]])

        # labels/values for slice shading pattern drop-down list
        self.shadingSelector = ObjectSelectorDropdownList( \
            [["Vertical shading", SymbolType.PIE_SLICE_VERTICAL_SHADING],
            ["Horizontal shading", SymbolType.PIE_SLICE_HORIZONTAL_SHADING],
            ["Optimal shading", SymbolType.PIE_SLICE_OPTIMAL_SHADING]])

        # labels/values for pie slice size (as percentage) drop-down list
        self.sliceSizeSelector = ObjectSelectorDropdownList([
                                            ["0%", int(0)],
                                            ["5%", int(5)],
                                            ["10%", int(10)],
                                            ["15%", int(15)],
                                            ["20%", int(20)],
                                            ["25%", int(25)],
                                            ["30%", int(30)],
                                            ["35%", int(35)],
                                            ["40%", int(40)],
                                            ["45%", int(45)],
                                            ["50%", int(50)],
                                            ["55%", int(55)],
                                            ["60%", int(60)],
                                            ["65%", int(65)],
                                            ["70%", int(70)],
                                            ["75%", int(75)],
                                            ["80%", int(80)],
                                            ["85%", int(85)],
                                            ["90%", int(90)],
                                            ["95%", int(95)],
                                            ["100%", int(100)]])

        self.theSliceEditor = SliceEditor(self)

        SOURCE_CODE_LINK = \
        "<a href='GChartExample20.txt' target='_blank'>Source code</a>"
        self.setChartSize(100, 100)
        self.setBorderStyle("none")
        self.setChartTitle("<big>Click pie to edit!</big>")
        self.setChartTitleThickness(20)
        self.setChartFootnotes(SOURCE_CODE_LINK)
        self.setChartFootnotesThickness(20)
        # initial slice sizes
        initSliceSize = [0.3, 0.2, 0.1, 0.2, 0.2]

        self.addClickListener(self.theSliceEditor)

        for iCurve in range(N_SLICES):
            self.addCurve()
            self.getCurve().getSymbol().setBorderWidth(1)
            self.getCurve().getSymbol().setFillThickness(4)
            self.getCurve().getSymbol().setFillSpacing(4)
            self.getCurve().getSymbol().setHoverLocation(
            AnnotationLocation.ON_PIE_ARC)
            self.getCurve().getSymbol().setBorderColor(
                    self.colorSelector.getObject(iCurve).borderColor)
            self.getCurve().getSymbol().setBackgroundColor(
                    self.colorSelector.getObject(iCurve).backgroundColor)
            # selection flips border and background colors
            self.getCurve().getSymbol().setHoverSelectionBackgroundColor(
                    self.colorSelector.getObject(iCurve).borderColor)
            self.getCurve().getSymbol().setHoverSelectionBorderColor(
                    self.colorSelector.getObject(iCurve).backgroundColor)
            self.getCurve().getSymbol().setSymbolType(
                    SymbolType.PIE_SLICE_HORIZONTAL_SHADING)
            self.getCurve().getSymbol().setPieSliceSize(initSliceSize[iCurve])
            self.getCurve().getSymbol().setModelHeight(1.0); #diameter = yMax-yMin
            self.getCurve().getSymbol().setModelWidth(0)
            self.getCurve().addPoint(0.5, 0.5);  # pie centered in world units

        self.getXAxis().setAxisMin(0);  # so 0.5,0.5 (see above) centers pie
        self.getXAxis().setAxisMax(1)
        self.getYAxis().setAxisMin(0)
        self.getYAxis().setAxisMax(1)
        self.getXAxis().setHasGridlines(False); # hides axes, ticks, etc.
        self.getXAxis().setAxisVisible(False);  # (not needed for the pie)
        self.getXAxis().setTickCount(0)
        self.getYAxis().setHasGridlines(False)
        self.getYAxis().setAxisVisible(False)
        self.getYAxis().setTickCount(0)
        self.update()