Victory: Warning: Failed prop type: Invalid prop `domain` supplied to `VictoryStack` when only one data point

Created on 19 Jul 2017  路  9Comments  路  Source: FormidableLabs/victory

Hi

I'm getting a "Failed prop type: Invalid prop "domain" supplied to "VictoryStack"" warning when my dataset contains only one data point. I tried setting a custom domain by supplying a range to VictoryChart:
` domain={{ x: [ dataPoint.x-1, dataPoint.x+1]}}

`
But I feel this is a very hacky approach.

FYI: The domain object calculated in getCalculatedProps() in "victory-chart.js"
(const domain = { x: ChartHelpers.getDomain(props, "x", childComponents), y: ChartHelpers.getDomain(props, "y", childComponents) };)
has the following content:
"{ "x": [ 1500415200000, 1500415200000 ], "y": [ 0, 45 ] }"

I hope somebody can help me get across my "hacky approach(!?)" :)

The warning message:

Warning: Failed prop type: Invalid prop domain supplied to VictoryStack.
in VictoryStack (created by BarChart)
in VictoryChart (created by BarChart)
in RCTView (created by View)
in View (created by BarChart)
in BarChart (created by Main)
in RCTView (created by View)
in View (created by Main)
in RCTView (created by View)
in View (created by _class)
in RCTScrollContentView (created by ScrollView)
in RCTScrollView (created by ScrollView)
in ScrollView (created by _class)
in RCTView (created by View)
in View (created by _class)
in _class (created by Main)
in RCTView (created by View)
in View (created by Main)
in RCTView (created by View)
in View (created by Main)
in RCTScrollContentView (created by ScrollView)
in RCTScrollView (created by ScrollView)
in ScrollView (created by Main)
in RCTView (created by View)
in View (created by Container)
in Container (created by Main)
in Main (created by Connect(Main))
in Connect(Main) (created by SceneView)
in SceneView (created by CardStack)
in RCTView (created by View)
in View (created by AnimatedComponent)
in AnimatedComponent (created by Card)
in Card (created by Container)
in Container (created by CardStack)
in RCTView (created by View)
in View (created by CardStack)
in RCTView (created by View)
in View (created by CardStack)
in CardStack (created by Transitioner)
in RCTView (created by View)
in View (created by Transitioner)
in Transitioner (created by CardStackTransitioner)
in CardStackTransitioner (created by Unknown)
in Unknown (created by Navigator)
in Navigator (created by NavigationContainer)
in NavigationContainer (created by RegistrationStackNavigatorComponent)
in RegistrationStackNavigatorComponent (created by Connect(RegistrationStackNavigatorComponent))
in Connect(RegistrationStackNavigatorComponent) (created by SceneView)
in SceneView (created by DrawerScreen)
in DrawerScreen (created by withCachedChildNavigation(DrawerScreen))
in withCachedChildNavigation(DrawerScreen) (created by Unknown)
in Unknown (created by Navigator)
in Navigator (created by DrawerView)
in RCTView (created by View)
in View (created by AnimatedComponent)
in AnimatedComponent (created by DrawerLayout)
in RCTView (created by View)
in View (created by DrawerLayout)
in DrawerLayout (created by DrawerView)
in DrawerView (created by Unknown)
in Unknown (created by Navigator)
in Navigator (created by NavigationContainer)
in NavigationContainer (created by MainDrawer)
in MainDrawer (created by Connect(MainDrawer))
in Connect(MainDrawer) (created by SceneView)
in SceneView (created by CardStack)
in RCTView (created by View)
in View (created by AnimatedComponent)
in AnimatedComponent (created by Card)
in Card (created by Container)
in Container (created by CardStack)
in RCTView (created by View)
in View (created by CardStack)
in RCTView (created by View)
in View (created by CardStack)
in CardStack (created by Transitioner)
in RCTView (created by View)
in View (created by Transitioner)
in Transitioner (created by CardStackTransitioner)
in CardStackTransitioner (created by Unknown)
in Unknown (created by Navigator)
in Navigator (created by NavigationContainer)
in NavigationContainer (created by App)
in RCTView (created by View)
in View (created by App)
in App (created by Connect(App))
in Connect(App) (created by Root)
in Provider (created by Root)
in Root
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer

Most helpful comment

Same issue occurring with 31.2.0


@boygirl I believe this should be reopened

All 9 comments

@jenskuhrjorgensen I believe this is fixed in the latest version of Victory ([email protected])

I'm seeing the same warning with [email protected]

<VictoryStack>
  <VictoryArea data={[{ x: 1505804400000, y: 2 }]} />
</VictoryStack>
warning.js:36 Warning: Failed prop type: Invalid prop `domain` supplied to `VictoryArea`.
    in VictoryArea (at index.js:62)
    in VictoryStack (at index.js:61)
    in SentimentStack (created by WithTheme(SentimentStack))
    in WithTheme(SentimentStack) (at SentimentStack.stories.js:46)
    in main (created by Base)
    in Base (created by Box)
    in Box (created by Styled(Box))
    in Styled(Box) (at index.js:23)
    in Unknown (created by Styled(Component))
    in Styled(Component) (created by Styled(Styled(Component)))
    in Styled(Styled(Component)) (at index.js:166)
    in section (created by styled.section)
    in styled.section (at index.js:154)
    in Card (at index.js:45)
    in withTabSelection(Card) (at SentimentStack.stories.js:40)
    in div (created by styled.div)
    in styled.div (at SentimentStack.stories.js:34)
    in ThemeProvider (at SentimentStack.stories.js:33)
    in div (created by styled.div)
    in styled.div (created by Provider)
    in ThemeProvider (created by Provider)
    in Provider (at config.js:21)
    in Router (created by BrowserRouter)
    in BrowserRouter (at config.js:20)

But with two points with different x values the warning goes away

<VictoryStack>
  <VictoryArea data={[{ x: 1505804400000, y: 2 }, { x: 1505804500000, y: 2 }]} />
</VictoryStack>

Digging into the proptype code, it looks like it'll accept as a valid a domain that is _either_:
{ x: [number. number], y: [number, number]} _or_ [number, number], and for any of those arrays, the numbers cannot be the same.

So in the OP's case, just specifying the x but not the y (which is what I'd been doing and why I ended up here) will run afoul of the proptypes declaration.

As for the poster directly above, I'm assuming it's not passing because with only one point, the x domain that's calculated automatically from the data would go from the minimum x value to the maximum x value, but since both are the same it's failing.

Can confirm that this has been fixed. I'm using version 0.16.5 of victory-native, which uses version 20.5.0 of victory-core. After upgrading from version 0.14.0 of victory-native the problem went away. Thanks @boygirl for the fix and thanks @jenskuhrjorgensen for reporting.

I'm using "victory-native": "^0.17.1" and this problem still exist.

I'm seeing this with "victory-native": "^30.6.0"

happens the same here, using the last version "victory": "^31.1.0",

Same issue occurring with 31.2.0


@boygirl I believe this should be reopened

Any updates of this issue? I've tried v33.0.5 and v34.0.0, the warning message still there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theinterned picture theinterned  路  3Comments

dinnayu picture dinnayu  路  3Comments

MrHen picture MrHen  路  3Comments

icd2k3 picture icd2k3  路  3Comments

robinwkurtz picture robinwkurtz  路  3Comments