package jp.dip.arimodoki.blogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import jp.dip.arimodoki.common.CConst;
import jp.dip.arimodoki.common.JsonConvertIf;
import jp.dip.arimodoki.model.FormChartIf;
import jp.dip.arimodoki.model.data.ChartDoughnutData;
import jp.dip.arimodoki.model.data.ChartDoughnutDataSet;
@Scope("prototype")
@Service("BlChartMoc")
public class BlChart implements CConst, BlChartIf {
@Autowired
private JsonConvertIf jsonConvert;
private FormChartIf formChart;
private static final String[][] fillColor = {
{
"#648dc7",
"#00b1ae",
"#f7c35f",
"#eb714d",
"#ee71a1",
"#add673",
"#4abdf0",
"#b1629f"
},{
"#f7c35f",
"#648dc7",
"#ee71a1",
"#00b1ae",
"#b1629f",
"#eb714d",
"#4abdf0",
"#add673"
}
};
private static final String[][] labelName = {
{
"アボカド",
"キーウィ",
"オレンジ",
"リンゴ",
"モモ",
"マスカット",
"スイカ",
"キョホウ"
},{
"豚肉",
"牛肉",
"魚介",
"鶏肉",
"鹿肉",
"馬肉",
"鯨肉",
"モツ"
}
};
private static final int[][] dataValue = {
{
10,
30,
50,
70,
90,
65,
40,
15
},{
10,
20,
30,
40,
50,
60,
70,
85
}
};
public void setForm(FormChartIf form) {
this.formChart = form;
}
public void getCharDoughnutData() {
int category = this.formChart.getJsonReqParam().getCategory();
logger.log_info(this, "category["+category+"]");
ChartDoughnutData chartDoughnutData = new ChartDoughnutData();
ChartDoughnutDataSet[] chartDoughnutDataSet = new ChartDoughnutDataSet[1];
ChartDoughnutDataSet dataSet = new ChartDoughnutDataSet();
chartDoughnutDataSet[0] = dataSet;
dataSet.setData(dataValue[category]);
dataSet.setBackgroundColor(fillColor[category]);
dataSet.setHoverBackgroundColor(fillColor[category]);
chartDoughnutData.setLabels(labelName[category]);
chartDoughnutData.setDatasets(chartDoughnutDataSet);
formChart.setChartDoughnutData(chartDoughnutData);
}
}
|