本文整理汇总了Python中pygooglechart.SimpleLineChart.set_axis_range方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleLineChart.set_axis_range方法的具体用法?Python SimpleLineChart.set_axis_range怎么用?Python SimpleLineChart.set_axis_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygooglechart.SimpleLineChart
的用法示例。
在下文中一共展示了SimpleLineChart.set_axis_range方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: velocity_chart
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [as 别名]
def velocity_chart(self):
graph_width = 600
graph_height = 300
x_max = self.total_iterations
y_max = max(max(self.estimate_stories_data()),
max(self.estimate_tasks_data()),
max(self.work_data()))
chart = SimpleLineChart(graph_width, graph_height,
x_range=(1, x_max + 1), y_range=(0, y_max + 1))
chart.add_data(self.estimate_stories_data())
chart.add_data(self.estimate_tasks_data())
chart.add_data(self.work_data())
chart.set_grid(0, 100.0 / y_max + 1, 5, 5)
chart.set_colours(['FF0000', '00FF00', '0000FF'])
chart.set_legend([_('rough story estimates'),
_('task estimates'), _('worked')])
chart.set_legend_position('b')
chart.set_axis_labels(Axis.LEFT, ['', '', _('days')])
chart.set_axis_labels(Axis.BOTTOM, range(1, x_max + 1))
chart.set_axis_range(Axis.LEFT, 0, y_max + 1)
return chart.get_url(data_class=ExtendedData)
示例2: get_elevation_chart_url
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [as 别名]
def get_elevation_chart_url(self, width, height):
if len(self.positions) == 0:
return ''
int_elevations = [int(elevation) for elevation in ema([p.altitude for p in self.positions], 30)]
max_elev = int(max(int_elevations) / 0.95)
min_elev = int(min(int_elevations) * 0.95)
chart = SimpleLineChart(width, height, y_range = (min_elev, max_elev))
chart.add_data(int_elevations)
chart.set_axis_range(Axis.LEFT, min_elev, max_elev)
return chart.get_url()
示例3: many_labels
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [as 别名]
def many_labels():
chart = SimpleLineChart(settings.width, settings.height)
for a in xrange(3):
for axis_type in (Axis.LEFT, Axis.RIGHT, Axis.BOTTOM):
index = chart.set_axis_range(axis_type, 0, random.random() * 100)
chart.set_axis_style(index, colour=helper.random_colour(), \
font_size=random.random() * 10 + 5)
chart.add_data(helper.random_data())
chart.download('label-many.png')
示例4: _line_strip_graph
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [as 别名]
def _line_strip_graph(data, legends, axis_labels, size, steps,
type=SimpleLineChart, multiline=False, **kwargs):
if multiline:
max_values = []
min_values = []
for row in data:
max_values.append(max(row))
min_values.append(min(row))
max_y = max(max_values)
min_y = min(min_values)
else:
max_y = max(data)
min_y = min(data)
#validando si hay datos para hacer grafico
if max_y==0:
return None
chart = SimpleLineChart(size[0], size[1], y_range=[0, max_y*1.05])
if multiline:
for row in data:
chart.add_data(row)
else:
chart.add_data(data)
step = ((max_y*1.05)-(min_y*0.95))/steps
#validando en caso de el paso sea menor que uno y de cero en la conversion
if step<1:
step = 1
max_value = max_y
tope = int(round(max_value*1.05))
if tope < max_value:
tope+=2
else:
tope+=1
try:
left_axis = range(int(round(min_y*0.95)), tope, int(step))
except ValueError:
#error por que los range no soportan decimales
left_axis = range(0, 2)
left_axis[0]=''
chart.set_axis_range(Axis.LEFT, min_y, tope)
if 'units' in kwargs:
chart.set_axis_labels(Axis.LEFT, kwargs['units'])
if 'time' in kwargs:
chart.set_axis_labels(Axis.BOTTOM, kwargs['time'])
chart.set_grid(0, 25, 4, 4,)
chart.chls=4|4
#chart.fill_linear_stripes(Chart.CHART, 0, 'FFFFEF', 0.2, 'FFFFFF', 0.2)
chart.set_colours(COLORS)
if axis_labels:
chart.set_axis_labels(Axis.BOTTOM, axis_labels)
chart.set_legend(legends)
chart.set_legend_position('b')
if 'thickness' in kwargs:
if multiline:
for i in range(len(data)):
chart.set_line_style(index = i, thickness=kwargs['thickness'])
else:
chart.set_line_style(index=0, thickness=kwargs['thickness'])
return chart
示例5: email_report
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [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
#.........这里部分代码省略.........
示例6: SimpleLineChart
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [as 别名]
from pygooglechart import SimpleLineChart, Axis
chart = SimpleLineChart(200, 125)
data = [ 1, 5, 30, 10, 25 ]
chart.add_data(data)
chart.set_axis_range(Axis.LEFT, 0, 10)
chart.download("hello.png")
print chart.get_url()
示例7: render
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [as 别名]
#.........这里部分代码省略.........
chart.add_marker(index, last_index, 't'+str(last_data), _valid_color(last_config.text), last_config.size)
chart.add_marker(index, last_index, last_config.style, _valid_color(last_config.color), last_config.thickness)
if serie_config.area:
fill_config = ChartConfig()
fill_config.__dict__.update(serie_config.__dict__)
fill_config.__dict__.update(serie_config.area)
to = ordered_keys.index(fill_config.to)
chart.add_fill_range(_valid_color(fill_config.color), index, to)
if serie_config.dash:
chart.set_line_style(index, serie_config.thickness, serie_config.dash, serie_config.dash)
else:
chart.set_line_style(index, serie_config.thickness)
if serie_config.legend:
legend.append(serie_config.legend)
legend_set = True
else:
legend.append('')
if serie_config.marks:
mark_config = ChartConfig()
mark_config.__dict__.update(serie_config.__dict__)
mark_config.__dict__.update(serie_config.marks)
mark_data = copy.copy(data[mark_config.serie.split('.')[0]]['series'][mark_config.serie.split('.')[1]])
mark_data = compress_to(mark_data, config.nval, min_index, max_index)[0]
for i, m in enumerate(mark_data):
if not m:
mark_data[i] = " "
density = max(1.0, 1.0 * mark_config.space * len("".join(mark_data))*mark_config.size / config.width)
for i, v in enumerate(mark_data):
if (i +1) % round(density) == 0:
if serie_data[i] != 0:
text = str(mark_data[i])
else:
text = " "
chart.add_marker(index, i, 't'+text, _valid_color(mark_config.color), mark_config.size)
index = index + 1
# Compute vertical range
if config.axes:
range_min_ref_units = 0
if not chart_min == sys.maxint and not chart_max == -sys.maxint:
range_min = chart_min-config.ymargin[0]
range_max = chart_max+config.ymargin[1]
range_min_target_units = math.floor(converter.convert(measure, range_min))
range_max_target_units = math.ceil(converter.convert(measure, range_max))
range_min_ref_units = converter.convert_back(measure, range_min_target_units)
range_max_ref_units = converter.convert_back(measure, range_max_target_units)
self.logger.debug("Y range: "+str(range_min_target_units) +" "+str(range_max_target_units))
chart.set_axis_range(Axis.LEFT, range_min_target_units, range_max_target_units+1)
chart.add_data([range_min_ref_units, range_max_ref_units])
colors.append("00000000")
else:
chart.set_axis_range(Axis.LEFT, 0, 100)
chart.set_axis_style(0, _valid_color(config.text), config.size, 0, Axis.BOTH if config.ticks else Axis.AXIS_LINES)
else:
chart.set_axis_labels(Axis.LEFT, [])
chart.set_axis_style(0, _valid_color(config.text), config.size, 0, Axis.TICK_MARKS, _valid_color(config.bgcolor))
if config.zero and config.axes and range_min_ref_units < 0 and range_max_ref_units > 0:
zero_config = ChartConfig()
zero_config.__dict__.update(config.__dict__)
zero_config.__dict__.update(config.zero)
chart.add_data([0]*2)
colors.append(_valid_color(zero_config.color))
chart.set_line_style(index, zero_config.thickness)
chart.set_colours(colors)
chart.fill_solid(Chart.BACKGROUND, _valid_color(config.bgcolor))
if legend_set:
chart.set_legend(legend)
chart.set_legend_position(config.legend_pos)
if self.labels:
labels_data = copy.copy(data[self.labels.split('.')[0]]['series'][self.labels.split('.')[1]])
labels_data = compress_to(labels_data, config.nval, None, None)[0]
if config.axes:
density = 1.0 * len("".join(labels_data))*config.size / config.width
if density > LABEL_DENSITY_THRESHOLD:
for i, v in enumerate(labels_data):
if i % round(density) != 0:
labels_data[i] = ' '
chart.set_axis_labels(Axis.BOTTOM, labels_data)
chart.set_axis_style(1, _valid_color(config.text), config.size, 0, Axis.BOTH if config.ticks else Axis.AXIS_LINES)
else:
chart.set_axis_labels(Axis.BOTTOM, [])
chart.set_axis_style(1, _valid_color(config.text), config.size, 0, Axis.TICK_MARKS, _valid_color(config.color))
try:
return chart.get_url()+"&chma=10,10,10,10" # add a margin
except:
self.logger.exception("Could not render chart")
return "http://chart.apis.google.com/chart?cht=lc&chs="+str(config.width)+"x"+str(config.height)
示例8: lambda_handler
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [as 别名]
def lambda_handler(event, context):
# http://developer.yahoo.co.jp/webapi/map/openlocalplatform/v1/weather.html
url = "http://weather.olp.yahooapis.jp/v1/place"
payload = {'appid': YAHOO_APP_ID, 'coordinates': LON + "," + LAT, 'output': 'json'}
result = requests.get(url, params=payload)
timeString = getTimeString(30)
send_message = False
json_data = json.loads(result.content)
rainfall = json_data['Feature'][0]['Property']['WeatherList']['Weather']#[3]['Rainfall']
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(inifile.get('dynamodb', 'table_id'))
key_id = int(inifile.get('dynamodb', 'id_value'))
result = table.get_item(
Key={
'Id': key_id
}
)
if 'raining' not in result:
table.put_item(
Item={
"Id":key_id,
"raining": False,
"source": inifile.get('dynamodb', 'source')}
)
raining = result['Item']['raining']
if rainfall[3]['Rainfall'] >= ALERT_THRESH and raining == False:
send_message = True
message = timeString + "で" + str(rainfall[3]['Rainfall']) + "mm/hの雨が予想されます。"
elif rainfall[3]['Rainfall'] < ALERT_THRESH and raining == True:
send_message = True
message = timeString + "で" + "雨が止む予報です。"
elif rainfall[3]['Rainfall'] >= ALERT_THRESH and raining == True:
send_message = True
message = timeString + "で" + str(rainfall[3]['Rainfall']) + "mm/hの雨が引き続き降る予報です。"
elif rainfall[3]['Rainfall'] < ALERT_THRESH and raining == False:
send_message = False
if rainfall[3]['Rainfall'] >= ALERT_THRESH:
table.put_item(
Item={
"Id":key_id,
"raining": True,
"source": inifile.get('dynamodb', 'source')}
)
else:
table.put_item(
Item={
"Id":key_id,
"raining": False,
"source": inifile.get('dynamodb', 'source')}
)
if send_message == True:
width = 500
height = 150
chart = SimpleLineChart(width, height)
chart.set_colours(['719CFF'])
rainfall_array = [rainfall[0]['Rainfall'], rainfall[1]['Rainfall'], rainfall[2]['Rainfall'], rainfall[3]['Rainfall'], rainfall[4]['Rainfall'], rainfall[5]['Rainfall'], rainfall[6]['Rainfall']]
chart.add_data(rainfall_array)
chart.set_axis_labels(Axis.BOTTOM, [getTimeString(0), getTimeString(10), getTimeString(20), getTimeString(30), getTimeString(40), getTimeString(50), getTimeString(60)])
chart.set_legend(['Rainfall(mm/h)'])
chart.set_legend_position('bv')
if math.ceil(max(rainfall_array)) < 1.0:
chart.y_range=(0, 1)
chart.set_axis_range(Axis.LEFT, 0, 1)
else:
chart.y_range=(0, math.ceil(max(rainfall_array)))
chart.set_axis_range(Axis.LEFT, 0, math.ceil(max(rainfall_array)))
d = datetime.now() + timedelta(hours=9, minutes=30)
date_str = d.strftime("|date:%Y%m%d%H%M|datelabel:on")
radar_url = "http://weather.yahoo.co.jp/weather/zoomradar/?lat=" + LAT + "&lon=" + LON + "&z=12"
rainfall_image_url = getRainfallRadarUrl(LAT, LON, ZOOM, MAP_IMAGE_X, MAP_IMAGE_Y) + date_str
chart_url = shorten_url(chart.get_url())
rainfall_image_url = shorten_url(rainfall_image_url)
radar_url = shorten_url(radar_url)
message = unicode(message, 'utf-8') + "\n" + chart_url + "\n" + timeString + u"の雨雲予想: " + rainfall_image_url + "\n" + u"詳細: " + radar_url + "\n"
sc = SlackClient(inifile.get('slack', 'token'))
res = sc.api_call("chat.postMessage", channel=inifile.get('slack', 'channel'), text=message, username=inifile.get('slack', 'username'), icon_emoji=inifile.get('slack', 'icon_emoji'))
print(res)
示例9: email_report
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_axis_range [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
#.........这里部分代码省略.........