How to get color of dataset? #503
-
First, many thanks for great job and really excellent library! My rather simple question: is it possible to get the color value assigned to the dataset line by a renderer (particulary strokeColor)? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
@AValov76 if you have set them manually via public static void setLineScheme(final GraphicsContext gc, final String defaultStyle, final int dsIndex) {
AssertUtils.gtEqThanZero("setLineScheme dsIndex", dsIndex);
final Map<String, List<String>> map = splitQuery(defaultStyle);
final Color lineColor = StyleParser.getColorPropertyValue(defaultStyle, XYChartCss.DATASET_STROKE_COLOR);
final double[] lineDash = StyleParser.getStrokeDashPropertyValue(defaultStyle, XYChartCss.STROKE_DASH_PATTERN);
final Color rawColor = lineColor == null ? getStrokeColor(dsIndex) : lineColor;
gc.setLineWidth(defaultStrokeLineWidthProperty().get());
gc.setLineDashes(lineDash);
gc.setFill(getFill(dsIndex));
gc.setStroke(getColorModifier(map, rawColor));
} Here You may also have a look at how these are being used in the ErrorDataSetRenderer. Hope this helps. Please share a screenshot of your application. We always love to hear/see how our litte library is being used. |
Beta Was this translation helpful? Give feedback.
-
@RalphSteinhagen , thank you for the answer. It's turned out that I have one renderer per dataset (because I need different DataPointTooltips per graph in a single chart) and I've taken simple approach just getting the color from DefaultRenderColorScheme.TUNEVIEWER by index as it's ok in my case keep track of added/removed datesets. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
@AValov76 if you have set them manually via
DataSet::setStyle(...)
, you may want to have a look at the snippets in DefaultRenderColorScheme and retrieve them via for example: