Я использую библиотеку GraphView для создания гистограммы, как показано на рисунке, мне нужно уменьшить ширину столбцов и увеличить расстояние между столбцами. Примечание. В настоящее время я получаю красные полосы, а то, что мне действительно нужно, показано черным.
Ниже приведен фрагмент кода для приведенного выше графика:
GraphViewSeriesStyle barStyle = new GraphViewSeriesStyle();
barStyle.thickness = 5;
barStyle.setValueDependentColor(new ValueDependentColor() {
@Override
public int get(GraphViewDataInterface data) {
return Color.rgb(205, 0, 0);
}
});
// init example series data
GraphViewSeries scoreSeries = new GraphViewSeries(
"HealthCare Bar Graph", barStyle, new GraphViewData[] {
new GraphViewData(1, rsCVD),
new GraphViewData(2, rsHypertension4),
new GraphViewData(3, rsHypertension2),
new GraphViewData(4, rsHypertension1) });
GraphView graphView = new BarGraphView(this // context
, "GRAPH_VIEW_HEADING" // heading
);
graphView.setHorizontalLabels(new String[] { "1", "2",
"3", "4" });
graphView.addSeries(scoreSeries);
graphView.setViewPort(0, 25);
graphView.setScalable(true);
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.BLACK);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.BLACK);
graphView.getGraphViewStyle().setTextSize(16);
graphView.getGraphViewStyle().setGridColor(Color.WHITE);
// graphView.getGraphViewStyle().setLegendWidth(legendWidth)
int maxValue = myScore+1;
// search the interval between 2 vertical labels
double interval;
if (maxValue >= 0 && maxValue < 3) {
interval = 0.5; // increment of 1 between each label
} else if (maxValue >= 3 && maxValue < 55) {
interval = 5; // increment of 5 between each label
} else if (maxValue >= 55 && maxValue <= 110) {
interval = 10; // increment of 10 between each label
} else {
interval = 20; // increment of 20 between each label
}
// search the top value of our graph
int maxLabel = maxValue;
while (maxLabel % interval != 0) {
maxLabel++;
}
// set manual bounds
graphView.setManualYAxisBounds(maxLabel, 0);
// indicate number of vertical labels
int numVerticalLabels = (int) ((int) maxLabel / interval + 1);
Log.v(TAG, "numVerticalLabels: " + numVerticalLabels);
graphView.getGraphViewStyle().setNumVerticalLabels(numVerticalLabels);
graphView.getGraphViewStyle().setVerticalLabelsWidth(20);
// graphView.getGraphViewStyle().setLegendWidth(20);
graphView.getGraphViewStyle().setLegendSpacing(30);
// LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
m_llayForRiskGraphContainer.addView(graphView);