Chart V7 Custom Data Source

Forums SPJS Charts for SharePoint Chart V7 Custom Data Source

Viewing 2 reply threads
  • Author
    • #36130
      Ian Patrick

      Hi Alex,
      I’m trying to get data from an external source using the Custom Datasource function in Charts. I get the attached error, can you help please.
      Kind regards
      Here is the Custom Object:
      {“fin”:”StringValue”,”label”:”Despatch Delivery”,”type”:”Text”,”dataType”:”number”,”role”:””} ]

      This is the code for the function, it fetches the data from our server and returns this data:

      async function postData(url = ”, data = {}) {
      // Default options are marked with *
      const response = await fetch(url, {
      method: ‘POST’, // *GET, POST, PUT, DELETE, etc.
      mode: ‘cors’, // no-cors, *cors, same-origin
      cache: ‘no-cache’, // *default, no-cache, reload, force-cache, only-if-cached
      credentials: ‘same-origin’, // include, *same-origin, omit
      headers: {
      ‘Content-Type’: ‘text/plain’
      // ‘Content-Type’: ‘application/x-www-form-urlencoded’,
      redirect: ‘follow’, // manual, *follow, error
      referrerPolicy: ‘no-referrer’, // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
      body: JSON.stringify(data) // body data type must match “Content-Type” header
      return response.text(data);

      function getChartCustomData(chartId){

      var data=[];
      postData(‘https://ourserver/data/getdata.php’, { answer: 42 })
      .then((data) => {
      return data;// console.log(data);

    • #36132
      Ian Patrick

      Hi Alex,

      Sorry to have bothered you. For anyone else I wrote this function:

      function getChartCustomData() {
      var deferred = jQuery.Deferred();
      jQuery.get(‘https://ourServer/data/getdata.php?ACTION=Test’,data = {}).done(function(data){
      return deferred.promise();

      All works great now

    • #36133
      Alexander Bautz

      I’m glad you figured it out.


Viewing 2 reply threads
  • You must be logged in to reply to this topic.