当前位置: 首页>>代码示例>>Python>>正文


Python SimpleLineChart.data方法代码示例

本文整理汇总了Python中pygooglechart.SimpleLineChart.data方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleLineChart.data方法的具体用法?Python SimpleLineChart.data怎么用?Python SimpleLineChart.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygooglechart.SimpleLineChart的用法示例。


在下文中一共展示了SimpleLineChart.data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: email_report

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import data [as 别名]
def email_report(email, download_link, daily_report, weekly_report,
                 host, port, login=None, password=None, dry_run=False,
                 verbose=False):
    daily = [v[0] for k, v in daily_report.items()] if daily_report else []
    weekly = [v[0] for k, v in weekly_report.items()] if weekly_report else []

    cumulative_data = daily_report if daily_report else weekly_report
    if cumulative_data is None:
        raise Exception("No data given to generate a cumulative report!")
    cumulative = [v[1] for k, v in cumulative_data.items()]

    width, height = 700, 300

    # Create the charts
    daily_chart = SimpleLineChart(width, height)
    weekly_chart = SimpleLineChart(width, height)
    cumulative_chart = SimpleLineChart(width, height)

    # Titles
    daily_chart.set_title('Daily Downloads')
    weekly_chart.set_title('Weekly Downloads')
    cumulative_chart.set_title('Cumulative Downloads')

    # Add data
    if daily:
        daily_chart.add_data(daily)
        daily_chart.set_axis_range(Axis.LEFT, 0, max(daily))
        daily_chart.set_axis_labels(Axis.RIGHT, [min(daily), max(daily)])

    if weekly:
        weekly_chart.add_data(weekly)
        weekly_chart.set_axis_range(Axis.LEFT, 0, max(weekly))
        weekly_chart.set_axis_labels(Axis.RIGHT, [min(weekly), max(weekly)])

    cumulative_chart.add_data(cumulative)
    cumulative_chart.set_axis_range(Axis.LEFT, 0, max(cumulative))
    cumulative_chart.set_axis_labels(
        Axis.RIGHT, [min(cumulative), max(cumulative)])

    # Set the styling
    marker = ('B', 'C5D4B5BB', '0', '0', '0')
    colors = ['3D7930', 'FF9900']

    daily_chart.markers.append(marker)
    weekly_chart.markers.append(marker)
    cumulative_chart.markers.append(marker)

    daily_chart.set_colours(colors)
    weekly_chart.set_colours(colors)
    cumulative_chart.set_colours(colors)

    grid_args = 0, 10
    grid_kwargs = dict(line_segment=2, blank_segment=6)
    daily_chart.set_grid(*grid_args, **grid_kwargs)
    weekly_chart.set_grid(*grid_args, **grid_kwargs)
    cumulative_chart.set_grid(*grid_args, **grid_kwargs)

    #daily_chart.fill_linear_stripes(
    #   Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)

    daily_chart_url = daily_chart.get_url() if daily else None
    weekly_chart_url = weekly_chart.get_url() if weekly else None
    cumulative_chart_url = cumulative_chart.get_url()

    # Create recent versions of the charts
    if daily:
        recent_daily = daily[-90:]

        # Get last year's daily data. First, get the first date for the daily
        # data.
        start = daily_report.items()[-90][0]
        dt = datetime.datetime.strptime(start, '%Y/%m/%d')
        dt = dt - datetime.timedelta(weeks=52)
        last_year_datestr = datetime_to_str(dt)

        # Get the index in the data for the datestr
        try:
            i = daily_report.keys().index(last_year_datestr)
            recent_daily_comparison = daily[i:i + 90]
        except ValueError:
            recent_daily_comparison = []

        if recent_daily_comparison:
            daily_chart.data = [recent_daily, recent_daily_comparison]
        else:
            daily_chart.data = [recent_daily]
        # Reset the axes
        daily_chart.axis = []
        min_daily = min(recent_daily + recent_daily_comparison)
        max_daily = max(recent_daily + recent_daily_comparison)
        daily_chart.set_axis_range(Axis.LEFT, 0, max_daily)
        daily_chart.set_axis_labels(Axis.RIGHT, [min_daily, max_daily])
        daily_chart.set_title('Recent Daily Downloads (filled is now)')

        daily_recent_chart_url = daily_chart.get_url()
    else:
        daily_recent_chart_url = None

    if verbose:
        print('Daily: ' + daily_chart_url) if daily_chart_url else None
#.........这里部分代码省略.........
开发者ID:mikehotel,项目名称:itunes-downloader,代码行数:103,代码来源:reports.py

示例2: email_report

# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import data [as 别名]
def email_report(email, download_link, daily_report, weekly_report,
                 host, port, login=None, password=None, dry_run=False,
                 verbose=False):
    daily = [v[0] for k, v in daily_report.items()] if daily_report else []
    daily_updates = daily_report.items()[-1][1][1]
    daily_edu = daily_report.items()[-1][1][2]
    weekly = [v[0] for k, v in weekly_report.items()] if weekly_report else []

    cumulative_data = daily_report if daily_report else weekly_report
    if cumulative_data is None:
        raise Exception("No data given to generate a cumulative report!")
    cumulative = [v[3] for k, v in cumulative_data.items()]

    width, height = 700, 300

    # Create the charts
    daily_chart = SimpleLineChart(width, height)
    weekly_chart = SimpleLineChart(width, height)
    cumulative_chart = SimpleLineChart(width, height)

    # Titles
    daily_chart.set_title('Daily Downloads')
    weekly_chart.set_title('Weekly Downloads')
    cumulative_chart.set_title('Cumulative Downloads')

    # Add data
    if daily:
        daily_data = daily[-180:]
        daily_chart.add_data(daily_data)
        daily_chart.set_axis_range(Axis.LEFT, 0, max(daily_data))
        daily_chart.set_axis_labels(Axis.RIGHT, [min(daily_data), max(daily_data)])

    if weekly:
        weekly_chart.add_data(weekly)
        weekly_chart.set_axis_range(Axis.LEFT, 0, max(weekly))
        weekly_chart.set_axis_labels(Axis.RIGHT, [min(weekly), max(weekly)])

    cumulative_chart.add_data(cumulative)
    cumulative_chart.set_axis_range(Axis.LEFT, 0, max(cumulative))
    cumulative_chart.set_axis_labels(
        Axis.RIGHT, [min(cumulative), max(cumulative)])

    # Set the styling
    marker = ('B', 'C5D4B5BB', '0', '0', '0')
    colors = ['3D7930', 'FF9900']

    daily_chart.markers.append(marker)
    weekly_chart.markers.append(marker)
    cumulative_chart.markers.append(marker)

    daily_chart.set_colours(colors)
    weekly_chart.set_colours(colors)
    cumulative_chart.set_colours(colors)

    grid_args = 0, 10
    grid_kwargs = dict(line_segment=2, blank_segment=6)
    daily_chart.set_grid(*grid_args, **grid_kwargs)
    weekly_chart.set_grid(*grid_args, **grid_kwargs)
    cumulative_chart.set_grid(*grid_args, **grid_kwargs)

    #daily_chart.fill_linear_stripes(
    #   Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)

    daily_chart_url = daily_chart.get_url() if daily else None
    weekly_chart_url = weekly_chart.get_url() if weekly else None
    cumulative_chart_url = cumulative_chart.get_url()

    # Create recent versions of the charts
    if daily:
        recent_daily = daily[-90:]

        # Get last year's daily data. First, get the first date for the daily
        # data.
        start = daily_report.items()[-90][0]
        dt = datetime.datetime.strptime(start, '%Y/%m/%d')
        dt = dt - datetime.timedelta(weeks=52)
        last_year_datestr = datetime_to_str(dt)

        # Get the index in the data for the datestr
        try:
            i = daily_report.keys().index(last_year_datestr)
            recent_daily_comparison = daily[i:i + 90]
        except ValueError:
            recent_daily_comparison = []

        if recent_daily_comparison:
            daily_chart.data = [recent_daily, recent_daily_comparison]
        else:
            daily_chart.data = [recent_daily]
        # Reset the axes
        daily_chart.axis = []
        min_daily = min(recent_daily + recent_daily_comparison)
        max_daily = max(recent_daily + recent_daily_comparison)
        daily_chart.set_axis_range(Axis.LEFT, 0, max_daily)
        daily_chart.set_axis_labels(Axis.RIGHT, [min_daily, max_daily])
        daily_chart.set_title('Recent Daily Downloads (filled is now)')

        daily_recent_chart_url = daily_chart.get_url()
    else:
        daily_recent_chart_url = None
#.........这里部分代码省略.........
开发者ID:educreations,项目名称:itunes-downloader,代码行数:103,代码来源:reports.py


注:本文中的pygooglechart.SimpleLineChart.data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。