@@ -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