用D3.js分页 [英] Pagination with D3.js
问题描述
我使用来自API的大量JSON数据用于D3条形图。我想一次只显示10-20个酒吧。有没有办法使用D3分页或者我需要做另一种方式(php)?欢迎任何最佳做法或建议。
我知道这是个迟到的问题,但也许这可以帮助你。
我将在d3中创建一个分页,创建一个只包含你想在特定时间显示的数据的第二个数组。这个切片数组将来自您的主数据数组。通过控制数组的切片位置,您可以控制分页。
我创建了一个简单的例子,将一个长数组分成五个页面。 / p>
I am using a large amount of JSON data from an API for D3 bar charts. I would like to show only 10-20 bars at a time. Is there a way to paginate using D3 or do I need to do this another way (php)? Any best practices or suggestions are welcome.
I know this is a late question, but maybe this can still help you out.
I would create pagination in d3 by creating a second array that only contains the data you want shown at a particular time. This sliced array would come from your primary data array. By controlling where the array is sliced, you control the pagination.
I've created a simple example here with a long array divided into five-bar 'pages'.
这篇关于用D3.js分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!