@@ -25,6 +25,7 @@ import { unit } from '../../../../style/variables';
2525import Tooltip from '../Tooltip' ;
2626import theme from '@elastic/eui/dist/eui_theme_light.json' ;
2727import { tint } from 'polished' ;
28+ import { getTimezoneOffsetInMs } from '../CustomPlot/getTimezoneOffsetInMs' ;
2829
2930const XY_HEIGHT = unit * 10 ;
3031const XY_MARGIN = {
@@ -104,6 +105,9 @@ export class HistogramInner extends PureComponent {
104105 return null ;
105106 }
106107
108+ const isTimeSeries =
109+ this . props . xType === 'time' || this . props . xType === 'time-utc' ;
110+
107111 const xMin = d3 . min ( buckets , d => d . x0 ) ;
108112 const xMax = d3 . max ( buckets , d => d . x ) ;
109113 const yMin = 0 ;
@@ -120,11 +124,25 @@ export class HistogramInner extends PureComponent {
120124 . range ( [ XY_HEIGHT , 0 ] )
121125 . nice ( ) ;
122126
127+ const [ xMinZone , xMaxZone ] = [ xMin , xMax ] . map ( x => {
128+ return x - getTimezoneOffsetInMs ( x ) ;
129+ } ) ;
130+
131+ const xTickValues = isTimeSeries
132+ ? d3 . time . scale
133+ . utc ( )
134+ . domain ( [ xMinZone , xMaxZone ] )
135+ . range ( [ 0 , XY_WIDTH ] )
136+ . ticks ( X_TICK_TOTAL )
137+ . map ( x => {
138+ const time = x . getTime ( ) ;
139+ return new Date ( time + getTimezoneOffsetInMs ( time ) ) ;
140+ } )
141+ : undefined ;
142+
123143 const xDomain = x . domain ( ) ;
124144 const yDomain = y . domain ( ) ;
125145 const yTickValues = [ 0 , yDomain [ 1 ] / 2 , yDomain [ 1 ] ] ;
126- const isTimeSeries =
127- this . props . xType === 'time' || this . props . xType === 'time-utc' ;
128146 const shouldShowTooltip =
129147 hoveredBucket . x > 0 && ( hoveredBucket . y > 0 || isTimeSeries ) ;
130148
@@ -150,6 +168,7 @@ export class HistogramInner extends PureComponent {
150168 tickSizeInner = { 0 }
151169 tickTotal = { X_TICK_TOTAL }
152170 tickFormat = { formatX }
171+ tickValues = { xTickValues }
153172 />
154173 < YAxis
155174 tickSize = { 0 }
@@ -213,7 +232,7 @@ export class HistogramInner extends PureComponent {
213232 [ XY_MARGIN . left , XY_MARGIN . top ] ,
214233 [ XY_WIDTH , XY_HEIGHT ]
215234 ] }
216- nodes = { this . props . buckets . map ( bucket => {
235+ nodes = { buckets . map ( bucket => {
217236 return {
218237 ...bucket ,
219238 xCenter : ( bucket . x0 + bucket . x ) / 2
0 commit comments