Quoting @vedder: “…having a chart with over 255 data series…”
How should anybody “read” such a visualization?
Quoting @vedder: “I managed this with a macro that picked the colour for each series based on the cell colour of its header.”
There are lots of chart types. There will be significant differences concerning the issue under discussion! I very rarely use charts of any type but “X-Y (Scatter)”. This type for visualizing ordinary functions (or empiric data under the assumption they might be generated by a function) does not allow to assign colors to the series except via the chart formatting dialogs - as far as I know.
Column diagrams wich I use sometimes allow to take the fill-colors and the border-colors per column from a dedicated range containing the RGB values.
To get the RGB values based on a sample cell, there is no standard function. However, a user function for the purpose is easily written. The one problem insofar is that Calc (as opposed to Excel with VBA) doesn’t pass an ordinary reference as a CellRange to the user function. Thus you need to pass the position of the sample cell either by address (string!) or by coordinates (3 numbers for Row, Column, and Sheet). See the attached demo containing such a user function going the coordinate way.
For your intended use case the most serious problem might be that there not seems to ba a way to cause the legend to accept coloring information from cells. I don’t need enough about the Chart model of LibreOffice to suggest a solution for this second problem by user code, and also not if there is one at all.