Esempio n. 1
0
def teamcomparison_chart_get(logger, ctitle, csubtitle, ismobile, data_dic):
    """ team comparison heatmap chart """
    logger.debug('teamcomparison_chart_get()')

    variable_dic = variables_get(ismobile)

    chart_options = {

        'chart': {
            'type': 'heatmap',
            'height': '110%',
            'inverted': 1,
            'style': chartstyle()
        },

        'exporting': exporting(filename=ctitle, allowhtml=0),
        'title': title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle': subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits': credit(),

        'xAxis': {
            'categories': data_dic['x_category'],
            'type': 'category',
            'labels': {'useHTML': 1, 'align': 'center'}
        },

        'yAxis': {
            'categories': data_dic['y_category'],
            'title': '',
            'opposite':1,
        },

        'tooltip': {
            'headerFormat': '',
            'pointFormat': '<b>{point.y_name}</b>: {point.ovalue}',
            'split': 1,
        },

        'legend': {
            'align': 'center',
            'layout': 'horizontal',
            'verticalAlign': 'bottom',
            'useHTML': 0,
            'itemStyle': {'color': text_color, 'font-size': font_size},
        },

        'colorAxis': color_axis(showinlegend=0),

        'series': [{
            'marker': {'symbol': 'square'},
            'borderWidth': variable_dic['border_width'],
            'borderColor': '#ffffff',
            'data': data_dic['data'],
            'showInLegend': 0,
            'dataLabels': {'enabled': 0}
        }],
    }

    return chart_options
Esempio n. 2
0
def faceoff_overview_chart(logger, ctitle, ismobile, data_dic):
    """ create chart 5v5 pace """
    # pylint: disable=E0602
    logger.debug('faceoff_overview_chart()')

    variable_dic = variables_get(ismobile)

    chart_options = {

        'chart': {
            'type': 'scatter',
            'height': '80%',
            'style': chartstyle()
        },

        'exporting': exporting(filename=ctitle),
        'title': title(ctitle, variable_dic['title_size'], decoration=True),
        'credits': credit(),
        'legend': legend(enabled=1),
        'responsive': responsive_y1(),

        'tooltip': {
            'useHTML': 1,
            'headerFormat': '',
            'pointFormat': '<span><b>{point.team_name}</b></span></br><span style="font-size: %s">%s: {point.sum_faceoffswon}</span><br><span style="font-size: %s">%s: {point.sum_faceoffslost}</span><br/><span style="font-size: %s">%s: {point.y}</span><br/>' % (font_size, _('Faceoffs won'), font_size, _('Faceoffs lost'), font_size, _('Faceoffs win percentage'))
        },

        'xAxis': {
            'labels': {
                'enabled': 0
            },
            'tickInterval': 0,
        },

        'yAxis': {
            'title': title(ctitle, font_size),
            # 'tickInterval': 1,
            'maxPadding': 0.1,
            'min': data_dic['y_min_minmax'] - 2,
            'max': data_dic['y_max_minmax'] + 2,
            'labels': {'style': {'fontSize': font_size},},
            'gridLineWidth': 1,
            'plotBands': [{'from': data_dic['y_avg'] - data_dic['y_deviation']/2, 'to': data_dic['y_avg'] + data_dic['y_deviation']/2, 'color': chart_color6}],
            'plotLines': [{'zIndex': 3, 'color': plotlines_color, 'width': 2, 'value': data_dic['y_avg']}],
        },

        'series': [{'zIndex': 1, 'name': _('Standard Deviation'), 'color': plotlines_color, 'data': data_dic['data']}]

    }

    return chart_options
Esempio n. 3
0
def pppk_chart_get(logger, ctitle, csubtitle, ismobile, pppk_data):
    # pylint: disable=E0602
    """ pdo breakdown """
    logger.debug('pdo_breakdown_chart()')

    variable_dic = variables_get(ismobile)

    # dirty hack
    if pppk_data['x_min'] == 0:
        pppk_data['x_min'] = 1
    if pppk_data['y_min'] == 0:
        pppk_data['y_min'] = 1
    if pppk_data['x_max'] == 100:
        pppk_data['x_max'] = 99
    if pppk_data['y_max'] == 100:
        pppk_data['y_max'] = 99

    minmax_dic = {
        'x_min': pppk_data['x_min'] - 1,
        'y_min': pppk_data['y_min'] - 1,
        'x_max': pppk_data['x_max'] + 1,
        'y_max': pppk_data['y_max'] + 1
    }

    chart_options = {
        'chart': {
            'type': 'scatter',
            'height': '120%',
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend': {
            'enabled': 1
        },
        'responsive':
        responsive_y1(),
        'tooltip': {
            'useHTML':
            1,
            'headerFormat':
            '',
            'pointFormat':
            '<span><b>{point.team_name}</b></span></br><span style="font-size: %s">%s: {point.x}%s</span><br><span style="font-size: %s">%s: {point.y}%s</span><br/>'
            % (font_size, _('Shooting percentage (Sh%)'), '%', font_size,
               _('Save percentage (Sv%)'), '%s')
        },
        'xAxis': {
            'title':
            title(_('Powerplay percentage (Pp%)'), font_size),
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'min':
            minmax_dic['x_min'],
            'max':
            minmax_dic['x_max'],
            'tickInterval':
            1,
            'showFirstLabel':
            1,
            'showLastLabel':
            1,
            'gridLineWidth':
            1,
            'plotBands': [{
                'from':
                pppk_data['x_avg'] - pppk_data['x_deviation'] / 2,
                'to':
                pppk_data['x_avg'] + pppk_data['x_deviation'] / 2,
                'color':
                chart_color6
            }],
            'plotLines': [{
                'zIndex': 3,
                'color': plotlines_color,
                'width': 2,
                'value': pppk_data['x_avg']
            }],
        },
        'yAxis': {
            'title':
            title(_('Penalty Kill percentage (Pk%)'), font_size),
            'maxPadding':
            0.1,
            'min':
            minmax_dic['y_min'],
            'max':
            minmax_dic['y_max'],
            'tickInterval':
            1,
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'gridLineWidth':
            1,
            'plotBands': [{
                'from':
                pppk_data['y_avg'] - pppk_data['y_deviation'] / 2,
                'to':
                pppk_data['y_avg'] + pppk_data['y_deviation'] / 2,
                'color':
                chart_color6
            }],
            'plotLines': [{
                'zIndex': 3,
                'color': plotlines_color,
                'width': 2,
                'value': pppk_data['y_avg']
            }],
        },
        'series': [{
            'zIndex': 1,
            'name': _('Standard Deviation'),
            'color': plotlines_color,
            'marker': {
                'symbol': 'square'
            },
            'data': pppk_data['data']
        }],
        'annotations':
        corner_annotations(ismobile, minmax_dic, _('Defensive'),
                           _('Overstrained'), _('Agressive'), _('Offensive')),
    }
    return chart_options
Esempio n. 4
0
def scoreenchart_get(logger, ctitle, csubtitle, ismobile, data_dic):
    # pylint: disable=E0602, R0914
    """ create time-on-ice chart """
    logger.debug('gametoichart_create()')

    variable_dic = variables_get(ismobile)

    chart_options = {
        'chart': {
            'type': 'column',
            'height': '80%',
            'alignTicks': 0,
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend':
        legend(),
        'responsive':
        responsive_y1(),
        'tooltip': {
            'sharted':
            1,
            'useHTML':
            1,
            'headerFormat':
            '',
            'pointFormat':
            '<span> <b>{point.team_name}</b></span></br><span style="font-size: %s">%s: {point.goalie_other_pull}</span><br><span style="font-size: %s">%s: {point.goals_en_for}</span><br/><span style="font-size: %s">%s: {point.goals_en_for_pctg}%s </span><br/>'
            % (font_size, _('Empty net changes'), font_size,
               _('Empty net goals'), font_size, _('Scoring percentage'), '%')
        },
        'plotOptions': {
            'series': {
                'states': {
                    'inactive': {
                        'opacity': 1
                    }
                },
                'dataLabels': {
                    'enabled': 1,
                    'style': {
                        'fontSize': font_size,
                        'textOutline': 0,
                        'color': '#000000',
                        'fontWeight': 0
                    },
                }
            }
        },
        'xAxis': {
            'categories': data_dic['team_list'],
            'title': title('', font_size),
            'labels': {
                'useHTML': 1,
                'align': 'center'
            },
            # 'labels': {'style': {'fontSize': font_size}},
        },
        'yAxis': [{
            # pylint: disable=E0602
            'title':
            title('', font_size),
            'reversedStacks':
            0,
            'labels': {
                'enabled': 1,
                'style': {
                    'fontSize': font_size
                }
            },
            'min':
            0,
            'plotLines': [{
                'color': plotlines_color,
                'width': 2,
                'value': 100
            }],
        }],
        'series': [
            # pylint: disable=E0602
            {
                'name': _('Empty net changes'),
                'data': data_dic['goalie_other_pull_list'],
                'color': chart_color2
            },
            {
                'name': _('Empty net goals'),
                'data': data_dic['goals_en_list'],
                'color': chart_color3
            },
        ]
    }

    return chart_options
Esempio n. 5
0
def goaliepullchart_get(logger, ctitle, csubtitle, ismobile, data_dic):
    # pylint: disable=E0602, R0914
    """ create time-on-ice chart """
    logger.debug('gametoichart_create()')

    variable_dic = variables_get(ismobile)

    chart_options = {
        'chart': {
            'type': 'column',
            'height': '80%',
            'alignTicks': 0,
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend':
        legend(),
        'responsive':
        responsive_y1_nolabel(),
        'tooltip': {
            'sharted':
            1,
            'useHTML':
            1,
            'headerFormat':
            '',
            'pointFormat':
            '<span><b>{point.team_name}</b></span></br><span style="font-size: %s">%s: {point.goalie_own_pull}</span><br><span style="font-size: %s">%s: {point.goals_wogoalie_for}</span><br/><span style="font-size: %s">%s: {point.goals_en_against}</span><br/>'
            % (font_size, _('Goalie pulls'), font_size,
               _('Goals after pulling goalie'), font_size,
               _('Empty net goals taken'))
        },
        'plotOptions': {
            'series': {
                'states': {
                    'inactive': {
                        'opacity': 1
                    }
                },
                'stacking': 'normal',
                'dataLabels': {
                    'enabled': 1,
                    'inside': 1,
                    'style': {
                        'fontSize': font_size,
                        'textOutline': 0,
                        'color': '#ffffff',
                        'fontWeight': 0
                    },
                    'format': '{point.label}'
                }
            }
        },
        'xAxis': {
            'categories': data_dic['team_list'],
            'title': title('', font_size),
            'labels': {
                'useHTML': 1,
                'align': 'center'
            },
            # 'labels': {'style': {'fontSize': font_size}},
        },
        'yAxis': {
            # pylint: disable=E0602
            'title': title('', font_size),
            'reversedStacks': 0,
            'tickInterval': 1,
            'labels': {
                'enabled': 0,
                'style': {
                    'fontSize': font_size
                }
            },
            'plotLines': [{
                'color': plotlines_color,
                'width': 2,
                'value': 100
            }],
        },
        'series': [
            # pylint: disable=E0602
            {
                'name': _('Goals after pulling goalie'),
                'marker': {
                    'symbol': 'square'
                },
                'data': data_dic['goals_wogoalie_for_list'],
                'color': chart_color3
            },
            {
                'name': _('Emptynet goals taken'),
                'marker': {
                    'symbol': 'square'
                },
                'data': data_dic['goals_en_against_list'],
                'color': chart_color1
            },
        ]
    }

    return chart_options
Esempio n. 6
0
def discipline_chart_get(logger, ctitle, csubtitle, ismobile, pppk_data):
    # pylint: disable=E0602
    """ pdo breakdown """
    logger.debug('discipline_chart_get()')

    variable_dic = variables_get(ismobile)

    # dirty hack
    if pppk_data['x_min'] == 0:
        pppk_data['x_min'] = 1
    if pppk_data['y_min'] == 0:
        pppk_data['y_min'] = 1
    if pppk_data['x_max'] == 100:
        pppk_data['x_max'] = 99
    if pppk_data['y_max'] == 100:
        pppk_data['y_max'] = 99

    minmax_dic = {
        'x_min': pppk_data['x_min'] - 0.2,
        'y_min': pppk_data['y_min'] - 0.2,
        'x_max': pppk_data['x_max'] + 0.2,
        'y_max': pppk_data['y_max'] + 0.2
    }

    chart_options = {
        'chart': {
            'type': 'scatter',
            'height': '110%',
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend': {
            'enabled': 1
        },
        'responsive':
        responsive_y1(),
        'tooltip': {
            'useHTML':
            1,
            'headerFormat':
            '',
            'pointFormat':
            '<span><b>{point.team_name}</b></span></br><span style="font-size: %s">%s: {point.penaltyminutes_drawn}min</span><br><span style="font-size: %s">%s: {point.penaltyminutes_taken}min</span><br/>'
            % (font_size, _('Penaltyminutes drawn'), font_size,
               _('Penaltyminutes taken'))
        },
        'xAxis': {
            'title':
            title(_('Penaltyminutes drawn (avg per game)'), font_size),
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'min':
            minmax_dic['x_min'],
            'max':
            minmax_dic['x_max'],
            'tickInterval':
            0.5,
            'showFirstLabel':
            1,
            'showLastLabel':
            1,
            'gridLineWidth':
            1,
            'plotBands': [{
                'from':
                pppk_data['x_avg'] - pppk_data['x_deviation'] / 2,
                'to':
                pppk_data['x_avg'] + pppk_data['x_deviation'] / 2,
                'color':
                chart_color6
            }],
            'plotLines': [{
                'zIndex': 3,
                'color': plotlines_color,
                'width': 2,
                'value': pppk_data['x_avg']
            }],
        },
        'yAxis': {
            'title':
            title(_('Penaltyminutes taken (avg per game)'), font_size),
            'maxPadding':
            0.1,
            'min':
            minmax_dic['y_min'],
            'max':
            minmax_dic['y_max'],
            'tickInterval':
            0.5,
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'gridLineWidth':
            1,
            'plotBands': [{
                'from':
                pppk_data['y_avg'] - pppk_data['x_deviation'] / 2,
                'to':
                pppk_data['y_avg'] + pppk_data['x_deviation'] / 2,
                'color':
                chart_color6
            }],
            'plotLines': [{
                'zIndex': 3,
                'color': plotlines_color,
                'width': 2,
                'value': pppk_data['y_avg']
            }],
        },
        'series': [{
            'zIndex': 1,
            'name': _('Standard Deviation'),
            'color': plotlines_color,
            'marker': {
                'symbol': 'square'
            },
            'data': pppk_data['data']
        }],
        'annotations':
        corner_annotations(ismobile, minmax_dic, _('Undisciplined'),
                           _('Friendly'), _('Chippy'), _('Disciplined'), 1)
    }
    return chart_options
Esempio n. 7
0
def xgfa_chart_get(logger, ctitle, csubtitle, ismobile, xgfa_data):
    # pylint: disable=E0602
    """ pdo breakdown """
    logger.debug('pdo_breakdown_chart()')

    variable_dic = variables_get(ismobile)

    # dirty hack
    if xgfa_data['x_min'] == 0:
        xgfa_data['x_min'] = 1
    if xgfa_data['y_min'] == 0:
        xgfa_data['y_min'] = 1

    minmax_dic = {
        'x_min': xgfa_data['x_min'] - 0.2,
        'y_min': xgfa_data['y_min'] - 0.2,
        'x_max': xgfa_data['x_max'] + 0.2,
        'y_max': xgfa_data['y_max'] + 0.2
    }

    chart_options = {
        'chart': {
            'type': 'scatter',
            'height': '100%',
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend': {
            'enabled': 1
        },
        'responsive':
        responsive_y1(),
        'tooltip': {
            'useHTML':
            1,
            'headerFormat':
            '',
            'pointFormat':
            '<span><b>{point.team_name}</b></span></br><span style="font-size: %s">%s: {point.x}</span><br><span style="font-size: %s">%s: {point.y}</span><br/>'
            % (font_size, _('xGF60'), font_size, _('xGA60'))
        },
        'xAxis': {
            'title':
            title(_('Expected Goals "For" per 60min (xGF60)'), font_size),
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'min':
            minmax_dic['x_min'],
            'max':
            minmax_dic['x_max'],
            'tickInterval':
            0.25,
            'showFirstLabel':
            1,
            'showLastLabel':
            1,
            'gridLineWidth':
            1,
            'plotBands': [{
                'from':
                xgfa_data['x_avg'] - xgfa_data['x_deviation'] / 2,
                'to':
                xgfa_data['x_avg'] + xgfa_data['x_deviation'] / 2,
                'color':
                chart_color6
            }],
            'plotLines': [{
                'zIndex': 3,
                'color': plotlines_color,
                'width': 2,
                'value': xgfa_data['x_avg']
            }],
        },
        'yAxis': {
            'title':
            title(_('Expected Goals "Against" per 60min (xGA60)'), font_size),
            'maxPadding':
            0.1,
            'min':
            minmax_dic['y_min'],
            'max':
            minmax_dic['y_max'],
            'tickInterval':
            0.25,
            'reversed':
            1,
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'gridLineWidth':
            1,
            'plotBands': [{
                'from':
                xgfa_data['y_avg'] - xgfa_data['y_deviation'] / 2,
                'to':
                xgfa_data['y_avg'] + xgfa_data['y_deviation'] / 2,
                'color':
                chart_color6
            }],
            'plotLines': [{
                'zIndex': 3,
                'color': plotlines_color,
                'width': 2,
                'value': xgfa_data['y_avg']
            }],
        },
        'series': [{
            'zIndex': 1,
            'name': _('Standard Deviation'),
            'color': plotlines_color,
            'marker': {
                'symbol': 'square'
            },
            'data': xgfa_data['data']
        }],
        'annotations':
        corner_annotations(ismobile, minmax_dic, _('Headless'), _('Boring'),
                           _('Exciting'), _('Coolly')),
    }
    return chart_options
Esempio n. 8
0
def dgf_chart_get(logger, ctitle, csubtitle, ismobile, data_dic):
    # pylint: disable=E0602
    """ pdo overview """
    logger.debug('pdo_overview_chart()')

    variable_dic = variables_get(ismobile)

    if ismobile:
        chart_height = '100%'
        legent_title_size = font_size_mobile
    else:
        chart_height = '80%'
        legent_title_size = font_size

    chart_options = {
        'chart': {
            'type': 'column',
            'height': chart_height,
            'alignTicks': 0,
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend':
        legend(1, {
            'title': {
                'text': 'GF%',
                'style': {
                    'fontSize': legent_title_size
                }
            }
        }),
        'responsive':
        responsive_y1(),
        'tooltip': {
            'useHTML':
            1,
            'headerFormat':
            '',
            'pointFormat':
            '<span><b>{point.shortcut}</b></span></br><span style="font-size: %s">%s: {point.gf_pctg}</span><br><span style="font-size: %s">%s: {point.y}</span><br/>'
            % (font_size, _('GF%'), font_size, _('dGF%'))
        },
        'plotOptions': {
            'series': {
                'dataLabels': {
                    'enabled': 1,
                    'useHTML': 0,
                    'style': {
                        'fontSize': font_size,
                        'textOutline': 0,
                        'color': '#ffffff',
                        'fontWeight': 0
                    }
                }
            }
        },
        'xAxis': {
            'categories': data_dic['data']['team_list'],
            'title': title('', font_size),
            'labels': {
                'useHTML': 1,
                'align': 'center'
            },
        },
        'colorAxis':
        color_axis(showinlegend=1, minimum=data_dic['gf_5v5_pctg_min']),
        'yAxis': {
            # pylint: disable=E0602
            'title': title(_('Difference of GF% and xGF% (dGF%)'), font_size),
            'labels': {
                'style': {
                    'fontSize': font_size
                }
            },
            'plotLines': [{
                'color': plotlines_color,
                'width': 2,
                'value': 100
            }],
        },
        'series': [
            # pylint: disable=E0602
            {
                'name': _('dGF%'),
                'marker': {
                    'symbol': 'square'
                },
                'data': data_dic['data']['dgf_list']
            },
        ]
    }

    return chart_options
Esempio n. 9
0
def gfxgf_chart_get(logger, ctitle, csubtitle, ismobile, gfxgf_data):
    # pylint: disable=E0602
    """ pdo breakdown """
    logger.debug('pdo_breakdown_chart()')

    variable_dic = variables_get(ismobile)

    # dirty hack
    if gfxgf_data['x_min'] == 0:
        gfxgf_data['x_min'] = 1
    if gfxgf_data['y_min'] == 0:
        gfxgf_data['y_min'] = 1
    if gfxgf_data['x_max'] == 100:
        gfxgf_data['x_max'] = 99
    if gfxgf_data['y_max'] == 100:
        gfxgf_data['y_max'] = 99

    minmax_dic = {
        'x_min': int(round(gfxgf_data['x_min'], 0)) - 5,
        'y_min': int(round(gfxgf_data['y_min'], 0)) - 2.5,
        'x_max': int(round(gfxgf_data['x_max'], 0)) + 5,
        'y_max': int(round(gfxgf_data['y_max'], 0)) + 5,
    }

    chart_options = {
        'chart': {
            'type': 'scatter',
            'height': '110%',
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend': {
            'enabled': 1
        },
        'responsive':
        responsive_y1(),
        'tooltip': {
            'useHTML':
            1,
            'headerFormat':
            '',
            'pointFormat':
            '<span><b>{point.team_name}</b></span></br><span style="font-size: %s">%s: {point.x}</span><br><span style="font-size: %s">%s: {point.y}</span><br/>'
            % (font_size, _('GF%'), font_size, _('xGF%'))
        },
        'xAxis': {
            'title':
            title(_('Goals percentage on 5v5 (Gf%)'), font_size),
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'min':
            minmax_dic['x_min'],
            'max':
            minmax_dic['x_max'],
            #'tickInterval': 2,
            'showFirstLabel':
            1,
            'showLastLabel':
            1,
            'gridLineWidth':
            1,
            'plotBands': [{
                'from':
                gfxgf_data['x_avg'] - gfxgf_data['x_deviation'] / 2,
                'to':
                gfxgf_data['x_avg'] + gfxgf_data['x_deviation'] / 2,
                'color':
                chart_color6
            }],
            'plotLines': [{
                'zIndex': 3,
                'color': plotlines_color,
                'width': 2,
                'value': gfxgf_data['x_avg']
            }],
        },
        'yAxis': {
            'title':
            title(_('expected Goals percentage on 5v5 (xGf%)'), font_size),
            'maxPadding':
            0.1,
            'min':
            minmax_dic['y_min'],
            'max':
            minmax_dic['y_max'],
            #'tickInterval': 2,
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'gridLineWidth':
            1,
            'plotBands': [{
                'from':
                gfxgf_data['y_avg'] - gfxgf_data['y_deviation'] / 2,
                'to':
                gfxgf_data['y_avg'] + gfxgf_data['y_deviation'] / 2,
                'color':
                chart_color6
            }],
            'plotLines': [{
                'zIndex': 3,
                'color': plotlines_color,
                'width': 2,
                'value': gfxgf_data['y_avg']
            }],
        },
        'series': [{
            'zIndex': 1,
            'name': _('Standard Deviation'),
            'color': plotlines_color,
            'marker': {
                'symbol': 'square'
            },
            'data': gfxgf_data['data']
        }],
        'annotations':
        corner_annotations(ismobile, minmax_dic, _('Underperforming'),
                           _('Bad'), _('Good'), _('Overperforming')),
    }
    return chart_options
def chatterchart_create(logger, ctitle, csubtitle, ismobile, events_dic,
                        plotband_list):
    """ create chatter chart """
    logger.debug('chatterchart_create()')

    variable_dic = variables_get(ismobile)

    data_list = []
    x_list = []

    cnt = 0
    for _uts, event in sorted(events_dic.items()):

        # we need to count the amount of tweets to calculate the chartsize
        cnt += 1

        # on the fly timestamp for x-axis
        timestamp = uts_to_date_utc(date_to_uts_utc(event['created_at']),
                                    '%H:%M')

        if 'text_raw' in event:
            timestamp = uts_to_date_utc(
                int(date_to_uts_utc(event['created_at']) + 3600), '%H:%M')
            # this is a regular event
            text_shorten = textwrap.shorten(
                event['text_raw'], variable_dic['timeline_wrap_length'])
            data_list.append({
                'x': cnt,
                'name': timestamp,
                'aname': '@{0}'.format(event['name_alternate']),
                'scolor': twitter_color,
                'label': text_shorten,
                'description': event['text_raw'],
                'dataLabels': {
                    'style': {
                        'fontSize': variable_dic['timeline_font_size']
                    }
                }
            })
        else:
            # this is a goal
            data_list.append({
                'x': cnt,
                'name': timestamp,
                'aname': '#bot1337',
                'scolor': chart_color3,
                'color': event['color'],
                'label': event['name_alternate'],
                'dataLabels': {
                    'color': event['color'],
                    'style': {
                        'fontSize': variable_dic['timeline_font_size'],
                        'fontWeight': 'bold'
                    }
                }
            })

        x_list.append({'x': cnt, 'name': timestamp})

    # charthight depends on number of tweets - need to be calculated
    chart_height = variable_dic['ticker_startval'] + (
        cnt * variable_dic['ticker_multiplier'])

    chart_options = {
        'chart': {
            'type': 'timeline',
            'height': '{0}%'.format(chart_height),
            'inverted': 1,
            'zoomType': 'x',
            #'alignTicks': 0,
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'plotOptions': {
            'timeline': {
                'dataLabels': {
                    'align': 'left',
                    'distance': variable_dic['timeline_distance'],
                    'alternate': 0
                }
            }
        },
        'tooltip': {
            'useHTML':
            1,
            'headerFormat':
            '',
            'pointFormat':
            '<span style="color: {point.scolor}"><b>{point.aname}</b></span><br>{point.description}',
        },
        'xAxis': {
            'categories': x_list,
            'visible': 1,
            'tickWidth': 0,
            'tickInterval': 3,
            'showFirstLabel': 1,
            'showLastLabel': 1,
            'lineWidth': 0,
            'labels': {
                'enabled': 1,
                'style': {
                    'fontSize': variable_dic['timeline_font_size']
                }
            },
            'plotBands': plotband_list,
        },
        'yAxis': {
            'gridLineWidth': 3,
            'title': '',
            'startOnTick': 0,
            'endOnTick': 0,
            'labels': {
                'enabled': 0
            },
            'width': 50
        },
        'colors': [chart_color6],
        'series': [{
            'dataLabels': {
                'allowOverlap': 1,
                'format': '{point.label}',
                'borderWidth': 0
            },
            'data': data_list
        }]
    }
    return chart_options
Esempio n. 11
0
def shiftsperplayerchart_create(logger, ctitle, csubtitle, ismobile, data_dic):
    # pylint: disable=E0602, R0914
    """ create shift per player chart """
    logger.debug('shiftsperplayerchart_create()')

    variable_dic = variables_get(ismobile)

    chart_options = {
        'ctype':
        'gantt',
        'chart': {
            'height': '110%',
            'alignTicks': 0,
            'style': chartstyle()
        },
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend': {
            'enabled': 0
        },
        'exporting':
        exporting(filename=ctitle),
        'responsive':
        responsive_y1(),
        'plotOptions': {
            'series': {
                'states': {
                    'inactive': {
                        'opacity': 1
                    }
                }
            }
        },
        'tooltip': {
            'useHTML': 0,
            'headerFormat': '',
            'pointFormat':
            '<b>{point.playername}</b><br>#{point.cnt} - {point.type}: {point.start_human}m - {point.end_human}m',
            'followPointer': 1,
        },
        'xAxis': [{
            'title': title(_('Game Time'), variable_dic['font_size']),
            'labels': {
                'align': 'center',
                'style': {
                    'fontSize': variable_dic['font_size']
                }
            },
            'tickInterval': 300000,
            'type': 'datetime',
            'tickWidth': 1,
            'grid': {
                'enabled': 0
            },
            'opposite': 0,
        }, {
            'title':
            title(_('Goals'), variable_dic['font_size'], offset=15),
            'tickPositions': [],
            'plotLines':
            data_dic['x2_plotlines_list'],
            'plotBands':
            data_dic['plotbands_list'],
            'tickWidth':
            0,
            'grid': {
                'enabled': 0
            },
            'opposite':
            1
        }],
        'yAxis': {
            'title': title('', font_size),
            'categories': data_dic['playername_list'],
            'labels': {
                'useHTML': 1,
                'align': 'right',
                'style': {
                    'fontSize': variable_dic['font_size']
                }
            },
            'grid': {
                'enabled': 0
            },
            'plotLines': data_dic['y_plotlines_list']
        },
        'series': [
            {
                'name': ('Even Strength'),
                'data': data_dic['shifts_list'],
                'color': '#404040',
                'marker': {
                    'symbol': 'square'
                }
            },
        ]
    }
    return chart_options
Esempio n. 12
0
def gamematchupchart_create(logger, ctitle, csubtitle, ismobile, lineup_dic, matchup_matrix, plotline_dic, matchinfo_dic):
    """ create matchup heatmeap """
    # pylint: disable=E0602, R0914
    logger.debug('gamematchupchart_create()')

    variable_dic = variables_get(ismobile)

    data_list = []
    for hpid in matchup_matrix:
        for vpid in matchup_matrix[hpid]:
            # data_list.append([hpid, vpid, round(matchup_matrix[hpid][vpid]/60, 0)])
            tmp_dic = {
                'x': hpid, 'y': vpid,
                'value': round(matchup_matrix[hpid][vpid]['seconds']/60, 3),
                'minsec': '{0:02d}:{1:02d}'.format(*divmod(matchup_matrix[hpid][vpid]['seconds'], 60)),
                'home_name': '{0} {1}'.format(lineup_dic['home_team'][hpid]['name'], lineup_dic['home_team'][hpid]['surname']),
                'visitor_name': '{0} {1}'.format(lineup_dic['visitor_team'][vpid]['name'], lineup_dic['visitor_team'][vpid]['surname']),
                'home_shots': matchup_matrix[hpid][vpid]['home_shots'],
                'visitor_shots': matchup_matrix[hpid][vpid]['visitor_shots'],
            }
            # deside how to set label
            if matchup_matrix[hpid][vpid]['home_shots'] - matchup_matrix[hpid][vpid]['visitor_shots'] > 0:
                # arrow up
                tmp_dic['delta'] = '{0}{1}'.format('\u2BC5', matchup_matrix[hpid][vpid]['home_shots'] - matchup_matrix[hpid][vpid]['visitor_shots'])
                tmp_dic['dataLabels'] = {'format': '{0}{1}'.format('\u2BC5', matchup_matrix[hpid][vpid]['home_shots'] - matchup_matrix[hpid][vpid]['visitor_shots'])}
            elif  matchup_matrix[hpid][vpid]['home_shots'] - matchup_matrix[hpid][vpid]['visitor_shots'] == 0:
                # no arrow
                tmp_dic['delta'] = '{0}'.format(matchup_matrix[hpid][vpid]['home_shots'] - matchup_matrix[hpid][vpid]['visitor_shots'])
                tmp_dic['dataLabels'] = {'format': '{0}'.format(matchup_matrix[hpid][vpid]['home_shots'] - matchup_matrix[hpid][vpid]['visitor_shots'])}
            else:
                # left arrow
                tmp_dic['delta'] = '{0}{1}'.format('\u2BC7', matchup_matrix[hpid][vpid]['visitor_shots'] - matchup_matrix[hpid][vpid]['home_shots'])
                tmp_dic['dataLabels'] = {'format': '{0}{1}'.format('\u2BC7', matchup_matrix[hpid][vpid]['visitor_shots'] - matchup_matrix[hpid][vpid]['home_shots'])}
            data_list.append(tmp_dic)

    x_list = []
    x_list_mobile = []
    for player in lineup_dic['home_team']:
        x_list.append('{0} {1}'.format(lineup_dic['home_team'][player]['name'], lineup_dic['home_team'][player]['surname']))
        x_list_mobile.append('{0}. {1}'.format(lineup_dic['home_team'][player]['name'][0], lineup_dic['home_team'][player]['surname']))


    y_list = []
    y_list_mobile = []
    for player in lineup_dic['visitor_team']:
        y_list.append('{0} {1}'.format(lineup_dic['visitor_team'][player]['name'], lineup_dic['visitor_team'][player]['surname']))
        y_list_mobile.append('{0}. {1}'.format(lineup_dic['visitor_team'][player]['name'][0], lineup_dic['visitor_team'][player]['surname']))

    # x_plotlines
    x_plotlines = []
    for plot in plotline_dic['home_team']:
        x_plotlines.append({'color': '#ffffff', 'width': 4, 'value': plot - .5, 'zIndex': 4})

    # y_plotlines
    y_plotlines = []
    for plot in plotline_dic['visitor_team']:
        y_plotlines.append({'color': '#ffffff', 'width': 4, 'value': plot - .5, 'zIndex': 4})

    chart_options = {

        'chart': {
            'type': 'heatmap',
            'height': variable_dic['shotmap_height_pctg'],
            'style': chartstyle()
        },

        'exporting': exporting(filename=ctitle, allowhtml=0),
        'title': title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle': subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits': credit(),

        'tooltip': {
            'useHTML': 0,
            'headerFormat': None,
            'pointFormat': '<span><b>{point.home_name} vs, {point.visitor_name}</b></span><br/> <span style="font-size: %(fontsize)s"> {series.name}: {point.minsec} %(min)s</span><br /><span style="font-size: %(fontsize)s"><b>%(headline)s:</b><br /><span style="font-size: %(fontsize)s"> %(homeshots)s: {point.home_shots}</span><br/> <span style="font-size: %(fontsize)s"> %(visitorshots)s: {point.visitor_shots}</span><br/><span style="font-size: %(fontsize)s"> delta: {point.delta}<br />' % {'fontsize': font_size, 'min': 'min', 'headline': _('Shots while players on Ice'), 'homeshots': matchinfo_dic['home_team__shortcut'], 'visitorshots': matchinfo_dic['visitor_team__shortcut']},
        },

        'xAxis': {
            'categories': x_list,
            'opposite':1,
            'plotLines': x_plotlines,
            'labels': {'step': 1, 'rotation': -45}
        },

        'yAxis': {
            'categories': y_list,
            'title': '',
            'reversed': True,
            'plotLines': y_plotlines,
            'labels': {'step': 1}
        },

        'legend': {
            'title': {'text': _('Time on Ice'), 'style': {'fontStyle': 'lighter','fontSize': font_size}},
            'align': 'center',
            'layout': 'horizontal',
            'verticalAlign': 'bottom',
            'itemStyle': {'color': text_color, 'fontWeight': 'lighter', 'fontSize': font_size},
        },

        'colorAxis': {
            'min': 0,
            'minColor': '#FFFFFF',
            'maxColor': chart_color1,
            'labels': {'style': {'color': text_color, 'fontSize': font_size}},
        },

        'series': [{
            'name': _('Time on Ice'),
            'borderWidth': 1,
            'data': data_list,
            'dataLabels': {
                'enabled': 1,
                'useHTML': 0,
                # 'color': text_color,
                'style': {'fontSize': '8px', 'textOutline': 0, 'color': text_color}
            }
        }],

        'responsive': {
            'rules': [{
                'condition': {'maxWidth': 500},
                'chartOptions': {
                    'legend': {'title': {'text': _('Time on Ice'), 'style': {'fontStyle': 'lighter','fontSize': font_size_mobile}}},
                    'xAxis': {'categories': x_list_mobile, 'labels': {'style': {'fontSize': font_size_mobile}}},
                    'yAxis': {'categories': y_list_mobile, 'labels': {'style': {'fontSize': font_size_mobile}}},
                    'colorAxis': {'labels': {'style': {'color': text_color, 'fontSize': font_size_mobile}}},
                }
            }]
        }
    }
    return chart_options
Esempio n. 13
0
def gametoichart_create(logger, ctitle, csubtitle, ismobile, toi_dic,
                        bar_color1, bar_color2, bar_color3, bar_color4):
    # pylint: disable=E0602
    """ create time-on-ice chart """
    logger.debug('gametoichart_create()')

    variable_dic = variables_get(ismobile)

    # create x axis with player names
    x_list = []
    y_dic = {1: [], 2: [], 3: [], 4: []}

    # we need two iterations of the dictionary
    # first one is to create the list of playernames
    for period in toi_dic:
        for player_name in toi_dic[period]:
            if player_name not in x_list:
                x_list.append(player_name)

    # 2nd one to add toi per player
    for period in toi_dic:
        for player_name in sorted(x_list):
            if player_name in toi_dic[period]:
                # y_dic[period].append('{0:02d}:{1:02d}'.format(*divmod(shifts_dic['ebb'][period][player_name], 60)))
                y_dic[period].append({
                    'y':
                    round(toi_dic[period][player_name] / 60, 3),
                    'label':
                    '{0:02d}:{1:02d}'.format(
                        *divmod(toi_dic[period][player_name], 60))
                })
            else:
                y_dic[period].append(0)

    chart_options = {
        'chart': {
            'type': 'bar',
            'height': '120%',
            'alignTicks': 0,
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend':
        legend(),
        'responsive':
        responsive_y1(),
        'plotOptions': {
            'series': {
                'stacking': 'normal'
            }
        },
        'tooltip': {
            'shared':
            1,
            'useHTML':
            1,
            'headerFormat':
            '<span style="font-size: %s"><b>{point.x}</b></span><br/>' %
            font_size,
            'pointFormat':
            '<span style="color:{point.color}">\u25CF</span> <span style="font-size: %s">{series.name}: {point.label} %s</span><br/>'
            % (font_size, _('min'))
        },
        'xAxis': {
            'categories': sorted(x_list),
            'title': title('', font_size),
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'tickInterval': 1,
            'showFirstLabel': 1,
            'showLastLabel': 1,
        },
        'yAxis': {
            'title': title(_('Time on Ice'), font_size),
            'reversedStacks': 0,
            'tickInterval': 1,
            'maxPadding': 0.1,
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
        },
        'series': [{
            'name': _('1st Period'),
            'data': y_dic[1],
            'color': bar_color1
        }, {
            'name': _('2nd Period'),
            'data': y_dic[2],
            'color': bar_color2
        }, {
            'name': _('3rd Period'),
            'data': y_dic[3],
            'color': bar_color3
        }, {
            'name': _('OT'),
            'data': y_dic[4],
            'color': bar_color4
        }]
    }
    return chart_options
Esempio n. 14
0
def gametoipppkchart_create(logger, ctitle, csubtitle, ismobile, toi_dic,
                            color_primary, color_secondary):
    # pylint: disable=E0602, R0914
    """ create time-on-ice chart """
    logger.debug('gametoipppkchart_create()')

    variable_dic = variables_get(ismobile)

    # create x axis with player names
    x_list = []
    pp_list = []
    pk_list = []

    # this one is to create the list of playernames
    for player_name in toi_dic:
        if player_name not in x_list:
            x_list.append(player_name)

    # add toi per player
    pp_max = 0
    pk_min = 0
    for player_name in sorted(x_list):
        if player_name in toi_dic:
            # y_dic[period].append('{0:02d}:{1:02d}'.format(*divmod(shifts_dic['ebb'][period][player_name], 60)))
            pp_value = round(toi_dic[player_name]['pp'] / 60, 3)
            pk_value = round(toi_dic[player_name]['pk'] / 60, 3) * -1
            # check min max values to adjust chart
            if pp_max <= pp_value:
                pp_max = pp_value
            if pk_value <= pk_min:
                pk_min = pk_value
            pp_list.append({
                'y':
                pp_value,
                'label':
                '{0:02d}:{1:02d}'.format(
                    *divmod(toi_dic[player_name]['pp'], 60))
            })
            pk_list.append({
                'y':
                pk_value,
                'label':
                '{0:02d}:{1:02d}'.format(
                    *divmod(toi_dic[player_name]['pk'], 60))
            })
        else:
            pp_list.append(0)
            pk_list.append(0)

    chart_options = {
        'chart': {
            'type': 'bar',
            'height': '100%',
            'alignTicks': 0,
            'style': chartstyle()
        },
        'exporting':
        exporting(filename=ctitle),
        'title':
        title(ctitle, variable_dic['title_size'], decoration=True),
        'subtitle':
        subtitle(csubtitle, variable_dic['subtitle_size']),
        'credits':
        credit(),
        'legend':
        legend(additional_parameters={'reversed': 1}),
        'responsive':
        responsive_y1_nolabel(),
        'plotOptions': {
            'series': {
                'stacking': 'normal',
                'dataLabels': {
                    'enabled': 1,
                    'inside': 0,
                    'style': {
                        'fontSize': font_size,
                        'textOutline': 0,
                        'color': '#000000',
                        'fontWeight': 0
                    },
                    'format': '{point.label}'
                }
            }
        },
        'tooltip': {
            'shared':
            1,
            'useHTML':
            1,
            'headerFormat':
            '<span style="font-size: %s"><b>{point.x}</b></span><br/>' %
            font_size,
            'pointFormat':
            '<span style="color:{point.color}">\u25CF</span> <span style="font-size: %s">{series.name}: {point.label} %s</span><br/>'
            % (font_size, _('min'))
        },
        'xAxis': {
            'categories': sorted(x_list),
            'title': title('', font_size),
            'labels': {
                'style': {
                    'fontSize': font_size
                },
            },
            'tickInterval': 1,
            'showFirstLabel': 1,
            'showLastLabel': 1,
        },
        'yAxis': {
            'title': title(_('Time on Ice in min'), font_size),
            'reversedStacks': 0,
            'tickInterval': 1,
            'maxPadding': 0.1,
            'min': pk_min - 1,
            'max': pp_max + 1,
            'labels': {
                'enabled': 0,
                'style': {
                    'fontSize': font_size
                },
            },
        },
        'series': [
            {
                'name': _('Time in Powerplay'),
                'data': pp_list,
                'color': color_primary
            },
            {
                'name': _('Time in Penalty killing'),
                'data': pk_list,
                'color': color_secondary
            },
        ]
    }
    return chart_options