css - Color Change in Area Chart -
i have java-class extends areachart. there implement method makes more or less this:
public void addnewcolortodata(xcoordinate, ycoordinate, redcolor, greencolor, bluecolor);
-> function should parameters of info xcoordinate, ycoordinate , rgb value of representes line.
is possible create inline-styles new color ?
here can see sample. there lot of color-fills area chart! possible add together there new colors?
i need add together inline style stuff in css:
.default-color0.chart-series-area-fill { -fx-fill: #007fc350; }
thank help
based on answer, create inline style based on r,g,b parameters (given these integers 0 255) need override chart_color_1
(up chart_color_8
) value modify line color , chart_color_1_trans_20
(up chart_color_8_trans_20
) modify area color:
private areachart<string, number> areachart; private void changecolor(int redcolor, int greencolor, int bluecolor, double opacity){ /* int redcolor=0, greencolor=127, bluecolor=195; double opacity=0.4; */ areachart.setstyle("chart_color_1: rgb("+redcolor+","+greencolor+","+bluecolor+");" + "chart_color_1_trans_20: rgba("+redcolor+","+greencolor+","+bluecolor+");"); }
edit
i'm adding short mvce sake of clarity:
@override public void start(stage primarystage) { areachart<string, number> areachart=new areachart<>(new categoryaxis(),new numberaxis()); observablelist<xychart.data<string,integer>> xylist = fxcollections.observablearraylist( new xychart.data<>("p1", 30), new xychart.data<>("p2", 40), new xychart.data<>("p3", 30)); xychart.series series = new xychart.series(xylist); areachart.getdata().addall(series); button button = new button("change style"); button.setonaction(e->{ int redcolor=0, greencolor=127, bluecolor=195; double opacity=0.3; areachart.setstyle("chart_color_1: rgb("+redcolor+","+greencolor+","+bluecolor+"); " + "chart_color_1_trans_20: rgba("+redcolor+","+greencolor+","+bluecolor+","+opacity+");"); }); vbox root = new vbox(5, button, areachart); scene scene = new scene(root, 400, 300); primarystage.setscene(scene); primarystage.show(); }
this result:
css javafx
No comments:
Post a Comment