本文整理汇总了Python中corehq.apps.reports.graph_models.MultiBarChart.rotateLabels方法的典型用法代码示例。如果您正苦于以下问题:Python MultiBarChart.rotateLabels方法的具体用法?Python MultiBarChart.rotateLabels怎么用?Python MultiBarChart.rotateLabels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.reports.graph_models.MultiBarChart
的用法示例。
在下文中一共展示了MultiBarChart.rotateLabels方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, x_label, y_label, data_provider):
def _get_label_with_percentage(row):
return "%s [%s%%]" % (row[0]['html'], str(int(row[-1]['html'][:-1])))
if isinstance(data_provider, NutritionBirthWeightDetails):
chart = PieChart('BirthWeight', '',
[{'label': "%s [%s%%]" % (row[0]['html'], str(int(row[-1]['html'][:-1]))),
'value': int(row[-1]['html'][:-1])} for row in rows[2:]], ['red', 'green'])
chart.showLabels = False
elif isinstance(data_provider, DeliveryPlaceDetailsExtended):
chart = PieChart('', '', [{'label': _get_label_with_percentage(row),
'value': int(row[-1]['html'][:-1])} for row in rows[1:]])
chart.showLabels = False
elif isinstance(data_provider, (PostnatalCareOverview, ImmunizationOverview)):
chart = MultiBarChart('', x_axis=Axis(x_label), y_axis=Axis(y_label, '.2%'))
chart.rotateLabels = -45
chart.marginBottom = 120
if isinstance(data_provider, ImmunizationOverview):
chart.stacked = True
chart.add_dataset('Percentage',
[{'x': row[0]['html'],
'y': int(row[3]['html'][:-1]) / 100.0} for row in rows],
color='green')
chart.add_dataset('Dropout Percentage',
[{'x': row[0]['html'],
'y': int(row[-1]['html'][:-1]) / 100.0} for row in rows],
color='red')
else:
chart.add_dataset('Percentage',
[{'x': row[0]['html'], 'y':int(row[-1]['html'][:-1]) / 100.0} for row in rows])
elif isinstance(data_provider, AnteNatalCareServiceOverviewExtended):
chart1 = MultiBarChart('', x_axis=Axis(x_label), y_axis=Axis(y_label, '.2%'))
chart2 = MultiBarChart('', x_axis=Axis(x_label), y_axis=Axis(y_label, '.2%'))
chart1.rotateLabels = -45
chart2.rotateLabels = -45
chart1.marginBottom = 120
chart2.marginBottom = 120
chart1.add_dataset('Percentage', [{'x': row[0]['html'],
'y': int(row[-1]['html'][:-1]) / 100.0} for row in rows[1:6]])
chart2.add_dataset('Percentage', [{'x': row[0]['html'],
'y': int(row[-1]['html'][:-1]) / 100.0} for row in rows[6:12]])
return [chart1, chart2]
elif isinstance(data_provider, ChildrenDeathsByMonth):
chart = LineChart('Seasonal Variation of Child Deaths', x_axis=Axis(x_label, dateFormat="%B"),
y_axis=Axis(y_label, '.2%'))
chart.rotateLabels = -45
chart.marginBottom = 120
months_mapping = dict((v, k) for k, v in enumerate(calendar.month_abbr))
chart.add_dataset('Percentage', [{'x': datetime.date(1, months_mapping[row[0][:3]], 1),
'y': int(row[-1]['html'][:-1]) / 100.0} for row in rows])
else:
chart = PieChart('', '', [{'label': "%s [%s%%]" % (row[0]['html'], str(int(row[-1]['html'][:-1]))),
'value': int(row[-1]['html'][:-1])} for row in rows])
chart.showLabels = False
return [chart]
示例2: charts
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def charts(self):
product_dashboard = ProductAvailabilityDashboardChart()
product_availability = self.rows
def convert_product_data_to_stack_chart(rows, chart_config):
ret_data = []
for k in ['Stocked out', 'Not Stocked out', 'No Stock Data']:
datalist = []
for product in rows:
prd_code = SQLProduct.objects.get(product_id=product.product).code
if k == 'No Stock Data':
datalist.append([prd_code, product.without_data])
elif k == 'Stocked out':
datalist.append([prd_code, product.without_stock])
elif k == 'Not Stocked out':
datalist.append([prd_code, product.with_stock])
ret_data.append({'color': chart_config.label_color[k], 'label': k, 'data': datalist})
return ret_data
chart = MultiBarChart('', x_axis=Axis('Products'), y_axis=Axis(''))
chart.rotateLabels = -45
chart.marginBottom = 120
chart.stacked = self.chart_stacked
for row in convert_product_data_to_stack_chart(product_availability, product_dashboard):
chart.add_dataset(row['label'], [
{'x': r[0], 'y': r[1]}
for r in sorted(row['data'], key=lambda x: x[0])], color=row['color']
)
return [chart]
示例3: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, columns, x_label, y_label):
chart = MultiBarChart('% of Groups Receiving Grades', x_axis=Axis(x_label), y_axis=Axis(y_label, '.0%'))
chart.height = 400
chart.rotateLabels = -60
chart.marginBottom = 90
chart.marginLeft = 100
self._chart_data(chart, columns, rows)
return [chart]
示例4: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, columns, x_label, y_label):
chart = MultiBarChart('Adoption of Practices', x_axis=Axis(x_label), y_axis=Axis(y_label))
chart.forceY = [0, 100]
chart.height = 700
chart.rotateLabels = -55
chart.marginBottom = 390
chart.marginLeft = 350
self._chart_data(chart, columns, rows)
return [chart]
示例5: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, columns, x_label, y_label, has_total_column=False):
end = len(columns)
if has_total_column:
end -= 1
categories = [c.html for c in columns.header[1:end]]
chart = MultiBarChart('', x_axis=Axis(x_label), y_axis=Axis(y_label, ' ,d'))
chart.rotateLabels = -45
chart.marginBottom = 120
self._chart_data(chart, categories, rows)
return [chart]
示例6: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, columns, x_label, y_label):
chart = MultiBarChart('Adoption of Practices', x_axis=Axis(x_label), y_axis=Axis(y_label, '%'))
if self.report_config['group'] == 'domain':
chart.height = 550
chart.rotateLabels = -55
chart.marginBottom = 250
elif self.report_config['group'] == 'practice':
chart.height = 700
chart.rotateLabels = -55
chart.marginBottom = 400
else:
chart.height = 320
chart.rotateLabels = 0
chart.marginBottom = 50
chart.marginLeft = 200
chart.marginRight = 150
self._chart_data(chart, columns, rows)
return [chart]
示例7: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, x_label, y_label):
chunks = _chunks(list(rows), self.chunk_size + 1)
charts = []
if self.request.GET.get('group_by', '') == 'domain':
chunks = sorted(chunks, key=lambda k: k[0][0])
for chunk in chunks:
chart = MultiBarChart(chunk[0][0], x_axis=Axis(x_label), y_axis=Axis(y_label, '.0%'))
chart.height = 300
chart.rotateLabels = 0
chart.marginBottom = 80
chart.marginLeft = 100
self._chart_data(chart, chunk[1:])
charts.append(chart)
return charts
示例8: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, x_label, y_label):
chunks = _chunks(list(rows), self.chunk_size+1)
charts = []
for chunk in chunks:
chart = MultiBarChart(chunk[0][0], x_axis=Axis(x_label), y_axis=Axis(y_label))
chart.forceY = [0, 100]
chart.height = 300
chart.rotateLabels = 0
chart.marginBottom = 80
chart.marginLeft = 100
self._chart_data(chart, chunk[1:])
charts.append(chart)
return charts
示例9: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, columns, x_label, y_label, has_total_column=False):
"""
Get a MultiBarChart model for the given set of rows and columns.
:param rows: 2D list of report data. Assumes index 0 of each row is the row label
:param columns: list of DatabaseColumn objects
"""
end = len(columns)
if has_total_column:
end -= 1
categories = [c.data_tables_column.html for c in columns[1:end]]
chart = MultiBarChart('', x_axis=Axis(x_label), y_axis=Axis(y_label, ' ,d'))
chart.rotateLabels = -45
chart.marginBottom = 120
self._chart_data(chart, categories, rows)
return [chart]
示例10: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, x_label, y_label, data_provider):
def _get_label_with_percentage(row):
return "%s [%d: %s%%]" % (row[0]['html'], int(row[-2]['html']), str(int(row[-1]['html'][:-1])))
if isinstance(data_provider, NutritionBirthWeightDetails):
chart = PieChart(data_provider.chart_title, '',
[{'label': _get_label_with_percentage(row),
'value': int(row[-1]['html'][:-1])} for row in rows[2:]], ['red', 'green'])
chart.showLabels = False
chart.marginLeft = 20
chart.marginRight = 0
chart.marginBottom = 20
elif isinstance(data_provider, DeliveryPlaceDetailsExtended):
chart = PieChart(data_provider.chart_title, '',
[{'label': _get_label_with_percentage(row),
'value': int(row[-1]['html'][:-1])} for row in rows[1:]])
chart.showLabels = False
elif isinstance(data_provider, (PostnatalCareOverview, ImmunizationOverview)):
chart = MultiBarChart(data_provider.chart_title, x_axis=Axis(x_label), y_axis=Axis(y_label, '.2%'))
chart.rotateLabels = -45
chart.marginBottom = 150
chart.marginLeft = 45
chart.marginRight = 0
if isinstance(data_provider, ImmunizationOverview):
chart.stacked = True
chart.add_dataset('Percentage',
[{'x': row[0]['html'],
'y': int(row[3]['html'][:-1]) / 100.0} for row in rows],
color='green')
chart.add_dataset('Dropout Percentage',
[{'x': row[0]['html'],
'y': int(row[-1]['html'][:-1]) / 100.0} for row in rows],
color='red')
else:
chart.add_dataset('Percentage',
[{'x': row[0]['html'], 'y':int(row[-1]['html'][:-1]) / 100.0} for row in rows])
elif isinstance(data_provider, AnteNatalCareServiceOverviewExtended):
chart1 = MultiBarChart('ANC Visits', x_axis=Axis(x_label), y_axis=Axis(y_label, '.2%'))
chart2 = MultiBarChart('Maternal TT & IFA', x_axis=Axis(x_label), y_axis=Axis(y_label, '.2%'))
chart1.rotateLabels = -45
chart2.rotateLabels = -45
chart1.marginBottom = 150
chart2.marginBottom = 150
chart1.marginLeft = 20
chart2.marginLeft = 45
chart1.marginRight = 0
chart2.marginRight = 0
chart1.add_dataset('Percentage', [{'x': row[0]['html'],
'y': int(row[-1]['html'][:-1]) / 100.0} for row in rows[1:6]])
chart2.add_dataset('Percentage', [{'x': row[0]['html'],
'y': int(row[-1]['html'][:-1]) / 100.0} for row in rows[6:12]])
return [chart1, chart2]
elif isinstance(data_provider, ChildrenDeathsByMonth):
chart = MultiBarChart(data_provider.chart_title, x_axis=Axis(x_label, dateFormat="%B"),
y_axis=Axis(y_label, '.2%'))
chart.rotateLabels = -45
chart.marginBottom = 50
chart.marginLeft = 20
chart.add_dataset('Percentage', [{'x': row[0],
'y': int(row[-1]['html'][:-1]) / 100.0} for row in rows])
else:
chart = PieChart(data_provider.chart_title, '', [{'label': _get_label_with_percentage(row),
'value': int(row[-1]['html'][:-1])} for row in rows])
chart.showLabels = False
chart.marginLeft = 20
chart.marginRight = 0
chart.marginBottom = 0
return [chart]
示例11: get_chart
# 需要导入模块: from corehq.apps.reports.graph_models import MultiBarChart [as 别名]
# 或者: from corehq.apps.reports.graph_models.MultiBarChart import rotateLabels [as 别名]
def get_chart(self, rows, x_label, y_label, data_provider):
def _get_label_with_percentage(row):
return "%s [%d: %s%%]" % (row[0]["html"], int(row[-2]["html"]), str(int(row[-1]["html"][:-1])))
if isinstance(data_provider, NutritionBirthWeightDetails):
chart = PieChart(
data_provider.chart_title,
"",
[{"label": _get_label_with_percentage(row), "value": int(row[-1]["html"][:-1])} for row in rows[2:]],
["red", "green"],
)
chart.showLabels = False
chart.marginLeft = 20
chart.marginRight = 0
chart.marginBottom = 20
elif isinstance(data_provider, DeliveryPlaceDetailsExtended):
chart = PieChart(
data_provider.chart_title,
"",
[{"label": _get_label_with_percentage(row), "value": int(row[-1]["html"][:-1])} for row in rows[1:]],
)
chart.showLabels = False
elif isinstance(data_provider, (PostnatalCareOverview, ImmunizationOverview)):
chart = MultiBarChart(data_provider.chart_title, x_axis=Axis(x_label), y_axis=Axis(y_label, ".2%"))
chart.rotateLabels = -45
chart.marginBottom = 150
chart.marginLeft = 45
chart.marginRight = 0
if isinstance(data_provider, ImmunizationOverview):
chart.stacked = True
chart.add_dataset(
"Percentage",
[{"x": row[0]["html"], "y": int(row[3]["html"][:-1]) / 100.0} for row in rows],
color="green",
)
chart.add_dataset(
"Dropout Percentage",
[{"x": row[0]["html"], "y": int(row[-1]["html"][:-1]) / 100.0} for row in rows],
color="red",
)
else:
chart.add_dataset(
"Percentage", [{"x": row[0]["html"], "y": int(row[-1]["html"][:-1]) / 100.0} for row in rows]
)
elif isinstance(data_provider, AnteNatalCareServiceOverviewExtended):
chart1 = MultiBarChart("ANC Visits", x_axis=Axis(x_label), y_axis=Axis(y_label, ".2%"))
chart2 = MultiBarChart("Maternal TT & IFA", x_axis=Axis(x_label), y_axis=Axis(y_label, ".2%"))
chart1.rotateLabels = -45
chart2.rotateLabels = -45
chart1.marginBottom = 150
chart2.marginBottom = 150
chart1.marginLeft = 20
chart2.marginLeft = 45
chart1.marginRight = 0
chart2.marginRight = 0
chart1.add_dataset(
"Percentage", [{"x": row[0]["html"], "y": int(row[-1]["html"][:-1]) / 100.0} for row in rows[1:6]]
)
chart2.add_dataset(
"Percentage", [{"x": row[0]["html"], "y": int(row[-1]["html"][:-1]) / 100.0} for row in rows[6:12]]
)
return [chart1, chart2]
elif isinstance(data_provider, ChildrenDeathsByMonth):
chart = MultiBarChart(
data_provider.chart_title, x_axis=Axis(x_label, dateFormat="%B"), y_axis=Axis(y_label, ".2%")
)
chart.rotateLabels = -45
chart.marginBottom = 50
chart.marginLeft = 20
chart.add_dataset("Percentage", [{"x": row[0], "y": int(row[-1]["html"][:-1]) / 100.0} for row in rows])
else:
chart = PieChart(
data_provider.chart_title,
"",
[{"label": _get_label_with_percentage(row), "value": int(row[-1]["html"][:-1])} for row in rows],
)
chart.showLabels = False
chart.marginLeft = 20
chart.marginRight = 0
chart.marginBottom = 0
return [chart]