【发布时间】:2014-08-27 00:43:48
【问题描述】:
我正在尝试使用dimple JS 绘制图表。我需要在选择下拉菜单时过滤数据。当我使用 dimple.filterData(....) 时没有返回数据时,我收到错误消息。当 dimple.filterData() 函数没有返回数据时,请告诉我如何处理。
当没有数据返回时,我想显示“当前选择没有数据”。
<select id="Time">
<option value="">Please Select</option>
<option value="Year">YTD</option>
<option value="Month">MTD</option>
<option value="Week">WTD</option>
$("#Time").on('change',function(){
$("#chartContainer").html('');
drawChart($(this).prop('id'), $(this).val());
});
function drawChart(id, value){
var svg = dimple.newSvg("#chartContainer", 590, 400);
var data = [
{ Time: "Year", Value: 1 },
{ Time: "Month", Value: 2 },
{ Time: "Month", Value: 3 }
];
data = dimple.filterData(data, id, value);
var myChart = new dimple.chart(svg, data);
myChart.setBounds(60, 30, 510, 305)
var x = myChart.addCategoryAxis("x", "Time");
x.addOrderRule(["Year", "Month", "Week"]);
myChart.addMeasureAxis("y", "Value");
myChart.addSeries(null, dimple.plot.bar);
myChart.draw();
}
【问题讨论】:
标签: javascript jquery html d3.js dimple.js