Skip to content

Commit 3f37e1d

Browse files
committed
screenshot added and graph vue trying to fetch real data
1 parent 12adb74 commit 3f37e1d

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Admin Data Viewer
22

3+
![Admin Data Viewer Screenshot](/admin-data-viewer.jpeg)
4+
35
## Description
46
A WordPress plugin that displays data from a remote API in a Vue app for admin users.
57

@@ -18,9 +20,6 @@ Navigate to the 'Admin Data Viewer' menu in the WordPress admin panel to access
1820
- 'npm run build'
1921
- 'download the zip and upload to the wordpress'
2022

21-
## Screenshots
22-
(Add screenshots here if applicable)
23-
2423
## Changelog
2524
- **1.0.0**: Initial release.
2625

admin-data-viewer.jpeg

72.1 KB
Loading

src/components/Graph.vue

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default {
4343
methods: {
4444
async fetchGraphData() {
4545
try {
46-
const apiUrl = `${this.apiData.root_url}/api`;
46+
const apiUrl = `${this.apiData.root_url}/api/data-endpoint`; // Update this line to point to your actual API endpoint
4747
const headers = this.apiData.nonce !== 'development_nonce' ? { 'X-WP-Nonce': this.apiData.nonce } : {};
4848
4949
const response = await fetch(apiUrl, { headers });
@@ -55,23 +55,20 @@ export default {
5555
}
5656
5757
const result = await response.json();
58-
console.log("Graph data:", result.graph); // Debugging log
58+
console.log("Graph data:", result); // Debugging log
5959
60-
// Update this section based on the actual structure of result.graph
61-
if (result.graph) {
62-
// Assume graph data is structured as an array of objects with 'label' and 'value' properties
63-
// Modify according to the actual data structure you observe in the console
60+
// Update this section based on the actual structure of result
61+
if (result.data) { // Adjust this based on your actual API response structure
6462
this.chartData = {
65-
labels: result.graph.map(item => item.label),
63+
labels: result.data.map(item => item.label), // Adjust according to your data structure
6664
datasets: [
6765
{
6866
label: 'Sample Data',
6967
backgroundColor: '#42b983',
70-
data: result.graph.map(item => item.value)
68+
data: result.data.map(item => item.value) // Adjust according to your data structure
7169
}
7270
]
73-
};
74-
this.chartData.datasets[0].data = Object.values(result.graph).map(item => item.value);
71+
};
7572
} else {
7673
console.error("Unexpected graph data format:", result);
7774
this.statusMessage = "Unexpected data format for graph data.";

0 commit comments

Comments
 (0)