The following example shows how to use a data filter to filter the daily recommendation data from the website of Site B by using the column chart of the carousel list widget.
Procedure
- Log on to the DataV console.
On the My Visualizations page, select the visualization that you created and click Edit.
On the Canvas Editor page, click the icon to go to the Assets page. In the search box, enter Column carousel.
Select the current component and click the Data icon in the right-side pane.
Click Configure Data Source. The Configure Data Source page appears.
In the Data Source Type section, select API from the drop-down list and enter the URL of Site B (
https://www.bilibili.com/index/recommend.json
).Select Server Proxy Request. This data request is in cross-domain mode.
Click Preview Results to view the returned results of the URL source data of Station B.
In the preview box, a JSON object is returned. However, the carousel list needs to display a list of objects, and each object needs to contain the
value
andcontent
fields. Therefore, you need to continue to perform the following steps to configure the data filter and convert the data structure.Select Data Filter and turn on Enable Filter Debugging.
Click the icon next to Add Filter to add a filter.
Edit the code content of the filter and click Test to view the filter result.
The trigger condition of the filter in the preceding figure is as follows:
return data.list.map(item => { return { value: item.author, content: item.description }; });
After the code in the filter is edited, you can see the list of data required by the converted widget. The content is displayed in the
value
andcontent
fields.After the configuration and test are successful, click Save and refresh the Data Response Result page to view the daily recommendation data of Site B.
NoteYou can also click the icon in the Data Response section to view the response results.