我正在使用 AmCharts 的 AngularJs 应用程序。
const writeemp = data => {
const {
total,
employees,
} = data;
empChart.dataProvider = e;
empChart.write('emp');
empChart.validateData();
};
AmCharts.handleLoad();
var configChart = function () {
empChart = new AmCharts.AmSerialChart();
empChart.categoryField = "state";
empChart.labelRotation = 90;
var yAxis = new AmCharts.ValueAxis();
yAxis.position = "left";
empChart.addValueAxis(yAxis);
empBarGraph = new AmCharts.AmGraph();
empBarGraph.valueField = "count";
empBarGraph.type = "column";
empBarGraph.fillAlphas = 1;
empBarGraph.lineColor = "#f0ab00";
empBarGraph.valueAxis = yAxis;
empChart.addGraph(empBarGraph);
empChart.write('empChart');
$http.get(hostNameService.getHostName()+"/dashboard/employees/statecount")
.then(response => writeemp(response.data));
}
html中的代码:
<div class='panel-body'>
<div id="empChart"></div>
</div>
这将返回我在 x 轴上的 State 值并在 y 轴上计数。我想添加复选框来过滤图表中的数据。每个复选框应代表员工的“状态”。如果我取消选中一个框,那么图表中显示的数据应该会发生变化。谁能让我知道如何实现这一目标。