carbon-design-system / carbon-charts

:bar_chart: :chart_with_upwards_trend:⠀Robust dataviz framework implemented using D3 & typescript
https://charts.carbondesignsystem.com
Apache License 2.0
908 stars 184 forks source link

legend alignment to the axes #421

Open mjabbink opened 4 years ago

mjabbink commented 4 years ago

@shixiedesign

mjabbink commented 4 years ago

current sample title too tight to chart:

Screen Shot 2019-12-04 at 3 45 49 PM
theiliad commented 4 years ago

We should create separate GitHub issues for items that aren't really relevant.

This'll help us easily track the progress of each of the items.

Since @shixiedesign's now created #426 I will remove the part about space under title from this issue

shixiedesign commented 4 years ago

Hey Mike, regarding legend should left align with Y-axis, what about when legend is on top of Chart? Is this left align with Y only applicable when legend is below chart?

Already made an issue for Chart title and dev team is aware.

mjabbink commented 4 years ago

It should stay left align when on the top with title and align left to title in a donut/pie chart.

I’ve also been researching X and Y axis and also think the Y-axis can be on the right side as on option. Many data viZ charts do this. I could certainly be a good option in many use cases.

theiliad commented 4 years ago

I like that idea. I originally was making a PR to right-align the legend on pie & donut for design to review, but left also seems like a very good idea.

mjabbink commented 4 years ago
Screen Shot 2019-12-09 at 8 16 19 AM Screen Shot 2019-12-09 at 8 17 50 AM
mjabbink commented 4 years ago

Bloomberg and Google have options for the Y-axis to be on the right side as well as some others.

theiliad commented 4 years ago

Currently you can show y-axis on left or right, and x-axis on top or bottom, so it's not really something we're missing.

However we still need axis positions that we set as default, which so far have been left y-axis and bottom x-axis for all charts (which again can be customized by user)

mjabbink commented 4 years ago

Oh, ok this is good. We should then show some visuals in Carbon site that show right side Y-axis. I have a long list of changes for the Carbon site we’ll get into during new year.

theiliad commented 4 years ago

For sure @mjabbink.

I'm looking for some guidance around min/max width values for the legend.

When we position the legend to the right or left side, we'd want to make sure that longer labels don't cause the legend to take over a significant amount of the chart container.

mjabbink commented 4 years ago

@theiliad Do we need to make a separate issue to move Y axis to right side. To me this should be default for a handful of charts like Line, curved line area, horizontal bar and even bar. Left side should be an option

Even scatter plot.

Additionally an option for x axis to be top is also very useful

mjabbink commented 4 years ago

Also wondering I’d we allow x axis to be 90 degrees vs. the games type in mobile. If mobile is important to support the diagonal can break more easily and running type on 99 can be good for the mobile use case

theiliad commented 4 years ago

@theiliad Do we need to make a separate issue to move Y axis to right side. To me this should be default for a handful of charts like Line, curved line area, horizontal bar and even bar. Left side should be an option

Even scatter plot.

Additionally an option for x axis to be top is also very useful

You can currently move y-axis to the right and the x-axis to the top in the library (and you could also have each one in both places, e.g. 1 x-axis in bottom and 1 in top)

I personally don't think it makes a ton of sense to move the axis to the other side by default, all examples I find have their main axis on the bottom and left sides by default.

In mathematics as well you're always looking at the bottom left since that is where the origin of the domain & range start.

image https://www.mathsisfun.com/sets/domain-range-codomain.html

Let me know what you think about that

theiliad commented 4 years ago

Also wondering I’d we allow x axis to be 90 degrees vs. the games type in mobile. If mobile is important to support the diagonal can break more easily and running type on 99 can be good for the mobile use case

Not sure I understood the ask here, could you please rephrase @mjabbink