Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
I'm getting an error when drawing a chart using echarts JS

When I try to draw a graph, I get an error:echarts.min.js:45 Uncaught TypeError: Bind must be called on a function at bind (<anonymous>) at Bd (echarts.min.js:45:130031)

My echarts-init.js:

let domTemp = document.getElementById("main");
let mytempChart = echarts.init(domTemp, null, {
  renderer: 'canvas',
  useDirtyRect: false
});
var app = {};
var option;

runDaysDatas(sens_data_result, sens_name_list);
function runDaysDatas(sens_data_result, sens_name_list) {
  
    const sens_names = sens_name_list;
    
    const datasetWithFilters = [];
    const seriesList = [];
    echarts.util.each(sens_names, function (sens) {
      var datasetId = 'dataset_' + sens;
      datasetWithFilters.push({
        id: datasetId,
        fromDatasetId: sens_data_result,
        transform: {
          type: 'filter',
          config: {
            and: [
              { dimension: 'Uid', '=': sens }
            ]
          }
        }
      });
      seriesList.push({
        type: 'line',
        datasetId: datasetId,
        showSymbol: false,
        name: sens,
        endLabel: {
          show: true,
          formatter: function (params) {
            return params.value[3] + ': ' + params.value[0];
          }
        },
        labelLayout: {
          moveOverlap: 'shiftY'
        },
        emphasis: {
          focus: 'series'
        },
        encode: {
          x: 'Date',
          y: 'Temperature',
          label: ['Name', 'Temperature'],
          itemName: 'Date',
          tooltip: ['Temperature']
        }
      });
    });
    option = {
      animationDuration: 10000,
      dataset: [
        {
          id: 'dataset_sens_names',
          source: sens_data_result
        },
        ...datasetWithFilters
      ],
      title: {
        text: 'Temperature for Day'
      },
      tooltip: {
        order: 'valueDesc',
        trigger: 'axis'
      },
      xAxis: {
        type: 'category',
        nameLocation: 'middle'
      },
      yAxis: {
        name: 'Temperature'
      },
      grid: {
        right: 140
      },
      series: seriesList
    };
    mytempChart.setOption(option);
}

In sens_data_result i pass data from api. In sens_name_list i pass names of the sensors.

The console does not send errors to my script, it swears at the library. I took an example from the official site and remade it for my task, displaying the temperature by time of day with the name of the sensor. There can be N number of graphs on one chart.

Thnx for help!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Okey, i'm a solved the problem, this is decision:

let url = '/api/sensdata';

let domTemp = document.getElementById("main");
let mytempChart = echarts.init(domTemp, null, {
  renderer: 'canvas',
  useDirtyRect: false
});
var app = {};
var option;

$.get(
  url,
  sensors_uid,
  (_rawData) => {
    runDaysDatas(_rawData, sens_name_list);
  }
);

function runDaysDatas(_rawData, sens_names) {
  const datasetWithFilters = [];
  const seriesList = [];
  _rawData.unshift(['Name', 'Date', 'Humidity', 'Temperature']);

  echarts.util.each(sens_names, function (sens) {
    var datasetId = 'dataset_' + sens;
    datasetWithFilters.push({
      id: datasetId,
      fromDatasetId: 'dataset_raw',
      transform: {
        type: 'filter',
        config: {
          and: [
            { dimension: 'Name', '=': sens }
          ]
        }
      }
    });
    seriesList.push({
      type: 'line',
      datasetId: datasetId,
      showSymbol: false,
      name: sens,
      endLabel: {
        show: true,
        formatter: function (params) {
          return 'Uid ' + params.value[0] + ': ' + params.value[3] + '°C';
        }
      },
      labelLayout: {
        moveOverlap: 'shiftY'
      },
      emphasis: {
        focus: 'series'
      },
      encode: {
        x: 'Date',
        y: 'Temperature',
        label: ['Name', 'Temperature'],
        itemName: 'Temperature',
        tooltip: ['Temperature']
      },
    });
  });

console.log(seriesList);

  option = {
    toolbox: {
      show : true,
      feature : {
          magicType : {show: true, type: ['line', 'bar']},
          restore : {show: true},
          saveAsImage : {show: true}
      }
  },
  legend: {},
    dataset: [
      {
        id: 'dataset_raw',
        source: _rawData
      },
      ...datasetWithFilters
    ],
    tooltip: {
      order: 'valueDesc',
      trigger: 'axis'
    },
    xAxis: {
      type: 'time',
      nameLocation: 'middle',
      axisLabel: {
        formatter: (function(value){
          moment.locales('RU_ru');
            return moment(value).format('MM/DD HH:mm');
        })
    }
    },
    yAxis: [
      {
          type : 'value',
          axisLabel : {
              formatter: '{value} °C'
          }
      }
  ],
    grid: {
      right: 140
    },
    series: seriesList
  };
  
  mytempChart.clear();
  mytempChart.setOption(option);

}

window.addEventListener('resize', mytempChart.resize);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!