Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2541: x-axis improvements. #2542

Merged
merged 1 commit into from
Jun 19, 2018
Merged

Conversation

emtwo
Copy link

@emtwo emtwo commented May 16, 2018

No description provided.

Copy link
Collaborator

@kravets-levko kravets-levko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me (small notices not required to be fixed)

@@ -102,6 +102,9 @@ function QueryResultService($resource, $timeout, $q) {
} else if (isString(v) && v.match(/^\d{4}-\d{2}-\d{2}$/)) {
row[k] = moment.utc(v);
newType = 'date';
} else if (v.match(/^\d{4}\d{2}\d{2}$/)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, this part of code (detecting date/time values) should be extended even more: it should accept all string in format YYYY<delimiter>MM<delimiter>DD (with optional T and the end) where <delimiter> is one of :/-. or empty. @arikfr WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this? ^\d{4}[:\/\-.]*\d{2}[:\/\-.]*\d{2}T*$

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moment can handle this properly, but this regex also matches strings like 2018-05.16, and I'm not sure if it's okay.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm. might be a more complicated regex statement to make sure both delimiters match... perhaps we can leave this as-is for now and have that in a separate issue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope.xAxisScales = [
{ label: 'default', value: '-' },
{ label: 'datetime' },
{ label: 'linear' },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to add value field to all items and remove that || in template.

Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm sure this will be very useful. Please see my comments.

@@ -102,6 +102,9 @@ function QueryResultService($resource, $timeout, $q) {
} else if (isString(v) && v.match(/^\d{4}-\d{2}-\d{2}$/)) {
row[k] = moment.utc(v);
newType = 'date';
} else if (v.match(/^\d{4}\d{2}\d{2}$/)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm missing something, this regex has potential for a lot of false detections. Basically any numeric column in the range of 10000000-99999999 will be detected as dates, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. I took the regex used above and removed the dashes but that makes the range of error worse than above. I've updated with a new regex pattern that is a little more restrictive.

<ui-select-match placeholder="Choose Scale...">{{$select.selected | capitalize}}</ui-select-match>
<ui-select-choices repeat="scaleType in xAxisScales">
<div ng-bind-html="scaleType | capitalize | highlight: $select.search"></div>
<ui-select-match placeholder="Choose Scale...">{{$select.selected.label | capitalize}}</ui-select-match>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label field is already supposed to be human friendly string, why not properly captialize instead of relaying on this filter?

@@ -77,7 +77,13 @@ function ChartEditor(ColorPalette, clientConfig) {
scope.chartTypes.custom = { name: 'Custom', icon: 'code' };
}

scope.xAxisScales = ['datetime', 'linear', 'logarithmic', 'category'];
scope.xAxisScales = [
{ label: 'default', value: '-' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Auto Detect is a better description?

@emtwo
Copy link
Author

emtwo commented May 28, 2018

@arikfr I addressed your comments. In terms of the regex concern, please see the comment I left. I updated it to be more restrictive but if we're still not ok with this, perhaps we can remove it entirely from this PR. For some context, the motivation for that change originally came from this issue in the mozilla fork: mozilla#338.

@arikfr
Copy link
Member

arikfr commented May 31, 2018

@emtwo thank you for the updates! As for the regex, while it limits the range, it can still wrongly detect large numbers as dates. As this is a Mozilla specific issue, I would prefer that you address it in some other way.

Some ideas --

  1. Change the format in the query itself (if it's frequently used, maybe create a view?), so it's properly loaded as a date value.
  2. Add some post processing code in the query runner(s) to update the format of these columns to a more universal one.

In the longer term, it can be great if the user could define the field types of the result set. Similar to how we do it now for the table visualization, but in a global way that will be used in all the visualizations. But this will take some time to implement properly...

@emtwo
Copy link
Author

emtwo commented May 31, 2018

@arikfr Thank you for those ideas! Indeed this is a fairly Mozilla-specific issue so I have taken that change out of this PR and we can re-evaluate how we'll handle it on our side.

This PR is now only for adding Auto Detect for the x-axis type.

@arikfr arikfr merged commit 5c1d2c8 into getredash:master Jun 19, 2018
@arikfr
Copy link
Member

arikfr commented Jun 19, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants