Код: Выделить всё
HIOptions options = new HIOptions();
HITitle title = new HITitle();
title.setText("Stacked column chart");
options.setTitle(title);
HISubtitle subtitle = new HISubtitle();
subtitle.setText("Plain");
options.setSubtitle(subtitle);
HIXAxis xaxis = new HIXAxis();
xaxis.setCategories(new ArrayList(Arrays.asList("Appled", "Oranges", "Pears", "Grapes", "Bananas")));
options.setXAxis(new ArrayList(Collections.singletonList(xaxis)));
HIYAxis yaxis = new HIYAxis();
yaxis.setMin(0);
yaxis.setTitle(new HITitle());
yaxis.getTitle().setText("Total fruit consumption");
yaxis.setStackLabels(new HIStackLabels());
yaxis.getStackLabels().setEnabled(true);
yaxis.getStackLabels().setStyle(new HICSSObject());
yaxis.getStackLabels().getStyle().setFontWeight("bold");
yaxis.getStackLabels().getStyle().setColor("gray");
options.setYAxis(new ArrayList(Collections.singletonList(yaxis)));
HILegend legend = new HILegend();
legend.setAlign("right");
legend.setX(-30);
legend.setVerticalAlign("top");
legend.setY(25);
legend.setFloating(true);
legend.setBackgroundColor(HIColor.initWithName("white"));
legend.setBorderColor(HIColor.initWithHexValue("ccc"));
legend.setBorderWidth(1);
// legend.setShadow(false);
options.setLegend(legend);
HITooltip tooltip = new HITooltip();
tooltip.setPointFormat("{series.name}: {point.y}
Total: {point.stackTotal}");
tooltip.setHeaderFormat("{point.x}[/b]
");
options.setTooltip(tooltip);
HIPlotOptions plotoptions = new HIPlotOptions();
plotoptions.setColumn(new HIColumn());
plotoptions.getColumn().setStacking("normal");
options.setPlotOptions(plotoptions);
HIColumn column1 = new HIColumn();
column1.setName("John");
Number[] column1Data = new Number[]{5, 3, 4, 7, 2};
String[] column1DataColor1 = new String[]{"#8B008B", "#8B008B", "#8B008B", "#8B008B", "#8B008B"};
column1.setData(new ArrayList(Arrays.asList(column1Data)));
column1.setColors(new ArrayList(Arrays.asList(column1DataColor1)));
HIColumn column2 = new HIColumn();
column2.setName("Jane");
Number[] column2Data = new Number[]{2, 2, 3, 2, 1};
String[] column1DataColor2 = new String[]{"#5F9EA0", "#5F9EA0", "#5F9EA0", "#5F9EA0", "#5F9EA0"};
column2.setData(new ArrayList(Arrays.asList(column2Data)));
column2.setColors(new ArrayList(Arrays.asList(column1DataColor2)));
options.setSeries(new ArrayList(Arrays.asList(column1, column2)));
chartView.setOptions(options);
[img]https://i.sstatic. net/LE30CKdr.png[/img]
Здесь я хочу изменить два цвета графика, для этого я использую приведенный ниже код, но он не работает.
Код: Выделить всё
String[] column1DataColor1 = new String[]{"#8B008B", "#8B008B", "#8B008B", "#8B008B", "#8B008B"};
column1.setColors(new ArrayList(Arrays.asList(column1DataColor1)));
String[] column1DataColor2 = new String[]{"#5F9EA0", "#5F9EA0", "#5F9EA0", "#5F9EA0", "#5F9EA0"};
column2.setColors(new ArrayList(Arrays.asList(column1DataColor2)));
Код: Выделить всё
options.setColors(new ArrayList(Arrays.asList(column1DataColor1)));
Заранее спасибо
Подробнее здесь: https://stackoverflow.com/questions/790 ... igh-charts