I'm trying to make a line chart with String values in the X-Axis.
XYChart doesn't work because "Series data must be either Number or Date type" (as an exception message told me).
So I tried to use a CategoryChart with line rendering (as in your example).
This way it works, but the offset of the line's starting point is a bit too large for my taste.
This is how it looks:

And this is what I'd like:

I checked the API and also did some debugging, and there seems to be no way to configure this.
I found the xOffset variable in:
org.knowm.xchart.internal.chartpart.PlotContent_Category_Line_Area_Scatter.doPaint(Graphics2D)
As far as I can tell, we always add half a gridStep at the beginning.
If you don't have time for that, I would try to change this myself and then send a pull request, but I'd like your opinion.
- Should we try and alter the aforementioned part of the code (
PlotContent_Category_Line_Area_Scatter)? Maybe that half gridStep makes sense for bar charts, but for lines maybe it could be different.
- Should we change the
XYChart to accept Strings for the X-Axis? I'm thinking of using the index of the String array for the values, and the actual String only as a label.
Which variant makes more sense to you?
Or do you see another way of doing it?
I'm trying to make a line chart with String values in the X-Axis.


XYChartdoesn't work because "Series data must be either Number or Date type" (as an exception message told me).So I tried to use a
CategoryChartwith line rendering (as in your example).This way it works, but the offset of the line's starting point is a bit too large for my taste.
This is how it looks:
And this is what I'd like:
I checked the API and also did some debugging, and there seems to be no way to configure this.
I found the
xOffsetvariable in:org.knowm.xchart.internal.chartpart.PlotContent_Category_Line_Area_Scatter.doPaint(Graphics2D)As far as I can tell, we always add half a
gridStepat the beginning.If you don't have time for that, I would try to change this myself and then send a pull request, but I'd like your opinion.
PlotContent_Category_Line_Area_Scatter)? Maybe that halfgridStepmakes sense for bar charts, but for lines maybe it could be different.XYChartto accept Strings for the X-Axis? I'm thinking of using the index of the String array for the values, and the actual String only as a label.Which variant makes more sense to you?
Or do you see another way of doing it?