-
Notifications
You must be signed in to change notification settings - Fork 145
Chart Component: chart design feedback and updates #350
Conversation
@LevinMedia Could you take a look at the todos from your list? I'll handle the rest in the next PR. |
There was a problem hiding this 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?
client/components/chart/style.scss
Outdated
|
||
&.woocommerce-legend__item-checked { | ||
button { | ||
&:hover { |
There was a problem hiding this comment.
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?
client/components/chart/style.scss
Outdated
width: 100%; | ||
min-width: 100px; | ||
|
||
.key-colour { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 70ab5a5
client/components/chart/utils.js
Outdated
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved in 27c8537
There was a problem hiding this 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.
modified: client/components/chart/legend.js modified: client/components/chart/style.scss modified: package-lock.json
e5ded76
to
a60c72b
Compare
There was a problem hiding this 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:
pre-approving pending your feedback on @Aljullu notes
stroke: $core-grey-light-200; | ||
stroke-width: 1; | ||
shape-rendering: crispEdges; | ||
.tick { |
There was a problem hiding this comment.
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 😆
|
This may be an issue. The d3 format specifier that massages the number into an SI-Prefix ( I can probably write a manual specifier, which I could extract into the props. |
|
|
D3 Chart Component Master Thread: #164
Based on feedback from @LevinMedia - https://docs.google.com/document/d/1YuUh0kzaZ12ege3Lsi6JCB8FPN5uA3lx9Jlj0PB3qgE/edit
Chart
Tooltip