mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Adding option for reduceXTicks (#640)
This commit is contained in:
parent
78eb1e6a54
commit
55c549d86f
@ -36,6 +36,7 @@ function nvd3Vis(slice) {
|
|||||||
var fd = payload.form_data;
|
var fd = payload.form_data;
|
||||||
var viz_type = fd.viz_type;
|
var viz_type = fd.viz_type;
|
||||||
var f = d3.format('.3s');
|
var f = d3.format('.3s');
|
||||||
|
var reduceXTicks = fd.reduce_x_ticks || false;
|
||||||
|
|
||||||
nv.addGraph(function () {
|
nv.addGraph(function () {
|
||||||
switch (viz_type) {
|
switch (viz_type) {
|
||||||
@ -63,7 +64,9 @@ function nvd3Vis(slice) {
|
|||||||
.showControls(true)
|
.showControls(true)
|
||||||
.groupSpacing(0.1);
|
.groupSpacing(0.1);
|
||||||
|
|
||||||
width = barchartWidth();
|
if (!reduceXTicks) {
|
||||||
|
width = barchartWidth();
|
||||||
|
}
|
||||||
chart.width(width);
|
chart.width(width);
|
||||||
chart.xAxis
|
chart.xAxis
|
||||||
.showMaxMin(false)
|
.showMaxMin(false)
|
||||||
@ -75,7 +78,7 @@ function nvd3Vis(slice) {
|
|||||||
case 'dist_bar':
|
case 'dist_bar':
|
||||||
chart = nv.models.multiBarChart()
|
chart = nv.models.multiBarChart()
|
||||||
.showControls(true) //Allow user to switch between 'Grouped' and 'Stacked' mode.
|
.showControls(true) //Allow user to switch between 'Grouped' and 'Stacked' mode.
|
||||||
.reduceXTicks(false)
|
.reduceXTicks(reduceXTicks)
|
||||||
.rotateLabels(45)
|
.rotateLabels(45)
|
||||||
.groupSpacing(0.1); //Distance between each group of bars.
|
.groupSpacing(0.1); //Distance between each group of bars.
|
||||||
|
|
||||||
@ -83,7 +86,9 @@ function nvd3Vis(slice) {
|
|||||||
.showMaxMin(false);
|
.showMaxMin(false);
|
||||||
|
|
||||||
chart.stacked(fd.bar_stacked);
|
chart.stacked(fd.bar_stacked);
|
||||||
width = barchartWidth();
|
if (!reduceXTicks) {
|
||||||
|
width = barchartWidth();
|
||||||
|
}
|
||||||
chart.width(width);
|
chart.width(width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -225,6 +225,16 @@ class FormFactory(object):
|
|||||||
"default": False,
|
"default": False,
|
||||||
"description": ""
|
"description": ""
|
||||||
}),
|
}),
|
||||||
|
'reduce_x_ticks': (BetterBooleanField, {
|
||||||
|
"label": _("Reduce X ticks"),
|
||||||
|
"default": False,
|
||||||
|
"description": (
|
||||||
|
"Reduces the number of X axis ticks to be rendered. "
|
||||||
|
"If true, the x axis wont overflow and labels may be "
|
||||||
|
"missing. If false, a minimum width will be applied "
|
||||||
|
"to columns and the width may overflow into an "
|
||||||
|
"horizontal scroll."),
|
||||||
|
}),
|
||||||
'include_series': (BetterBooleanField, {
|
'include_series': (BetterBooleanField, {
|
||||||
"label": _("Include Series"),
|
"label": _("Include Series"),
|
||||||
"default": False,
|
"default": False,
|
||||||
@ -562,7 +572,7 @@ class FormFactory(object):
|
|||||||
"default": '',
|
"default": '',
|
||||||
}),
|
}),
|
||||||
'y_axis_label': (TextField, {
|
'y_axis_label': (TextField, {
|
||||||
"label": _("X Axis Label"),
|
"label": _("Y Axis Label"),
|
||||||
"default": '',
|
"default": '',
|
||||||
}),
|
}),
|
||||||
'where': (TextField, {
|
'where': (TextField, {
|
||||||
|
@ -1075,6 +1075,7 @@ class NVD3TimeSeriesBarViz(NVD3TimeSeriesViz):
|
|||||||
('line_interpolation', 'bar_stacked'),
|
('line_interpolation', 'bar_stacked'),
|
||||||
('x_axis_showminmax', 'bottom_margin'),
|
('x_axis_showminmax', 'bottom_margin'),
|
||||||
('x_axis_label', 'y_axis_label'),
|
('x_axis_label', 'y_axis_label'),
|
||||||
|
('reduce_x_ticks', None),
|
||||||
), }] + [NVD3TimeSeriesViz.fieldsets[2]]
|
), }] + [NVD3TimeSeriesViz.fieldsets[2]]
|
||||||
|
|
||||||
|
|
||||||
@ -1158,6 +1159,7 @@ class DistributionBarViz(DistributionPieViz):
|
|||||||
('show_legend', 'bar_stacked'),
|
('show_legend', 'bar_stacked'),
|
||||||
('y_axis_format', 'bottom_margin'),
|
('y_axis_format', 'bottom_margin'),
|
||||||
('x_axis_label', 'y_axis_label'),
|
('x_axis_label', 'y_axis_label'),
|
||||||
|
('reduce_x_ticks', None),
|
||||||
)
|
)
|
||||||
},)
|
},)
|
||||||
form_overrides = {
|
form_overrides = {
|
||||||
|
Loading…
Reference in New Issue
Block a user