Categories are not working properly with horizontal stacked bars
I am trying to build a horizontal bar chart and am having issues with the automatic calculation of tickValues for the VictoryAxis.
Here is an image of the issue in question.

Clearly I am having an issue telling Victory which dataset to use for the automatic calculation of the tickValues, but I am not sure how to correctly change it.
Below is a simplification of the code I am using.
var React = require('react');
var VictoryBar = require('victory').VictoryBar;
var VictoryChart = require('victory').VictoryChart;
var VictoryAxis = require('victory').VictoryAxis;
var VictoryStack = require('victory').VictoryStack;
var StackedTest = function(props) {
var data = [
{
user: 'John',
apples: 50,
oranges: 10
},
{
user: 'Jane',
apples: 5,
oranges: 20
}
];
return (
<VictoryChart domainPadding={20}>
<VictoryAxis />
<VictoryAxis dependentAxis />
<VictoryStack
horizontal={true}
categories={data.map(function(datum) {return datum.user})}
>
<VictoryBar
horizontal={true}
data={data}
x="user"
y="apples"
/>
<VictoryBar
horizontal={true}
data={data}
x="user"
y="oranges"
/>
</VictoryStack>
</VictoryChart>
);
};
module.exports = StackedTest;
I was able to get it working by hard coding the tick values.
<VictoryAxis tickValues={[20, 40, 60]} />
<VictoryAxis dependentAxis />

Is there an easier way to do this or something I am missing in the definition of VictoryAxis? I really don't want to have to dynamically calculate the tick values outside of Victory for every chart.
@acarl categories should be given as an object with x and y. https://jsfiddle.net/boygirl/5ohsfz6c/
However, it does look like there's a bug with horizontal data with categories. I will change the title of this issue to reflect that.
Thanks! I can see the bug you are talking about when I change your example to a horizontal bar chart. https://jsfiddle.net/5ohsfz6c/2/ It only shows data for John.
I didn't realize you needed to specify categories as an object. The example given in the documentation has an array of strings. https://formidable.com/open-source/victory/docs/victory-stack/#categories
In the mean time would you recommend I calculate the tickValues manually or is there a better workaround before a bug fix?
@acarl you can do something like this in the meantime: https://jsfiddle.net/boygirl/5ohsfz6c/3/
I'll open an issue in our docs repo to fix the issue you mention.
That should work nicely. Thanks for your help.
This bug is still there but I am not able to access fiddle with workaround, can you repost it please?
I see the same issue with the JSFiddle. Here is a working version based on my first example. I can't remember if this was different from the JSFiddle, but it works.
var React = require('react');
var VictoryBar = require('victory').VictoryBar;
var VictoryChart = require('victory').VictoryChart;
var VictoryAxis = require('victory').VictoryAxis;
var VictoryStack = require('victory').VictoryStack;
var StackedTest = function(props) {
var data = [
{
user: 'John',
apples: 50,
oranges: 10
},
{
user: 'Jane',
apples: 5,
oranges: 20
}
];
return (
<VictoryChart domainPadding={20}>
<VictoryAxis
tickFormat={function(tick) {return tick}}
/>
<VictoryStack horizontal>
<VictoryBar
data={data}
x="user"
y="apples"
/>
<VictoryBar
data={data}
x="user"
y="oranges"
/>
</VictoryStack>
<VictoryAxis
dependentAxis
tickValues={[1, 2]}
tickFormat={['John','Jane']}
/>
</VictoryChart>
);
};
module.exports = StackedTest;
we should use https://codesandbox.io/ instead of jsfiddle
I believe this is fixed in the latest version, so I'm going to close this issue.