Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Chart Component: chart design feedback and updates #350

Merged
merged 12 commits into from
Sep 7, 2018

Conversation

greenafrican
Copy link
Contributor

@greenafrican greenafrican commented Sep 4, 2018

D3 Chart Component Master Thread: #164

chart

Based on feedback from @LevinMedia - https://docs.google.com/document/d/1YuUh0kzaZ12ege3Lsi6JCB8FPN5uA3lx9Jlj0PB3qgE/edit

  • If a legend is unchecked, it’s hover interaction should be disabled
  • Add hover states to legends

Chart

  • Ensure 16px of padding on left and right edges of chart area
  • Left align text in y-axis ticks
  • Add vertical pipes to x-axis ticks
  • Add secondary label to x-axis (for month / year)
  • Massage the rounding on y-axis labels
  • Update zero (baseline) color

Tooltip

  • The Tool-tip and vertical line disappear if you hover directly over a point on the chart
  • Update styles to match design documentation

screenshot 2018-09-04 15 04 32

@greenafrican
Copy link
Contributor Author

@LevinMedia Could you take a look at the todos from your list? I'll handle the rest in the next PR.

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

It works great! Looks good to me. 🙂

I added a couple of suggestions in the code.

The Tool-tip and vertical line disappear if you hover directly over a point on the chart

Out of curiosity, why was that decision taken?


&.woocommerce-legend__item-checked {
button {
&:hover {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be written like:
&.woocommerce-legend__item-checked button:hover {
Is there any reason to prefer nesting?

width: 100%;
min-width: 100px;

.key-colour {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use color instead of colour to be consistent with CSS properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 70ab5a5

const yMax = Math.round(
4 / 3 * d3Max( lineData, d => d3Max( d.values.map( date => date.value ) ) )
);
const pow3Y = Math.pow( 10, ( ( Math.log( yMax ) * Math.LOG10E + 1 ) | 0 ) - 2 ) * 3;
Copy link
Contributor

@Aljullu Aljullu Sep 6, 2018

Choose a reason for hiding this comment

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

I think a comment here might help making this operation easier to understand.

Another solution would be splitting it into another function and adding a descriptive name to it:

const convertToPowerOf10 = value => {
	const pow3Y = Math.pow( 10, ( ( Math.log( value ) * Math.LOG10E + 1 ) | 0 ) - 2 ) * 3;
	return Math.ceil( value / pow3Y ) * pow3Y;
};

export const getYMax = lineData => {
	const yMax = 4 / 3 * d3Max( lineData, d => d3Max( d.values.map( date => date.value ) ) );
	return convertToPowerOf10( yMax );
};

(Probably a better name can be found)

What do you think? 🙂

I also think the Math.round() around yMax value can be removed, now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved in 27c8537

Copy link
Contributor

@LevinMedia LevinMedia left a comment

Choose a reason for hiding this comment

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

Looking good @greenafrican ! Per our convo this AM

Sorry for the confusion about the hover state / disable. The hover state on the legend should persist when a series is disabled - it's the behavior in the actual chart that should be disabled.

Add revenue symbols to y-axis legend, left align text.

Check ordering for the points on line - the tool tip is showing up consistently now, but the vertical line is still disappearing on hover directly over a point.

Robert Elliott added 5 commits September 6, 2018 18:15
	modified:   client/components/chart/legend.js
	modified:   client/components/chart/style.scss
	modified:   package-lock.json
Copy link
Contributor

@timmyc timmyc left a comment

Choose a reason for hiding this comment

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

Looking good to me as well - I am seeing some crowding on the axis labels, but I think that has already been noted:

image

pre-approving pending your feedback on @Aljullu notes

stroke: $core-grey-light-200;
stroke-width: 1;
shape-rendering: crispEdges;
.tick {
Copy link
Contributor

Choose a reason for hiding this comment

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

🐞 i loathe ticks - reading it makes me shudder 😆

@greenafrican
Copy link
Contributor Author

greenafrican commented Sep 7, 2018

Sorry for the confusion about the hover state / disable. The hover state on the legend should persist when a series is disabled - it's the behavior in the actual chart that should be disabled.

@greenafrican
Copy link
Contributor Author

Add revenue symbols to y-axis legend

This may be an issue. The d3 format specifier that massages the number into an SI-Prefix (M for millions etc.) isn't compatible with the Intl.NumberFormatter at the moment. It seems as though there may be an effort to support this here - tc39/ecma402#37

I can probably write a manual specifier, which I could extract into the props.

@greenafrican
Copy link
Contributor Author

...legend, left align text.

@greenafrican
Copy link
Contributor Author

greenafrican commented Sep 7, 2018

vertical line is still disappearing on hover directly over a point.

@greenafrican
Copy link
Contributor Author

greenafrican commented Sep 7, 2018

Add revenue symbols

@greenafrican greenafrican merged commit b576012 into master Sep 7, 2018
@ryelle ryelle deleted the fix/chart-design-feedback branch October 9, 2018 14:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants