dataviz: add an option to print values directly on chart (#68944)
gitea/combo/pipeline/head This commit looks good
Details
gitea/combo/pipeline/head This commit looks good
Details
This commit is contained in:
parent
af473d684e
commit
dc124d92f1
|
@ -190,6 +190,7 @@ class ChartNgForm(ChartFiltersMixin, forms.ModelForm):
|
|||
'height',
|
||||
'sort_order',
|
||||
'hide_null_values',
|
||||
'print_values',
|
||||
)
|
||||
widgets = {
|
||||
'time_range_start': forms.DateInput(attrs={'type': 'date'}, format='%Y-%m-%d'),
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 3.2.18 on 2024-04-22 12:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('dataviz', '0029_chartngcell_display_total'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='chartngcell',
|
||||
name='print_values',
|
||||
field=models.BooleanField(
|
||||
default=False,
|
||||
help_text='When not checked values are printed on hover.',
|
||||
verbose_name='Print values on chart',
|
||||
),
|
||||
),
|
||||
]
|
|
@ -288,6 +288,12 @@ class ChartNgCell(CellBase):
|
|||
help_text=_('This setting only applies for one-dimensional charts.'),
|
||||
)
|
||||
|
||||
print_values = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=_('Print values on chart'),
|
||||
help_text=_('When not checked values are printed on hover.'),
|
||||
)
|
||||
|
||||
manager_form_template = 'combo/chartngcell_form.html'
|
||||
|
||||
invalid_reason_codes = {
|
||||
|
@ -384,7 +390,11 @@ class ChartNgCell(CellBase):
|
|||
'dot': pygal.Dot,
|
||||
'table': pygal.Bar,
|
||||
'table-inverted': pygal.Bar,
|
||||
}[self.chart_type](config=pygal.Config(style=copy.copy(style), order_min=0.1, max_scale=5))
|
||||
}[self.chart_type](
|
||||
config=pygal.Config(
|
||||
style=copy.copy(style), order_min=0.1, max_scale=5, print_values=self.print_values
|
||||
)
|
||||
)
|
||||
|
||||
if self.statistic.service_slug == 'bijoe':
|
||||
x_labels, y_labels, data = self.parse_response(response, chart)
|
||||
|
|
|
@ -1127,6 +1127,25 @@ def test_chartng_cell_hide_null_values_new_api(app, new_api_statistics):
|
|||
]
|
||||
|
||||
|
||||
@with_httmock(bijoe_mock)
|
||||
def test_chartng_cell_print_values(app, statistics):
|
||||
page = Page(title='One', slug='index')
|
||||
page.save()
|
||||
|
||||
cell = ChartNgCell(page=page, order=1)
|
||||
cell.statistic = Statistic.objects.get(slug='example')
|
||||
cell.print_values = False
|
||||
cell.save()
|
||||
|
||||
chart = cell.get_chart()
|
||||
assert chart.config.print_values is False
|
||||
|
||||
cell.print_values = True
|
||||
cell.save()
|
||||
chart = cell.get_chart()
|
||||
assert chart.config.print_values is True
|
||||
|
||||
|
||||
@with_httmock(bijoe_mock)
|
||||
def test_chartng_cell_sort_order_alpha(app, statistics):
|
||||
page = Page(title='One', slug='index')
|
||||
|
|
Loading…
Reference in New Issue