javafx - How to set border color in Line Chart -
i have linechart graph. want color rectangular border of graph area.
"-fx-border-color: black transparent transparent transparent;" add border x-axis or y-axis.
"-fx-border-color: black" add border around complete chart.
but need border around graph area shown in attachment
any useful.
thanks
border css
.chart-plot-background { -fx-border-color: red; -fx-border-style: solid; -fx-border-width: 4px; -fx-border-insets: -2px; }
gives this:
the green border around chart plot content css above provides.
on dotted lines
you notice there dashed lines , axes drawn on top of green border. perhaps want border behind lines, perhaps want on top, perhaps don't want draw dotted lines @ all.
if fine have border behind dotted lines don't need else.
if don't want draw dotted lines, can remove them:
linechart.setalternativerowfillvisible(false); linechart.setalternativecolumnfillvisible(false); linechart.sethorizontalgridlinesvisible(false); linechart.setverticalgridlinesvisible(false);
and adjust insets of bounding rectangle accordingly:
.chart-plot-background { -fx-border-color: forestgreen; -fx-border-style: solid; -fx-border-width: 4px; -fx-border-insets: 0 0 0 1; }
if want keep dotted lines , draw rectangle on top of chart, can place chart in stackpane, run chart.lookup(".chart-plot-background")
after chart has been displayed, monitor bounds of resultant chart background node , add new rectangle top of stack bound chart background bounds, in layout bounds demo. don't want though.
how stuff yourself
using tools scenicview or css analyzer in scenebuilder, or studying css reference guide or modena.css file in jfxrt.jar
shipped jre can determine css rules need.