react-vis icon indicating copy to clipboard operation
react-vis copied to clipboard

VerticalBarSeries - strange xDomain behavior with time data

Open akindr opened this issue 9 years ago • 2 comments

When creating an VerticalBarSeries with a predefined xDomain and an xType of time, the chart is rendered with a vastly different time domain than the one specified.

Given the following example:

      // An arbitrary time range, in this case 1 hr
      <XYPlot
        xType="time"
        xDomain={[new Date().getTime() - 3600000, new Date().getTime()]}
        height={250}
        width={500}
      >
        <XAxis />
        <YAxis />
        <VerticalBarSeries
          data={[
            {x: new Date().getTime() - 1800000, y: 10}
          ]}/>
      </XYPlot>

The following is rendered: screen shot 2016-12-13 at 1 55 08 pm

The XYPlot attempts to adjust the domain by a small delta. However, the code which handles the edge case for one data entry (e.g., _computeLeftDomainAdjustment) subtracts 0.5 from the single data point, and you end up with a domain containing a negative timestamp and a timestamp in the far future.

Note I am not sure if this affects other series types, but it seems likely.

Is there a better domain adjustment that could be made here?

akindr avatar Dec 13 '16 19:12 akindr

@akindr I would actually endorse not using BarSeries for things on a continuous domain. Instead consider using RectSeries (the only difference is that you specify left and right edges of the box use x0 for left and x for right). BarSeries does weird auto positioning that is appropriate for categorical data, but makes weird distortions for continuous data

mcnuttandrew avatar Dec 14 '16 23:12 mcnuttandrew

I'm gonna close this as there is now a solution in place to address (rect series), let me know if i missed anythign

mcnuttandrew avatar Feb 20 '17 07:02 mcnuttandrew