package com.webonlineapp;

import java.util.Arrays;

import com.hyjavaapex.chart.Apexchart;
import com.hyjavaapex.model.apexcharts.ChartOptions;
import com.hyjavaapex.model.apexcharts.Series;
import com.hyjavaapex.model.apexcharts.constants.BorderRadiusApplication;
import com.hyjavaapex.model.apexcharts.constants.ChartType;
import com.hyjavaapex.model.common.Color;
import com.hyjavaapex.model.common.Function;

public class ApexChartsBasicColumn {

	public Apexchart configure() {
		Apexchart apexchart = new Apexchart();
		ChartOptions chartOptions = apexchart.getChartOptions();
		
		chartOptions.getChart().setType(ChartType.BAR);
		
		chartOptions.getPlotOptions().getBar()
			.setHorizontal(false).setBorderRadius(5).setBorderRadiusApplication(BorderRadiusApplication.END).setColumnWidth("55%");
		
		chartOptions.getDataLabels().setEnabled(false);
		chartOptions.getStroke().setShow(true).setWidth(2).getColors().add(new Color("transparent"));

		chartOptions.getXaxis()
			.setCategoriesAsArrayString(Arrays.asList("Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct"));
		chartOptions.getYaxisSingle().getTitle().setText("$ (thousands)");
		
		chartOptions.getFill().setOpacity(1);
		chartOptions.getTooltip().getY().setFormatter(new Function("return \"$ \" + val + \" thousands\"", "val"));
		
		Series series = new Series();
		series.setName("Net Profit");
		series.setDataAsArrayNumber(Arrays.asList(44, 55, 57, 56, 61, 58, 63, 60, 66));
		chartOptions.getSeries().add(series);
		
		series = new Series();
		series.setName("Revenue");
		series.setDataAsArrayNumber(Arrays.asList(76, 85, 101, 98, 87, 105, 91, 114, 94));
		chartOptions.getSeries().add(series);
		
		series = new Series();
		series.setName("Free Cash Flow");
		series.setDataAsArrayNumber(Arrays.asList(35, 41, 36, 26, 45, 48, 52, 53, 41));
		chartOptions.getSeries().add(series);
		
		return apexchart;
	}
	
}