我正在使用 struts2-jquery-chart-plugin-3.2.1。我想显示一个由列表填充的条形图。
这是我的代码:
动作类:
public class FinancialChartAction extends ActionSupport{
private List<FinChartModel> wholeChartModels;
@SkipValidation
@Action(value = "getFinancialChartData", results = {
@Result(name = "success", type = "json", params = {
"wholeChartModels"
})}){
wholeChartModels = new ArrayList<FinChartModel>();
wholeChartModels.add(new FinChartModel("2020/01/01", 1000));
wholeChartModels.add(new FinChartModel("2020/01/02", 2000));
wholeChartModels.add(new FinChartModel("2020/01/03", 3500));
wholeChartModels.add(new FinChartModel("2020/01/04", 550));
}
public List<FinChartModel> getWholeChartModels() {
return wholeChartModels;
}
}
型号类:
private String registerDate;
private Long sellValue;
public String getRegisterDate() {
return registerDate;
}
public void setRegisterDate(String registerDate) {
this.registerDate = registerDate;
}
public Long getSellValue() {
return sellValue;
}
public void setSellValue(Long sellValue) {
this.sellValue = sellValue;
}
FinChartModel(String registerDate,Long sellValue){
this.registerDate = registerDate;
this.sellValue = sellValue;
}
JSP:
<div id="gain_chart">
<sjc:chart
id="chartAjaxTwo"
cssStyle="width: 600px; height: 400px;">
<sjc:chartData
dataType="json"
id="chartAjaxTwoData2"
label="List -ListValue-"
href="%{getFinancialChartData}"
list="wholeChartModels"
listKey="registerDate"
listValue="sellValue"
bars="{show : true, barWidth: 0.7}"
/>
</sjc:chart>
</div>
如您所见,我希望我的图表在 x 轴上显示字符串。通过这种配置,我在条形图上看不到任何数据。是否可以使用字符串作为条形图的 x 轴?如果是,我的代码有什么问题?