mirror of
https://github.com/apache/superset.git
synced 2024-09-17 19:19:38 -04:00
Merge pull request #86 from bradmbaker/brad_adding_new_and_improved_date_formats
adjusting date formats
This commit is contained in:
commit
dcd36780ef
@ -9,14 +9,13 @@ function viz_nvd3(data_attribute) {
|
|||||||
return v = new Date(dttm.getUTCFullYear(), dttm.getUTCMonth(), dttm.getUTCDate(), dttm.getUTCHours(), dttm.getUTCMinutes(), dttm.getUTCSeconds());
|
return v = new Date(dttm.getUTCFullYear(), dttm.getUTCMonth(), dttm.getUTCDate(), dttm.getUTCHours(), dttm.getUTCMinutes(), dttm.getUTCSeconds());
|
||||||
}
|
}
|
||||||
var tickMultiFormat = d3.time.format.multi([
|
var tickMultiFormat = d3.time.format.multi([
|
||||||
[".%L", function(d) { return d.getMilliseconds(); }],
|
[".%L", function(d) { return d.getMilliseconds(); }], // If there are millisections, show only them
|
||||||
[":%S", function(d) { return d.getSeconds(); }],
|
[":%S", function(d) { return d.getSeconds(); }], // If there are seconds, show only them
|
||||||
["%I:%M", function(d) { return d.getMinutes(); }],
|
["%a %b %d, %I:%M %p", function(d) { return d.getMinutes()!=0; }], // If there are non-zero minutes, show Date, Hour:Minute [AM/PM]
|
||||||
["%I %p", function(d) { return d.getHours(); }],
|
["%a %b %d, %I %p", function(d) { return d.getHours() != 0; }], // If there are hours that are multiples of 3, show date and AM/PM
|
||||||
["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }],
|
["%a %b %d, %Y", function(d) { return d.getDate() != 1; }], // If not the first of the month, do "month day, year."
|
||||||
["%b %d", function(d) { return d.getDate() != 1; }],
|
["%B %Y", function(d) { return d.getMonth() != 0 && d.getDate() == 1; }], // If the first of the month, do "month day, year."
|
||||||
["%B", function(d) { return d.getMonth(); }],
|
["%Y", function(d) { return true; }] // fall back on month, year
|
||||||
["%Y", function() { return true; }]
|
|
||||||
]);
|
]);
|
||||||
function formatDate(dttm) {
|
function formatDate(dttm) {
|
||||||
var d = UTC(new Date(dttm));
|
var d = UTC(new Date(dttm));
|
||||||
@ -44,7 +43,8 @@ function viz_nvd3(data_attribute) {
|
|||||||
chart.lines2.xScale(d3.time.scale.utc());
|
chart.lines2.xScale(d3.time.scale.utc());
|
||||||
chart.x2Axis
|
chart.x2Axis
|
||||||
.showMaxMin(viz.form_data.x_axis_showminmax)
|
.showMaxMin(viz.form_data.x_axis_showminmax)
|
||||||
.tickFormat(formatDate);
|
.tickFormat(formatDate)
|
||||||
|
.staggerLabels(true);
|
||||||
} else {
|
} else {
|
||||||
chart = nv.models.lineChart()
|
chart = nv.models.lineChart()
|
||||||
}
|
}
|
||||||
@ -54,9 +54,13 @@ function viz_nvd3(data_attribute) {
|
|||||||
chart.interpolate(viz.form_data.line_interpolation);
|
chart.interpolate(viz.form_data.line_interpolation);
|
||||||
chart.xAxis
|
chart.xAxis
|
||||||
.showMaxMin(viz.form_data.x_axis_showminmax)
|
.showMaxMin(viz.form_data.x_axis_showminmax)
|
||||||
.tickFormat(formatDate);
|
.tickFormat(formatDate)
|
||||||
|
.staggerLabels(true);
|
||||||
chart.showLegend(viz.form_data.show_legend);
|
chart.showLegend(viz.form_data.show_legend);
|
||||||
chart.yAxis.tickFormat(d3.format('.3s'));
|
chart.yAxis.tickFormat(d3.format('.3s'));
|
||||||
|
if (chart.y2Axis != undefined) {
|
||||||
|
chart.y2Axis.tickFormat(d3.format('.3s'));
|
||||||
|
}
|
||||||
if (viz.form_data.contribution || viz.form_data.num_period_compare) {
|
if (viz.form_data.contribution || viz.form_data.num_period_compare) {
|
||||||
chart.yAxis.tickFormat(d3.format('.3p'));
|
chart.yAxis.tickFormat(d3.format('.3p'));
|
||||||
if (chart.y2Axis != undefined) {
|
if (chart.y2Axis != undefined) {
|
||||||
@ -125,6 +129,8 @@ function viz_nvd3(data_attribute) {
|
|||||||
chart.yAxis.tickFormat(d3.format('.3s'));
|
chart.yAxis.tickFormat(d3.format('.3s'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make space for labels on right
|
||||||
|
chart.height($(".chart").height() - 50).margin({"right": 50});
|
||||||
if ((viz_type === "line" || viz_type === "area") && viz.form_data.rich_tooltip) {
|
if ((viz_type === "line" || viz_type === "area") && viz.form_data.rich_tooltip) {
|
||||||
chart.useInteractiveGuideline(true);
|
chart.useInteractiveGuideline(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user