def horizontal_bar_graph(self):
            """
            Draws a horizontal bar chart

            :return: horizontal bar chart
            """
            drawing = Drawing(200, 50)
            graph = HorizontalBarChart()
            graph.x = self.graph_x
            graph.y = self.graph_y

            graph.width = self.width
            graph.height = self.height

            graph.valueAxis.valueMin = self.value_min
            graph.valueAxis.valueMax = self.value_max
            graph.valueAxis.valueStep = self.value_step

            graph.data = self.data
            graph.categoryAxis.categoryNames = self.categories

            graph.barLabels.nudge = 15
            graph.barLabelFormat = '%d'
            graph.barLabels.dx = 0
            graph.barLabels.dy = 7
            graph.barLabels.boxAnchor = 'n'
            graph.barLabels.fontName = 'Vera'
            graph.barLabels.fontSize = 10

            graph.bars[0].fillColor = PCMYKColor(45, 45, 0, 0, alpha=85)
            graph.bars[1].fillColor = PCMYKColor(64, 75, 0, 18, alpha=95)
            graph.bars.fillColor = PCMYKColor(64, 62, 0, 18, alpha=85)
            drawing.add(graph, '')

            return [drawing]
Exemple #2
0
def get_studentPRChart(studentEvaluation, showPercentValue=False):
    pr_items = _get_pr_items(studentEvaluation)

    row_data = []
    row_barLabel = []
    categories = []
    '''这是一个Hack,因为Chart绘制的顺序和预期的不同。'''
    pr_items = reversed(pr_items)

    for item in pr_items:
        row_data.append(item.p_value)
        if showPercentValue:
            barLabel = '%s%%(%s %s)' % (item.p_value, item.e_value,
                                        item.e_unit)
        else:
            barLabel = '%s%%' % (item.p_value, )
        row_barLabel.append(barLabel)
        categories.append(item.name)

    data = [row_data]
    labels = [row_barLabel]

    drawing = Drawing(14 * cm, 6 * cm)
    bc = HorizontalBarChart()
    bc.x = 1.5 * cm
    bc.y = 0
    bc.width = drawing.width - bc.x
    bc.height = drawing.height
    bc.data = data
    bc.bars.strokeColor = None
    bc.bars[0].fillColor = colors.HexColor('#7fd8ff')
    bc.barLabelFormat = 'values'
    bc.barLabelArray = labels
    bc.barLabels.boxAnchor = 'w'
    bc.barLabels.fixedEnd = LabelOffset()
    bc.barLabels.fixedEnd.posMode = 'low'

    bc.barLabels.fontName = 'Microsoft-YaHei-Light'
    bc.barLabels.fontSize = 8
    bc.valueAxis.valueMin = 0
    bc.valueAxis.valueMax = 100
    bc.valueAxis.valueStep = 10
    bc.valueAxis.labels.fontName = 'Microsoft-YaHei-Light'
    bc.valueAxis.labels.fontSize = 8
    bc.categoryAxis.categoryNames = categories
    bc.categoryAxis.labels.boxAnchor = 'w'
    bc.categoryAxis.labels.dx = -1.5 * cm
    bc.categoryAxis.labels.fontName = 'Microsoft-YaHei-Light'
    bc.categoryAxis.labels.fontSize = 8
    bc.categoryAxis.visibleAxis = 0
    bc.categoryAxis.visibleTicks = 0

    drawing.add(bc)

    return drawing
def generate_histogram(data, left=True):
    chart = HorizontalBarChart()
    drawing = Drawing(300, 400)

    chart.bars.strokeColor = None
    chart.bars[0].fillColor = chartreuse if left else coral
    chart.x = 20 if left else 0
    chart.y = 0
    chart.width = 245
    chart.height = 400
    chart.data = [[data['hist'][c] for c in data['hist']]]
    chart.strokeColor = None
    chart.fillColor = None
    chart.valueAxis.valueMin = 0
    chart.valueAxis.valueMax = max(chart.data[0]) * 1.1
    # chart.valueAxis.visibleTicks = False
    # chart.valueAxis.valueStep = 10
    chart.valueAxis.reverseDirection = 1 if left else 0
    chart.categoryAxis.labels.boxAnchor = 'nw' if left else 'ne'
    chart.categoryAxis.labels.dx = 6 if left else -6
    chart.categoryAxis.labels.dy = 8
    chart.categoryAxis.categoryNames = [c for c in data['hist']]
    chart.categoryAxis.joinAxisMode = 'right' if left else 'left'
    chart.categoryAxis.reverseDirection = 1
    chart.categoryAxis.visibleTicks = False
    chart.categoryAxis.visibleAxis = False
    chart.categoryAxis.strokeColor = None
    drawing.add(chart)
    return drawing
Exemple #4
0
    def __init__(self, width=400, height=200, *args, **kw):
        Drawing.__init__(self, width, height, *args, **kw)
        self.add(HorizontalBarChart(), name='chart')

        question = q

        self.add(String(200, 180, "Question Title"),
                 name='title')  # replace 'QUESTION' with question title

        # set any shapes, fonts, colors you want here.  We'll just
        # set a title font and place the chart within the drawing
        self.chart.x = 20
        self.chart.y = 20
        self.chart.width = self.width - 50
        self.chart.height = self.height - 40

        self.title.fontName = 'Helvetica-Bold'
        self.title.fontSize = 12

        votes = []
        for choice in question.choice_set.all:  # iterate through all the votes for a set question
            votes.append(
                choice.votes
            )  # add the number of votes for each question to the data

        self.chart.data = [votes]  # put data in chart
Exemple #5
0
    def bar_chart(self, pdf, userdjango):
        usuariomodelo = Usuario.objects.get(usuario=userdjango)
        formularios = usuariomodelo.formulario_set.all()
        nombre = []  #labels
        ponderado = []  #porcetaje

        for datos in formularios:
            nombre.append(datos.nombreFormulario)
            ponderado.append(datos.ponderado)

        nuevo_ponderado = [float(i) for i in ponderado]
        drawing = Drawing(50, 150)
        data = [nuevo_ponderado]
        bc = HorizontalBarChart()
        bc.x = 100
        bc.y = 40
        bc.height = 470
        bc.width = 600
        bc.data = data
        #bc.strokeColor = colors.black
        bc.valueAxis.valueMin = 0
        bc.valueAxis.valueMax = 60
        bc.valueAxis.valueStep = 10
        bc.categoryAxis.labels.boxAnchor = 'ne'
        bc.categoryAxis.labels.dx = -2
        bc.categoryAxis.labels.dy = -2
        bc.categoryAxis.labels.angle = 0
        bc.categoryAxis.labels.fontSize = 7
        bc.categoryAxis.categoryNames = nombre
        drawing.add(bc)
        return drawing
def barChart(daten,Versuch,Phaenomene,path=None,vMin=1,vMax=6):
    """
    Plots data to a Drawing and returns the Drawing
    """
    #Festlegen der Gesamtgröße in Pixel
    d = Drawing(500,160)
    #Daten für das Diagramm
    #daten = [(10,6,8)]
    #Anlegen des Diagramms
    diagramm = HorizontalBarChart()
    #Positionierung und Größe des Diagramms
    diagramm.x = 10
    diagramm.y = 30
    diagramm.height = 100
    diagramm.width = 400
    #Hinzufügen der Daten
    #diagramm.reversePlotOrder = 1
    diagramm.data = daten
    #Y-Achse (in ReportLab „valueAxis“) formatieren
    diagramm.valueAxis.valueMin = vMin
    diagramm.valueAxis.valueMax = vMax
    diagramm.valueAxis.valueStep = 1
    #X-Achse (in ReportLab „categoryAxis“) formatieren
    diagramm.categoryAxis.categoryNames = Phaenomene
    #Diagramm zeichnen
    d.add(diagramm)
    if not path == None:
        Versuch = path + Versuch    
    renderPM.drawToFile(d, Versuch + ".png", 'PNG')    
    #d = Paragraph(d, centered)
    d.scale(0.8,0.8)
    
    return d
Exemple #7
0
    def tercero_chart(self, pdf, userdjango):
        usuariomodelo = Usuario.objects.get(usuario=userdjango)
        formularios = usuariomodelo.formulario_set.all()
        nivel = []
        ponderado = []

        for datos in formularios:
            nivel.append(datos.nivel)
            ponderado.append(datos.ponderado)

        nuevo_ponderado = [float(i) for i in ponderado]
        drawing = Drawing(50, 150)
        data = [nuevo_ponderado]
        bc = HorizontalBarChart()
        bc.x = 100
        bc.y = 40
        bc.height = 520
        bc.width = 600
        bc.data = data
        bc.valueAxis.valueMin = 0
        bc.valueAxis.valueMax = 60
        bc.valueAxis.valueStep = 10
        bc.categoryAxis.labels.boxAnchor = 'ne'
        bc.categoryAxis.labels.dx = -2
        bc.categoryAxis.labels.dy = -2
        bc.categoryAxis.labels.angle = 0
        bc.categoryAxis.labels.fontSize = 7
        bc.categoryAxis.categoryNames = nivel
        drawing.add(bc)
        return drawing
Exemple #8
0
def simple_horizontal_bar_chart():
    d = Drawing(280, 250)
    bar = HorizontalBarChart()
    bar.x = 50
    bar.y = 85
    bar.height = 225
    bar.width = 250
    data = [[1, 2, 3, None, None],
            [10, 5, 2, 6, 8],
            [5, 7, 2, 8, 8],
            [2, 10, 2, 1, 8],
            ]
    bar.data = data
    bar.categoryAxis.categoryNames = ['Year1', 'Year2', 'Year3',
                                      'Year4', 'Year5', 'Year6',
                                      'Year7']

    bar.bars[0].fillColor = colors.green
    bar.bars[1].fillColor = colors.blue
    bar.bars[2].fillColor = colors.red
    bar.bars[3].fillColor = colors.purple
    
    bar.categoryAxis.labels.angle = 45
    bar.categoryAxis.labels.dx = -15
    
    d.add(bar, '')

    doc = SimpleDocTemplate('18.simple_horizontal_bar_chart.pdf')
    story = []
    story.append(d)
    doc.build(story)
Exemple #9
0
    def __init__(self,
                 drawing=None,
                 title=None,
                 data=None,
                 x=45,
                 y=25,
                 width=170,
                 height=130):

        if len(data) > 1:
            y = y + 22
            height = height - 22

        bars = HorizontalBarChart()
        bars.x = x
        bars.y = y
        bars.data = [[value for (_, value) in category] for category in data]
        bars.width = width
        bars.height = height
        bars.valueAxis.forceZero = 1
        bars.valueAxis.labels.fontName = 'Lato'
        bars.valueAxis.labels.fontSize = 9
        bars.valueAxis.strokeColor = white
        bars.valueAxis.visibleGrid = 1
        bars.bars[0].fillColor = toColor(my_color_func())
        bars.bars.strokeColor = white
        bars.categoryAxis.categoryNames = [key for (key, _) in data[0]]
        bars.categoryAxis.tickRight = 0
        bars.categoryAxis.tickLeft = 0
        #bars.categoryAxis.strokeColor = white
        bars.categoryAxis.labels.fontName = 'Lato'
        bars.categoryAxis.labels.fontSize = 9

        legend = Legend()
        legend.y = 25
        legend.x = 95
        legend.strokeColor = white
        legend.alignment = 'right'
        legend.fontName = 'Lato'
        legend.fontSize = 9
        legend.dx = 6
        legend.dy = 6
        legend.dxTextSpace = 5
        legend.deltay = 10
        legend.strokeWidth = 0
        legend.strokeColor = white

        colors = map(toColor, get_n_random_colors(len(data)))
        for (i, color) in enumerate(colors):
            bars.bars[i].fillColor = color

        if len(data) > 1:
            legend_data = (title, 'Benchmark')
            legend.colorNamePairs = zip(colors, legend_data)
            drawing.add(legend)

        drawing.add(bars)
Exemple #10
0
def vendorcreatedperquarter(vendor_data):
    vendor_data['Period'] = vendor_data['Created Date'].dt.to_period('M')
    vendor_data['Qtr'] = (vendor_data['Period']).dt.quarter
    vendor_data['Year'] = vendor_data['Created Date'].map(lambda x: 1 * x.year)
    vendor_data["Quarter"] = vendor_data["Year"].map(str) + "Q" + vendor_data["Qtr"].map(str)

    # raw_ven_data = vendor_data[['Vendor ID', 'Quarter']]

    act_raw_ven_data = vendor_data[vendor_data['Status'] == 'Active'][['Vendor ID', 'Quarter']]
    inact_raw_ven_data = vendor_data[vendor_data['Status'] == 'In Active'][['Vendor ID', 'Quarter']]

    group_data = vendor_data[['Vendor ID', 'Quarter']].groupby(['Quarter']).count()

    act_group_ven_data = act_raw_ven_data.groupby(['Quarter']).count()
    inact_group_ven_data = inact_raw_ven_data.groupby(['Quarter']).count()

    act_data = act_group_ven_data['Vendor ID'].tolist()
    inact_data = inact_group_ven_data['Vendor ID'].tolist()

    y_data = group_data.index.tolist()

    drawing = Drawing(200, 100)
    list_data = []
    list_data.append(act_data)
    list_data.append(inact_data)
    data = list_data

    lc = HorizontalBarChart()

    lc.x = 10
    lc.y = -150
    lc.height = 250
    lc.width = 450
    lc.data = data
    lc.categoryAxis.categoryNames = y_data
    lc.bars[0].fillColor = colors.lightblue
    lc.bars[1].fillColor = colors.lightgreen
    # lc.lines.symbol = makeMarker('Circle')

    # name1 = 'Active'
    # name2 = 'Inactive'
    #
    # swatches = Legend()
    # swatches.alignment = 'right'
    # swatches.x = 80
    # swatches.y = 160
    # swatches.deltax = 60
    # swatches.dxTextSpace = 10
    # swatches.columnMaximum = 4
    # items = [(colors.lightblue, name1), (colors.lightgreen, name2)]
    # swatches.colorNamePairs = items

    drawing.add(lc)

    return drawing
Exemple #11
0
    def __init__(self, width=400, height=200, *args, **kw):
        Drawing.__init__(self, width, height, *args, **kw)
        self.add(HorizontalBarChart(), name='chart')

        self.add(String(200, 180, 'TEST CHART'), name='title')
        self.chart.x = 20
        self.chart.y = 20
        self.chart.width = self.width - 20
        self.chart.height = self.height - 40

        self.title.fontName = 'Helvetica-Bold'
        self.title.fontSize = 12

        self.chart.data = [[100, 150, 200, 235, 400, 15]]
Exemple #12
0
    def __init__(self, width=400, height=200, *args, **kw):
        Drawing.__init__(self, width, height, *args, **kw)
        self.add(HorizontalBarChart(), name='chart')
        self.add(String(200, 180, 'Hello World'), name='title')
        # set any shapes, fonts, colors you want here.  We'll just
        # set a title font and place the chart within the drawing
        self.chart.x = 20
        self.chart.y = 20
        self.chart.width = self.width - 20
        self.chart.height = self.height - 40

        self.title.fontName = 'Helvetica-Bold'
        self.title.fontSize = 12

        self.chart.data = [[100, 150, 200, 235]]
def vendorcreatedperquarter(vendor_data):
    vendor_data['Period'] = vendor_data['Created Date'].dt.to_period('M')
    vendor_data['Qtr'] = (vendor_data['Period']).dt.quarter
    vendor_data['Year'] = vendor_data['Created Date'].map(lambda x: 1 * x.year)
    vendor_data["Quarter"] = vendor_data["Year"].map(
        str) + "Q" + vendor_data["Qtr"].map(str)

    # raw_ven_data = vendor_data[['Vendor ID', 'Quarter']]

    act_raw_ven_data = vendor_data[vendor_data['Status'] == 'Active'][[
        'Vendor ID', 'Quarter'
    ]]
    inact_raw_ven_data = vendor_data[vendor_data['Status'] == 'In Active'][[
        'Vendor ID', 'Quarter'
    ]]

    group_data = vendor_data[['Vendor ID',
                              'Quarter']].groupby(['Quarter']).count()

    act_group_ven_data = act_raw_ven_data.groupby(['Quarter']).count()
    inact_group_ven_data = inact_raw_ven_data.groupby(['Quarter']).count()

    act_data = act_group_ven_data['Vendor ID'].tolist()
    inact_data = inact_group_ven_data['Vendor ID'].tolist()

    y_data = group_data.index.tolist()

    drawing = Drawing(200, 100)
    list_data = []
    list_data.append(act_data)
    list_data.append(inact_data)
    data = list_data

    lc = HorizontalBarChart()

    lc.x = 10
    lc.y = -200
    lc.height = 300
    lc.width = 450
    lc.data = data
    lc.categoryAxis.categoryNames = y_data
    lc.bars[0].fillColor = colors.lightblue
    lc.bars[1].fillColor = colors.lightgreen
    # lc.lines.symbol = makeMarker('Circle')

    drawing.add(lc)

    return drawing
Exemple #14
0
    def __init__(
        self,
        width=A4[0],
        height=A4[1] * 0.25,
        leftMargin=inch,
        rightMargin=inch,
        axis_font_size=10,
        axis_font_name='simsun',
    ):
        self.axis_font_name = axis_font_name
        self.axis_font_size = axis_font_size
        self.width = width
        self.height = height
        self.chart_width = self.width - leftMargin - rightMargin
        self.chart_height = self.height

        self.chart = HorizontalBarChart()
        self.chart.x = 0
        self.chart.y = 0

        self.chart.width = self.chart_width
        self.chart.height = self.chart_height
        self.chart.bars.strokeColor = None
        # 设置柱状图的柱子颜色
        self.chart.bars[0].fillColor = deepskyblue

        # 设置在柱状图后增加该坐标的值
        self.chart.barLabelFormat = '%0.2f'
        self.chart.barLabels.boxAnchor = 'w'  # 锚点,用不好..
        self.chart.barLabels.dx = 0.1 * cm  # 柱状图的值向右偏移0.1CM

        # 设置柱状图的柱宽
        self.chart.barWidth = height * 0.05

        self.title = Label()
        self.x_unit = Label()
        self.y_unit = Label()

        self.title.setText('')
        self.x_unit.setText('')
        self.y_unit.setText('')

        self.x_unit.fontName = self.axis_font_name
        self.y_unit.fontName = self.axis_font_name
    def add_vertical_bar_chart(self, data, categories, dataLabel):
        if len(categories) == 0:
            return
        if len(data) == 0:
            return

        drawing = Drawing(self.content_width(), len(categories)*15 + 50)
        
        maxValue = 1
        for value in data:
            if value > maxValue:
                maxValue = value

        bc = HorizontalBarChart()
        bc.height = len(categories)*15
        bc.width = self.content_width() - 300
        bc.x = 150
        bc.y = 25
        bc.groupSpacing = 2

        bc.data = [data]
        bc.strokeColor = None
        bc.bars[0].fillColor = CYAN

        bc.valueAxis.valueMin = 0
        bc.valueAxis.valueMax = maxValue
        bc.valueAxis.valueStep = max(maxValue/5, 1)
        bc.valueAxis.labelTextFormat = dataLabel

        bc.categoryAxis.labels.boxAnchor = 'e'
        bc.categoryAxis.labels.dx = -8
        bc.categoryAxis.labels.dy = 0
        bc.categoryAxis.categoryNames = categories

        drawing.add(bc)
        self.add(drawing)
Exemple #16
0
    def __init__(self, width=480, height=480, *args, **kwargs):
        Drawing.__init__(self, width, height, *args, **kwargs)

        self.add(HorizontalBarChart(), name='chart')
        self.chart.width = self.width - 100
        self.chart.height = self.height - 80
        self.chart.x = 60
        self.chart.y = 60
        self.chart.barSpacing = 1
        self.chart.groupSpacing = 6
        self.chart.bars[0].fillColor = barColors[2]
        self.chart.bars[1].fillColor = barColors[1]
        self.chart.bars[2].fillColor = barColors[0]
        self.chart.bars.strokeWidth = 0
        self.chart.barLabelFormat = '%d'
        self.chart.barLabels.boxAnchor = 'w'
        self.chart.barLabels.fontSize = 8
        self.chart.barLabels.leftPadding = 3
        self.chart.barLabels.textAnchor = 'middle'
        self.chart.categoryAxis.strokeColor = barColors[1]
        self.chart.categoryAxis.labels.fontSize = 9
        self.chart.categoryAxis.labels.textAnchor = 'end'
        self.chart.valueAxis.valueMin = 0
        self.chart.valueAxis.strokeColor = barColors[1]
        self.chart.valueAxis.labels.fontSize = 9

        self.add(Legend(), name='legend')
        self.legend.alignment = 'right'
        self.legend.fontSize = 10
        self.legend.x = int(0.24 * self.width)
        self.legend.y = 25
        self.legend.boxAnchor = 'nw'
        self.legend.colorNamePairs = [(barColors[0], 'Surveys Sent'),
                                      (barColors[1], 'Surveys Started'),
                                      (barColors[2], 'Surveys Completed')]
        self.legend.dxTextSpace = 5
        self.legend.dy = 6
        self.legend.dx = 6
        self.legend.deltay = 5
        self.legend.columnMaximum = 1
        self.legend.strokeWidth = 0
Exemple #17
0
 def __init__(self, xList, yList, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.width = 80 * 1.2 * 2.5
     self.height = 60 * 0.8 * 2.5
     self._add(self,
               HorizontalBarChart(),
               name='chart',
               validate=None,
               desc=None)
     self.chart.y = 11.2 * 2
     self.chart.x = 20 * 2
     #self.chart.data = [[0.05, 0.05, 0.1, 0.1, 0.05, 0.05, 0.955555]]
     self.chart.data = yList
     self.chart.width = self.width * 0.75
     self.chart.height = self.height * 0.75
     self.chart.bars.strokeColor = None
     self.chart.bars[0].fillColor = colors.blue
     self.chart.valueAxis.valueMin = 0
     self.chart.valueAxis.valueMax = 1.0
     self.chart.valueAxis.valueStep = 0.2
     self.chart.categoryAxis.visibleTicks = False
     self.chart.barLabelFormat = DecimalFormatter(3)
     self.chart.barLabels.boxAnchor = 'w'
     self.chart.barLabels.fontSize = 2.8 * 2.5
     self.chart.barLabels.fontName = 'Helvetica-Bold'
     self.chart.valueAxis.labels.fontSize = 2.8 * 2.5
     self.chart.valueAxis.labels.fontName = 'Helvetica-Bold'
     #self.chart.categoryAxis.categoryNames = ['unaligned', 'mRNA', 'rRNA', 'snoRNA', 'tRNA', 'hairpin miRNA', 'miRNA']
     self.chart.categoryAxis.categoryNames = xList
     self.chart.categoryAxis.labels.fontSize = 2.8 * 2.5
     self.chart.categoryAxis.labels.fontName = 'Helvetica-Bold'
     self._add(self,
               Label(),
               name='XLabel',
               validate=None,
               desc='Percentage')
     self.XLabel.fontSize = 4.4 * 2
     self.XLabel.fontName = 'Helvetica-Bold'
     self.XLabel._text = 'Percentage'
     self.XLabel.dx = 48 * 2.5
     self.XLabel.dy = 2
Exemple #18
0
 def draw_bar_plot(self, data, names):
     d = Drawing(50, 100)
     bar = HorizontalBarChart()
     bar.data = data
     bar.x = 180
     bar.y = 0
     bar.categoryAxis.categoryNames = names
     bar.valueAxis.valueMin = 0
     bar.valueAxis.valueMax = 100
     bar.bars[0].fillColor = self.rgb_to_color_obj((65, 182, 230))
     bar.barLabels.angle = 0
     bar.barLabelFormat = DecimalFormatter(2, suffix='%')
     bar.barLabels.dx = 20
     d.add(bar, '')
     self.content.append(self.small_space)
     self.content.append(d)
     self.content.append(self.large_space)
Exemple #19
0
 def __init__(self, width=200, height=150, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self._add(self,
               HorizontalBarChart(),
               name='chart',
               validate=None,
               desc="The main chart")
     self.chart.width = 115
     self.chart.height = 80
     self.chart.x = 30
     self.chart.y = 40
     self.chart.bars[0].fillColor = color01
     self.chart.bars[1].fillColor = color02
     self.chart.bars[2].fillColor = color03
     self.chart.bars[3].fillColor = color04
     self.chart.bars[4].fillColor = color05
     self.chart.bars[5].fillColor = color06
     self.chart.bars[6].fillColor = color07
     self.chart.bars[7].fillColor = color08
     self.chart.bars[8].fillColor = color09
     self.chart.bars[9].fillColor = color10
     self.chart.fillColor = backgroundGrey
     self.chart.barLabels.fontName = 'Helvetica'
     self.chart.valueAxis.labels.fontName = 'Helvetica'
     self.chart.valueAxis.labels.fontSize = 6
     self.chart.valueAxis.forceZero = 1
     self.chart.data = [(100, 150, 180), (125, 180, 200)]
     self.chart.groupSpacing = 15
     self.chart.valueAxis.avoidBoundFrac = 1
     self.chart.valueAxis.gridEnd = 80
     self.chart.valueAxis.tickDown = 3
     self.chart.valueAxis.visibleGrid = 1
     self.chart.categoryAxis.categoryNames = ['North', 'South', 'Central']
     self.chart.categoryAxis.tickLeft = 3
     self.chart.categoryAxis.labels.fontName = 'Helvetica'
     self.chart.categoryAxis.labels.fontSize = 6
     self.chart.categoryAxis.labels.dx = -3
     self._add(self,
               Label(),
               name='Title',
               validate=None,
               desc="The title at the top of the chart")
     self.Title.fontName = 'Helvetica-Bold'
     self.Title.fontSize = 7
     self.Title.x = 100
     self.Title.y = 135
     self.Title._text = 'Chart Title'
     self.Title.maxWidth = 180
     self.Title.height = 20
     self.Title.textAnchor = 'middle'
     self._add(self,
               Legend(),
               name='Legend',
               validate=None,
               desc="The legend or key for the chart")
     self.Legend.colorNamePairs = [(color01, 'Widgets'),
                                   (color02, 'Sprockets')]
     self.Legend.fontName = 'Helvetica'
     self.Legend.fontSize = 7
     self.Legend.x = 153
     self.Legend.y = 85
     self.Legend.dxTextSpace = 5
     self.Legend.dy = 5
     self.Legend.dx = 5
     self.Legend.deltay = 5
     self.Legend.alignment = 'right'
     self._add(self,
               Label(),
               name='XLabel',
               validate=None,
               desc="The label on the horizontal axis")
     self.XLabel.fontName = 'Helvetica'
     self.XLabel.fontSize = 7
     self.XLabel.x = 85
     self.XLabel.y = 10
     self.XLabel.textAnchor = 'middle'
     self.XLabel.maxWidth = 100
     self.XLabel.height = 20
     self.XLabel._text = "X Axis"
     self._add(self,
               Label(),
               name='YLabel',
               validate=None,
               desc="The label on the vertical axis")
     self.YLabel.fontName = 'Helvetica'
     self.YLabel.fontSize = 7
     self.YLabel.x = 12
     self.YLabel.y = 80
     self.YLabel.angle = 90
     self.YLabel.textAnchor = 'middle'
     self.YLabel.maxWidth = 100
     self.YLabel.height = 20
     self.YLabel._text = "Y Axis"
     self.chart.categoryAxis.style = 'stacked'
     self._add(self, 0, name='preview', validate=None, desc=None)
from reportlab.platypus import SimpleDocTemplate
from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.barcharts import HorizontalBarChart
from reportlab.lib import colors

doc = SimpleDocTemplate("pdfs/extra-071.pdf")
story = []
"""

Exemplo do gerador de gráficos automático do reportlab

"""

drawing = Drawing(400, 200)
data = [(1, 2, 3, 3, 5, 4, 2, 3)]
bc = HorizontalBarChart()
bc.x = 50
bc.y = 50
bc.height = 125
bc.width = 150
bc.data = data
bc.strokeColor = colors.black
bc.valueAxis.valueMin = 0
bc.valueAxis.valueMax = 5
bc.valueAxis.valueStep = 1
bc.categoryAxis.labels.boxAnchor = 'ne'
bc.categoryAxis.labels.dx = -5
bc.categoryAxis.labels.dy = 8
bc.categoryAxis.labels.angle = 0
bc.categoryAxis.categoryNames = [
    'Liderança', 'Comunicação', 'Empreendedorismo', 'Detalhe',
Exemple #21
0
    def __init__(self, width=400, height=200, *args, **kw):
        Drawing.__init__(*(self, width, height) + args, **kw)
        bc = HorizontalBarChart()
        bc.x = 50
        bc.y = 50
        bc.height = 125
        bc.width = 300
        bc.data = dataSample5
        bc.strokeColor = colors.black

        bc.useAbsolute = 1
        bc.barWidth = 10
        bc.groupSpacing = 20
        bc.barSpacing = 10

        bc.valueAxis.valueMin = 0
        bc.valueAxis.valueMax = 60
        bc.valueAxis.valueStep = 15

        bc.categoryAxis.labels.boxAnchor = 'e'
        bc.categoryAxis.categoryNames = ['Ying', 'Yang']

        self.add(bc, name='HBC')
                    def generate_page1(c):
                        #Image----------------------------------------------------------------------
                        im1 = Image.open("left.jpg")
                        c.drawInlineImage(im1,
                                          10,
                                          15,
                                          width=546 / 2.3,
                                          height=1290 / 2.3)

                        im2 = Image.open("shinken.jpg")
                        c.drawInlineImage(im2,
                                          259,
                                          height - 183,
                                          width=2434 / 4.4,
                                          height=725 / 4.4)

                        im3 = Image.open("skor.jpg")
                        c.drawInlineImage(im3,
                                          259,
                                          height - 251,
                                          width=2335 / 4.2,
                                          height=271 / 4.2)

                        im4 = Image.open("diagram.jpg")
                        c.drawInlineImage(im4,
                                          259,
                                          15,
                                          width=2339 / 4.2,
                                          height=1367 / 4.2)

                        #grafik1----------------------------------------------------------------------

                        from reportlab.graphics.shapes import Drawing
                        from reportlab.graphics.charts.barcharts import HorizontalBarChart

                        drawing = Drawing(500, 250)
                        data = [(N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11,
                                 N12, N13, N14, N15, N16, N17)]
                        bc = HorizontalBarChart()
                        bc.x = 100
                        bc.y = 100
                        bc.height = 250
                        bc.width = 300
                        bc.data = data
                        bc.strokeColor = None
                        bc.fillColor = None
                        #                        bc.bars[0].fillColor = PCMYKColor(92,47,0,33,alpha=95)
                        #                        bc.bars[0].strokeColor = PCMYKColor(92,47,0,33,alpha=95)
                        #                        bc.bars[0].fillColor = PCMYKColor(92,32,0,33,alpha=95)
                        #                        bc.bars[0].strokeColor = PCMYKColor(92,32,0,33,alpha=95)
                        bc.bars[0].fillColor = PCMYKColor(92,
                                                          16,
                                                          0,
                                                          33,
                                                          alpha=95)
                        bc.bars[0].strokeColor = PCMYKColor(92,
                                                            16,
                                                            0,
                                                            33,
                                                            alpha=95)
                        #                        bc.bars[0].fillColor = PCMYKColor(92,7,0,33,alpha=95)
                        #                        bc.bars[0].strokeColor = PCMYKColor(92,7,0,33,alpha=95)
                        bc.barWidth = 15
                        bc.valueAxis.valueMin = 0
                        bc.valueAxis.valueMax = 100
                        bc.valueAxis.valueStep = 10
                        bc.valueAxis.visibleAxis = False
                        bc.valueAxis.visibleGrid = False
                        bc.valueAxis.visibleTicks = False
                        bc.valueAxis.forceZero = True
                        bc.valueAxis.visibleLabels = 0

                        bc.categoryAxis.visibleGrid = False
                        bc.categoryAxis.visibleTicks = False  # hidding the ticks remove the label
                        bc.categoryAxis.tickLeft = 0  # a workaround is to set the tick length
                        bc.categoryAxis.tickRight = 0  # to zero.
                        bc.categoryAxis.strokeWidth = 0.25
                        bc.categoryAxis.labelAxisMode = 'low'
                        bc.categoryAxis.labels.textAnchor = 'end'
                        bc.categoryAxis.labels.angle = 0
                        bc.categoryAxis.labels.fontName = 'Designosaur-Regular'
                        #bc.categoryAxis.labels.fontColor    = PCMYKColor(0,65,100,0,alpha=90)
                        bc.categoryAxis.labels.boxAnchor = 'e'
                        bc.categoryAxis.labels.dx = -5
                        bc.categoryAxis.labels.dy = 0
                        bc.categoryAxis.labels.angle = 0
                        bc.categoryAxis.reverseDirection = 1
                        bc.categoryAxis.joinAxisMode = 'left'
                        bc.categoryAxis.categoryNames = [
                            NN1, NN2, NN3, NN4, NN5, NN6, NN7, NN8, NN9, NN10,
                            NN11, NN12, NN13, NN14, NN15, NN16, NN17
                        ]

                        bc.barLabels.fontName = 'Designosaur-Regular'
                        bc.barLabels.fontSize = 10
                        bc.barLabels.angle = 0
                        bc.barLabelFormat = "%.00f%%"
                        bc.barLabels.boxAnchor = 'w'
                        bc.barLabels.boxFillColor = None
                        bc.barLabels.boxStrokeColor = None
                        bc.barLabels.dx = 10
                        bc.barLabels.dy = 0
                        #bc.barLabels.dy            = -1
                        bc.barLabels.boxTarget = 'hi'

                        drawing.add(bc)
                        drawing.wrapOn(c, width, height)
                        drawing.drawOn(c, 350, height - 650)

                        #Table---------------------------------------------------------------------

                        styleBH = styles["Normal"]
                        styleBH.alignment = TA_CENTER
                        styleBH.fontSize = 12
                        styleBH.fontName = 'Designosaur-Regular'
                        #styleBH.textColor = PCMYKColor(92,7,0,33,alpha=100)
                        isi1 = Paragraph(nama, styleBH)
                        isitabel1 = [[isi1]]
                        table1 = Table(isitabel1, colWidths=[150])
                        table1.wrapOn(c, width, height)
                        table1.drawOn(c, 54, height - 352)

                        isi2 = Paragraph(kelas, styleBH)
                        isitabel2 = [[isi2]]
                        table2 = Table(isitabel2, colWidths=[150])
                        table2.wrapOn(c, width, height)
                        table2.drawOn(c, 54, height - 386)

                        isi3 = Paragraph(sekolah, styleBH)
                        isitabel3 = [[isi3]]
                        table3 = Table(isitabel3, colWidths=[150])
                        table3.wrapOn(c, width, height)
                        table3.drawOn(c, 54, height - 421)

                        isi4 = Paragraph(outlet, styleBH)
                        isitabel4 = [[isi4]]
                        table4 = Table(isitabel4, colWidths=[150])
                        table4.wrapOn(c, width, height)
                        table4.drawOn(c, 54, height - 455)

                        #Text----------------------------------------------------------------------

                        #nilai total
                        c.setFillColor(white)
                        c.setStrokeColor(white)
                        if (NTotal == '10.0'):
                            c.setFont("Designosaur-Regular", 35)
                            c.drawString(352, height - 230, NTotal + "/")
                            c.setFont("Designosaur-Regular", 20)
                            c.drawString(395, height - 235, "10")
                        else:
                            c.setFont("Designosaur-Regular", 35)
                            c.drawString(338, height - 230, NTotal + "/")
                            c.setFont("Designosaur-Regular", 20)
                            c.drawString(415, height - 235, "10")

                        #Yang paling tidak dikuasai siswa
                        c.setFont("Designosaur-Regular", 9)
                        c.drawString(
                            576, height - 205,
                            "Topik yang paling tidak dikuasai peserta Try-Out II :"
                        )
                        c.drawString(576, height - 216,
                                     "1. Mean, Median, dan Modus")
                        c.drawString(576, height - 227, "2. Debit Air")
                        c.drawString(576, height - 238, "3. Bangun Ruang")
from reportlab.lib import colors

doc = SimpleDocTemplate("pdfs/extra-071.pdf")
story  = []

"""

Exemplo do gerador de gráficos automático do reportlab

"""

drawing = Drawing(400, 200)
data = [
        (1, 2, 3, 3, 5, 4, 2, 3)
        ]
bc = HorizontalBarChart()
bc.x = 50
bc.y = 50
bc.height = 125
bc.width = 150
bc.data = data
bc.strokeColor = colors.black
bc.valueAxis.valueMin = 0
bc.valueAxis.valueMax = 5
bc.valueAxis.valueStep = 1
bc.categoryAxis.labels.boxAnchor = 'ne'
bc.categoryAxis.labels.dx = -5
bc.categoryAxis.labels.dy = 8
bc.categoryAxis.labels.angle = 0
bc.categoryAxis.categoryNames = ['Liderança','Comunicação','Empreendedorismo',
       'Detalhe','Decisão racional','Cumprimento à normas','Criatividade','Energia']
Exemple #24
0
    def createDocument(self):  # funzione che crea il documento
        """"""
        voffset = 65  # offset verticale

        # add a logo and size it
        logo = Image('Image_pdf/Meta-logo.jpg')  # indica la path dell'immagine
        logo.drawHeight = 3 * inch  # indica l'alteza dell'immagine
        logo.drawWidth = 3.5 * inch  # indica la larghezza dell'immagine
        logo.wrapOn(
            self.c, self.width,
            self.height)  # indica l'impostazione dell'immagine nel foglio
        logo.drawOn(self.c, *self.coord(
            65, 80, mm))  # disegna la foto a coordinate fissate 65,80, mm

        address = """<font size="24">
		Stazione di %s%s</font>
        """ % (self.namestation, self.id
               )  # indica il nome della stazione corrente
        p = Paragraph(
            address,
            self.styles["Normal"])  # creazione di un paragrafo di testo
        p.wrapOn(self.c, self.width,
                 self.height)  # importazione del testo nel foglio
        if len(
                self.namestation
        ) == 6:  # if fatti per centrare il nome della stazione nel foglio
            self.X = 188
        elif len(self.namestation) == 3:
            self.X = 223
        elif len(self.namestation) == 4:
            self.X = 214
        elif len(self.namestation) == 5:
            self.X = 205
        elif len(self.namestation) == 7:
            self.X = 180
        elif len(self.namestation) == 8:
            self.X = 175
        elif len(self.namestation) == 9:
            self.X = 172
        elif len(self.namestation) == 10:
            self.X = 168
        elif len(self.namestation) == 11:
            self.X = 164
        elif len(self.namestation) == 12:
            self.X = 160
        elif len(self.namestation) == 13:
            self.X = 156
        elif len(self.namestation) == 14:
            self.X = 152
        elif len(self.namestation) == 15:
            self.X = 148
        elif len(self.namestation) == 16:
            self.X = 144
        elif len(self.namestation) == 17:
            self.X = 140
        elif len(self.namestation) == 18:
            self.X = 136
        elif len(self.namestation) == 19:
            self.X = 132
        elif len(self.namestation) == 20:
            self.X = 128
        elif len(self.namestation) == 21:
            self.X = 124
        elif len(self.namestation) == 22:
            self.X = 120
        elif len(self.namestation) == 23:
            self.X = 116
        p.drawOn(self.c, *self.coord(self.X,
                                     195))  # diesgna il testo a coordinate...

        tMedia = """<font size="12">
		<b>Temperatura media</b></font>
		"""                  # paragrafo di testo
        self.createParagraph(tMedia, 18, voffset + 25)  # creazione paragrafo
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresTMED, "%d" % (percTMED) + "%"]]  # dati per tabella
        table = Table(data, colWidths=2 * inch)  # inizializzazione tabella
        table.setStyle([("VALIGN", (-1, -1), (-1, -1), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)
                        ])  # stile tabella
        table.wrapOn(self.c, self.width,
                     self.height)  # importazione nel foglio della tabella
        table.drawOn(self.c,
                     *self.coord(18, 105,
                                 mm))  # disegno della tabella a coordinate...

        umid = """<font size="12">
		<b>Umidità</b></font>
		"""
        self.createParagraph(umid, 18, voffset + 50)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresUMID, "%d" % (percUMID) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 130, mm))

        piogg = """<font size="12">
		<b>Pioggia</b></font>
		"""
        self.createParagraph(piogg, 18, voffset + 75)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresPG, "%d" % (percPG) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 155, mm))

        bagnFogl = """<font size="12">
		<b>Bagnatura fogliare</b></font>
		"""
        self.createParagraph(bagnFogl, 18, voffset + 100)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresFB, "%d" % (percFB) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 180, mm))

        velVento = """<font size="12">
		<b>Velocità vento</b></font>
		"""
        self.createParagraph(velVento, 18, voffset + 125)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresVenVel,
            "%d" % (percVenVel) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 205, mm))

        radSolare = """<font size="12">
		<b>Radiazione solare</b></font>
		"""
        self.createParagraph(radSolare, 18, voffset + 150)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresRAD, "%d" % (percRAD) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 230, mm))

        self.c.showPage()  # per iniziare una nuova pagina

        self.drawing = Drawing(200, 400)  # disegna figura vuota
        self.drawing.rotate(-90)  # ruota figura vuota
        self.data = [(percRAD, percVenVel, percFB, percPG, percUMID, percTMED)
                     ]  #dati per il grafico
        self.names = [
            "Radiazione solare", "Velocità vento", "Bagnatura fogliare",
            "Pioggia", "Umidità", "Temperatura media"
        ]  #nomi per grafico
        self.bc = HorizontalBarChart()  # inizializzazione grafico orizzontale
        self.bc.x = 20  # x del grafico
        self.bc.y = 50  # y del grafico
        self.bc.height = 400  # altezza del grafico
        self.bc.width = 600  # larghezza grafico
        self.bc.data = self.data  # dati del grafico sono uguali a data
        self.bc.strokeColor = colors.white  # colore del grafico
        self.bc.valueAxis.valueMin = 0  # valore minimo asse
        self.bc.valueAxis.valueMax = 100  # valore massimo asse
        self.bc.valueAxis.valueStep = 5  # step di 5 dell'asse
        self.bc.categoryAxis.labels.boxAnchor = 'ne'  # non importante
        self.bc.categoryAxis.labels.dx = -10  # etichettatura grafico
        self.bc.categoryAxis.labels.fontName = 'Helvetica'  # font garfico
        self.bc.categoryAxis.categoryNames = self.names  # asse dei nomi, quello sotto
        self.drawing.add(self.bc)  # aggiunta del grafico alla figura vuota
        renderPDF.draw(self.drawing, self.c, 40,
                       700)  # disegmo del grafico sul pdf

        self.d = Drawing(0, 0)
        self.d.rotate(-90)
        self.c.rotate(-90)
        self.c.setFont('Helvetica', 30)
        self.cb = self.c.drawString(
            -600, 525, "Percentuale di funzionamento"
        )  # creazione titolo per grafico ruotato di -90 gradi
        self.d.add(
            self.cb
        )  # la x è negativa perchè anche le coordinate cambiano in base al punto di orgine
        renderPDF.draw(self.d, self.c, 100, 100)
    #aqui ens cal fer una iteració......
    for j in range(1, dfa_col_ini):
        text5 = '<font size=11><center><p>><em> {}. {}</em> <strong> <b>{}</b> </strong></p></center></font>'.format(
            j, df_ab.columns[j], row[j])  #titol i valo de la fila que mira
        Story.append(Paragraph(text5, styles["justificat"]))
        Story.append(Spacer(0, 0))
    Story.append(Spacer(0, 15))

    text5 = '<font size=11> Els resultats dels continguts treballats es poden \
    endreçar en Competències i Dimensions d\'acord amb els següents resultats.</font>'

    Story.append(Paragraph(text5, styles["justificat"]))
    Story.append(Spacer(0, 75))

    grafic = Drawing(300, 150)
    bc = HorizontalBarChart()

    dades_dibuix = [[
        int(round(row[10])),
        int(round(row[11])),
        int(round(row[12])),
        int(round(row[13])),
        int(round(row[14])),
        int(round(row[15])),
        int(round(row[16])),
        int(round(row[17])),
        int(round(row[18])),
        int(round(row[19])),
        int(round(row[20])),
        int(round(row[21]))
    ]]
Exemple #26
0
 def categoryVvalueChart(self,
                         chapter,
                         ordinateValues,
                         abscissaCategories,
                         chartType='HorizontalBarChart',
                         markerType=None,
                         gridlinesX=False,
                         gridlinesY=True,
                         ordinateTics=10,
                         bIncludeZero=True,
                         ordinateFmtType='%0.3f',
                         chartIdx=0,
                         pageHfraction=1.0,
                         chartX=None,
                         chartY=None,
                         chartH=None,
                         chartW=None,
                         title="",
                         captionLabel="",
                         caption="",
                         fontname='',
                         fontsize='',
                         fontcolor=''):
     abscissaCategories, title, captionLabel, caption = GetUnicode(
         [abscissaCategories, title, captionLabel, caption])
     ##testing
     #from numpy import randn,histogram
     #mu,sigma = 100,15
     #x = list(mu + sigma*randn(10000))
     #ordinateTics=10
     #ordinateValues,abscissaCategories = histogram(x,100,normed=True)
     #ordinateValues,abscissaCategories = [list(ordinateValues)],list(abscissaCategories)
     #for idx in xrange(len(abscissaCategories)):
     #    if idx%5: abscissaCategories[idx]=''
     #    else: abscissaCategories[idx]='%.2f'%abscissaCategories[idx]
     ##print abscissaCategories[:10],abscissaCategories[-10:]
     ##testing
     # if no X/Y & H/W scaling specified, set to fill up page within margins
     if chartType in ("HorizontalBarChart", "HorizontalLineChart",
                      "VerticalBarChart"):  # note: no "VerticalLineChart"
         pageWidth, pageHeight = self.pagesize  # in points
         nLeft, nBottom, nRight, nTop = [
             val * inch
             for val in self.nLeft, self.nBottom, self.nRight, self.nTop
         ]  # inches to points
         availH, availW = pageHfraction * (
             pageHeight - (nTop + nBottom)), pageWidth - (nLeft + nRight)
         pgMinDim, pgMaxDim = min(pageWidth / inch, pageHeight / inch), max(
             pageWidth / inch, pageHeight / inch)  # inches
         nGutter = min(
             pgMinDim / 17., pgMaxDim / 22.
         ) * inch  # 0.5" nominal gutter based on 8.5" x 11" paper size
         # todo: QC size (e.g., >0)
         if chartX == None or chartY == None or chartH == None or chartW == None:
             chartX, chartY, chartH, chartW, drawH, drawW = nGutter, nGutter, availH - 3 * nGutter, availW - 1.25 * nGutter, availH - 1.5 * nGutter, availW - 0.5 * nGutter
         else:
             chartX, chartY, chartH, chartW = [
                 val * inch for val in chartX, chartY, chartH, chartW
             ]
             drawH, drawW = chartH + 1.5 * nGutter, chartW + 0.75 * nGutter
         bIsHorizontal, bIsBarChart = chartType.find(
             'Horizontal') == 0, chartType.find('BarChart') > 0
         if bIsHorizontal:
             if bIsBarChart:
                 bXisValueYisCategory, bXisCategoryYisValue = True, False
                 gridlinesX, gridlinesY = gridlinesY, gridlinesX
                 chartObj = HorizontalBarChart()
                 for dataSeries in ordinateValues:
                     dataSeries.reverse()
                 ordinateValues.reverse()
                 abscissaCategories.reverse()
             else:  # note: HorizontalLineChart has same aspect as VerticalBarChart
                 bXisValueYisCategory, bXisCategoryYisValue = False, True
                 chartObj = HorizontalLineChart()
         else:  # note: only vertical chart possible is barchart
             bXisValueYisCategory, bXisCategoryYisValue = False, True
             chartObj = VerticalBarChart()
         if bXisValueYisCategory:
             labelsAngle, labelsAnchor, labelsDX, labelsDY = 0, 'e', -max(
                 [len(val) for val in abscissaCategories]), 0
             if gridlinesX:
                 chartObj.valueAxis.tickUp = chartH
             if gridlinesY:
                 chartObj.categoryAxis.tickRight = chartW
         else:  # bXisCategoryYisValue
             labelsAngle, labelsAnchor, labelsDX, labelsDY = 30, 'ne', 0, 0
             if gridlinesX:
                 chartObj.categoryAxis.tickUp = chartH
             if gridlinesY:
                 chartObj.valueAxis.tickRight = chartW
         colorPalette = [
             colors.lightcoral, colors.cornflower, colors.darkseagreen,
             colors.tan, colors.aquamarine, colors.lightsteelblue,
             colors.cadetblue, colors.thistle, colors.steelblue
         ]
         if bIsBarChart:
             chartObj.bars[0].fillColor = colorPalette[chartIdx % len(
                 colorPalette
             )]  # todo: bars[0],[1],... if ordinateValues a list of lists (stacked bars)
         else:
             chartObj.joinedLines = 1
             chartObj.lines[
                 0].strokeWidth = 2  # todo: lines[0],[1],... if ordinateValues a list of lists (multiple lines)
             chartObj.lines[0].strokeColor = colorPalette[
                 chartIdx % len(colorPalette)]  # ibid.
             #todo: chartObj.lines[0].symbol = makeMarker('FilledCircle') # or 'Circle', others?
             if markerType:
                 chartObj.lines[0].symbol = makeMarker(markerType)
         chartObj.data = ordinateValues
         chartObj.x, chartObj.y = chartX, chartY
         chartObj.height, chartObj.width = chartH, chartW
         ordinateMin = min([
             min(ordinateValuesSet) for ordinateValuesSet in ordinateValues
         ])
         ordinateMax = max([
             max(ordinateValuesSet) for ordinateValuesSet in ordinateValues
         ])
         if bIncludeZero:
             ordinateMin = min(0, ordinateMin)
             ordinateMax = max(0, ordinateMax)
         # evaluate ordinate range in graph string-label space and adjust ordinate[Min,Max,Step] accordingly
         ordinateMinGstr, ordinateMaxGstr = [
             ordinateGstr.replace('%', '').split()[0]
             for ordinateGstr in (ordinateFmtType % ordinateMin,
                                  ordinateFmtType % ordinateMax)
         ]
         ordinateMinG, ordinateMaxG = float(ordinateMaxGstr), float(
             ordinateMinGstr)
         bAdjustMinMax = True
         if ordinateMinG == ordinateMaxG:
             # if constant y-value graph, set range to span from zero (regardless of bIncludeZero)
             bAdjustMinMax = False
             if ordinateMinG != 0.:  # y-values!=0
                 if ordinateMax > 0: ordinateMin = 0
                 else: ordinateMax = 0
             else:  # y-values==0, set range to [0,1]
                 ordinateMin, ordinateMax = 0, 1.
             ordinateMinG, ordinateMaxG = ordinateMin, ordinateMax
             ordinateTics = 2
         #  determine smallest significant ordinateStep, per desired ordinateTicSize--using stepwise reduction down to 1
         for ordinateTicSize in range(ordinateTics, 1, -1):
             ordinateStep = abs(
                 (ordinateMaxG - ordinateMinG) / ordinateTicSize)
             ordinateStepGstr = ordinateFmtType % ordinateStep
             ordinateStepGstr = ordinateStepGstr.replace('%', '').split()[0]
             ordinateStepG = float(ordinateStepGstr)
             if ordinateStepG != 0:
                 ordinateStep = ordinateStepG
                 break
         if bAdjustMinMax:
             if ordinateMin != 0:  # extend y-axis on low side...
                 ordinateMin -= ordinateStep
             if ordinateMax != 0:  # then extend y-axis on high side, but don't exceed 100%...
                 try:
                     if (ordinateMax + ordinateStep
                         ) >= 100 and ordinateFmtType[-1] == '%':
                         ordinateMax = 100.
                     else:
                         ordinateMax += ordinateStep
                 except:  # ostensibly b/c invalid ordinateFmtType
                     ordinateMax += ordinateStep
         chartObj.valueAxis.valueMin, chartObj.valueAxis.valueMax, chartObj.valueAxis.valueStep = ordinateMin, ordinateMax, ordinateStep
         chartObj.valueAxis.labelTextFormat = ordinateFmtType
         chartObj.categoryAxis.labels.boxAnchor = labelsAnchor
         chartObj.categoryAxis.labels.dx, chartObj.categoryAxis.labels.dy = labelsDX, labelsDY
         chartObj.categoryAxis.labels.angle = labelsAngle
         chartObj.categoryAxis.categoryNames = abscissaCategories
         chartObjDrawing = Drawing(drawW, drawH)
         chartObjDrawing.add(chartObj)
         if title:
             self.CPage(
                 chapter, 0.5 + drawH / inch
             )  # todo: had to hack this b/c [start,end]Keep not working
             self.clabel2(chapter, title, fontname, fontsize, fontcolor)
         self.report[chapter].append(chartObjDrawing)
         if captionLabel or caption:
             self.report[chapter].append(
                 self.aTextFlowable('<b>%s</b> %s' %
                                    (captionLabel, caption),
                                    fontname=fontname,
                                    fontsize=fontsize,
                                    fontcolor=fontcolor))