What is a two-dimensional array in the main order of behavior?

echarts-gl draw surfaces

when drawing a surface with echarts-gl, a two-dimensional array is provided. Echarts error prompts you to provide a two-dimensional array in the main order of behavior:

echarts-gl.js:51001 Uncaught (in promise) Error: Invalid data. data should be a row major 2d array.
    at ExtendedClass._getDataShape (echarts-gl.js:51001)
    at ExtendedClass.render (echarts-gl.js:50617)
    at Task.progress (echarts.js:23685)
    at doProgress (echarts.js:22678)
    at Task.taskProto.perform (echarts.js:22601)
    at echarts.js:26562
    at ExtendedClass.<anonymous> (echarts.js:20645)
    at Array.forEach (<anonymous>)
    at each$1 (echarts.js:524)
    at ExtendedClass.eachSeries (echarts.js:20643)
An example of a two-dimensional array in

echarts-gl. With this two-dimensional array, you can draw a surface. I took a look at this two-dimensional array. The first element (x coordinate) of each element in the array (each element in the one-dimensional array corresponds to x, y, z coordinates) is arranged from small to large. If you mess up this order, you can"t draw a surface, but it doesn"t matter if you mess up the order of y or z, you can draw a surface.

data: [
    [-1,-1,0],[-0.5,-1,0],[0,-1,0],[0.5,-1,0],[1,-1,0],
    [-1,-0.5,0],[-0.5,-0.5,1],[0,-0.5,0],[0.5,-0.5,-1],[1,-0.5,0],
    [-1,0,0],[-0.5,0,0],[0,0,0],[0.5,0,0],[1,0,0],
    [-1,0.5,0],[-0.5,0.5,-1],[0,0.5,0],[0.5,0.5,1],[1,0.5,0],
    [-1,1,0],[-0.5,1,0],[0,1,0],[0.5,1,0],[1,1,0]
]

the surface drawn is as follows:

clipboard.png

what is a two-dimensional array in the main order of behavior?

Apr.06,2021

suppose you have a two-dimensional array A3, three rows and two columns, and imagine a matrix .
if you follow row major (from left to right, that is, elements are selected from rows, and then wrap lines from top to bottom), the program reads data in the order of a [0] [0], a [0] [1], a [1] [0], a [2] [0], a [2] [1] , and

in line number order.

look at its source code, as long as x is smaller than the previous one, it will report an error.
clipboard.png

Menu