-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix datachart bug for single chart data #7020
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -527,7 +527,7 @@ const DataChart = forwardRef( | |
series.forEach(({ property, render }) => { | ||
if ( | ||
!render && | ||
data.length > 1 && | ||
data.length >= 1 && | ||
typeof data[0][property] === 'string' | ||
) { | ||
result[property] = createDateFormat( | ||
|
@@ -547,7 +547,8 @@ const DataChart = forwardRef( | |
if (!property || (!horizontal && y) || (horizontal && !y)) { | ||
if (render) return render(value); | ||
} else { | ||
const datum = data[axisValue]; | ||
// const datum = data[axisValue]; | ||
const datum = data[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change causes an issue with the axis labels. If we have the following code we end up with two xaxis labels that are the same value (Jun 23) coming from data[0].
|
||
value = datum[property]; | ||
if (render) return render(value, datum, property); | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -78,7 +78,13 @@ export const createDateFormat = (firstValue, lastValue, full) => { | |||||||||||||||||
) { | ||||||||||||||||||
const delta = Math.abs(endDate - startDate); | ||||||||||||||||||
let options; | ||||||||||||||||||
if (delta < 60000) | ||||||||||||||||||
if (delta === 0) | ||||||||||||||||||
// equal 0 - single data point | ||||||||||||||||||
options = { | ||||||||||||||||||
month: full ? 'short' : 'numeric', | ||||||||||||||||||
day: 'numeric', | ||||||||||||||||||
}; | ||||||||||||||||||
else if (delta < 60000) | ||||||||||||||||||
Comment on lines
+81
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Lets revert this change back, I don't think we need to adjust this |
||||||||||||||||||
// less than 1 minute | ||||||||||||||||||
options = full | ||||||||||||||||||
? { | ||||||||||||||||||
|
@@ -96,7 +102,7 @@ export const createDateFormat = (firstValue, lastValue, full) => { | |||||||||||||||||
else if (delta < 86400000) | ||||||||||||||||||
// less than 1 day | ||||||||||||||||||
options = { hour: 'numeric' }; | ||||||||||||||||||
else if (delta < 2592000000) | ||||||||||||||||||
else if (delta < 2592000000 || delta === 0) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's revert this change as well |
||||||||||||||||||
// less than 30 days | ||||||||||||||||||
options = { | ||||||||||||||||||
month: full ? 'short' : 'numeric', | ||||||||||||||||||
|
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 we should revert this change back. If we only have 1 data point we don't need the createDateFormat code