Skip to content

Per-axis separators attribute #1842

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

Closed
ndabAP opened this issue Jul 3, 2017 · 13 comments
Closed

Per-axis separators attribute #1842

ndabAP opened this issue Jul 3, 2017 · 13 comments
Labels
community community contribution feature something new

Comments

@ndabAP
Copy link

ndabAP commented Jul 3, 2017

var trace = {
  x: ['2000-01-30', '2000-01-31'],
  y: [1.5, 1.7],
  type: 'scatter' 
};

var data = [trace];

var layout = {
  xaxis: {
    type: 'date',
  },
  yaxis: {
    tickformat: ',.'
  },
};

Plotly.plot('myDiv', data, layout);

Last two axis labels are wrong and the comma format isn't applied. The problem doesn't occur when setting layout.separators = ',.'.

https://codepen.io/anon/pen/LLmWpm

@etpinard
Copy link
Contributor

etpinard commented Jul 3, 2017

What should it do? It's not obvious to me from reading the docs.

You might be looking for layout.separator attribute.

@ndabAP
Copy link
Author

ndabAP commented Jul 4, 2017

@etpinard, last two axis labels should be 1,65 and 1,7 not 000000 ... When I define layout.separator as ,. it works without any problem.

What if my x axis values should be comma decimal and my y axis should be dot decimal notation? E. G.:

x: 1.5, 1.7
y: 2.1, 2.5

should be displayed as

x: 1,5, 1,1
y: 2.1, 2.5

Is this possible?

@etpinard
Copy link
Contributor

etpinard commented Jul 4, 2017

Is this possible?

Yes, using layout.separators as in https://codepen.io/etpinard/pen/awKoBP?editors=0010

@ndabAP
Copy link
Author

ndabAP commented Jul 5, 2017

@etpinard, thanks for your answer. But it seems that it is not possible to set the separators independently per axis, e. g. yaxis2 has a different separator than yaxis. Is this correct?

@etpinard
Copy link
Contributor

etpinard commented Jul 5, 2017

But it seems that it is not possible to set the separators independently per axis, e. g. yaxis2 has a different separator than yaxis. Is this correct?

That's correct. layout.separators is a global setting and there's no corresponding per-axis attribute.

Can I ask? Why do you different separator styles on different axes?

@ndabAP
Copy link
Author

ndabAP commented Jul 5, 2017

Why do you different separator styles on different axes?

Sure. The user within my application can choose their column format which can be a comma or a dot decimal notation. They can upload data and visualize it. Maybe one source of the data has dot, another comma decimal notation. Either way, the user can choose their format.

@etpinard
Copy link
Contributor

etpinard commented Jul 5, 2017

Maybe one source of the data has dot, another comma decimal notation.

Hmm. But layout.seperators is meant to control the output format of those numbers on the graph. Wouldn't you want that to be consistent?

@ndabAP
Copy link
Author

ndabAP commented Jul 5, 2017

Wouldn't you want that to be consistent?

I can't make this decision. I let the user decide that. Also it's just the output, not the actual number. Maybe the user can't modify the data before he imports it into my application.

@etpinard
Copy link
Contributor

etpinard commented Jul 5, 2017

Ok. Well, we could add attributes xaxis.separtors and yaxis.separators that would either inherit from layout.separators or be set individually. I'll change the issue title accordingly.

This won't be a high priority item for the foreseeable future, so don't expect it getting implementing anytime soon, unless you're willing to make a PR to this repo.

@etpinard etpinard changed the title Setting "tickformat" to ",." results in strange result Per-axis separators attribute Jul 5, 2017
@etpinard etpinard added community community contribution feature something new labels Jul 5, 2017
@ndabAP
Copy link
Author

ndabAP commented Jul 12, 2017

Sounds great!

@ndabAP ndabAP closed this as completed Jul 12, 2017
@ndabAP ndabAP reopened this Jul 12, 2017
@alexcjohnson
Copy link
Collaborator

Also, similar to calendars #1220 - if your users are providing this data as text, not numbers, we currently only support parsing with '.' as the decimal separator. If we need to support other text formats (which may be independent of how you want to display the data in tick & hover labels) we'll need separators as a trace property too.

@alexcjohnson
Copy link
Collaborator

Coming back to this in the context of #2207 and my comment that we may consider removing separators altogether in v2 #420 (comment) and supporting only config.locale:

@ndabAP seems like you're concerned with interpreting numeric strings being passed into your system with different separators - potentially several different formats within the same graph? In principle this isn't even just per-axis OR per-trace, but per-data-array - so we'd need something like trace.xseparators and trace.marker.line.widthseparators etc etc... which makes me think that this doesn't really belong in plotly.js but at a higher level of application logic (ie sanitize the data before passing it to plotly.js) - kind of like how we don't accept dates in any string form besides (potentially truncated) ISO 8601 format.

And then as far as display (tick and hover labels) - even if we did support parsing different arrays within a plot differently, I think we want a single display format throughout the plot - whether based on layout.separators or config.locale - otherwise we're just inviting confusion.

@etpinard
Copy link
Contributor

This ticket most likely won't be implemented. Closing.

#1842 (comment) sums up our current state-of-mind on the topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution feature something new
Projects
None yet
Development

No branches or pull requests

3 participants