<commit_before>import echarts from 'echarts/lib/echarts';
import matrix from 'zrender/lib/core/matrix';
import graphicGL from '../../util/graphicGL';
import ViewGL from '../../core/ViewGL';
import Lines2DGeometry from '../../util/geometry/Lines2D';

import retrieve from '../../util/retrieve';

echarts.extendChartView({

    type: 'linesGL',

    __ecgl__: true,

    init: function (ecModel, api) {
        this.groupGL = new graphicGL.Node();
        this.viewGL = new ViewGL('orthographic');
        this.viewGL.add(this.groupGL);

        this._coordSysTransform = matrix.create();
    },

    render: function (seriesModel, ecModel, api) {
        this.groupGL.removeAll();
        if (!this._linesMesh) {
            this._linesMesh = this._createLinesMesh(seriesModel);
        }
        this.groupGL.add(this._linesMesh);
        this._udpateLinesMesh(seriesModel, this._linesMesh, 0, seriesModel.getData().count());

        this._updateCamera(api.getWidth(), api.getHeight(), api.getDevicePixelRatio());
        this._setCameraTransform(matrix.create());

        if (seriesModel.coordinateSystem.transform) {
            matrix.copy(this._coordSysTransform, seriesModel.coordinateSystem.transform);
        }
    },

    incrementalPrepareRender: function () {

    },

    incrementalRender: function () {

    },

    updateLayout: function (seriesModel, ecModel, api) {
        var coordinateSystem = seriesModel.coordinateSystem;

        if (coordinateSystem.transform) {
            var diffTransform = matrix.create();
            matrix.invert(diffTransform, this._coordSysTransform);
            matrix.mul(diffTransform, diffTransform, coordinateSystem.transform);

            this._setCameraTransform(diffTransform);
        }
        else {
            // Can only render again.
            this.render(seriesModel, ecModel, api);
        }
    },

    incrementalLayout: function () {
    },

    incrementalPrepareLayout: function () {

    },

    _createLinesMesh: function (seriesModel) {
        var linesMesh = new graphicGL.Mesh({
            material: new graphicGL.Material({
                shader: graphicGL.createShader('ecgl.meshLines2D'),
                transparent: true,
                depthMask: false,
                depthTest: false
            }),
            geometry: new Lines2DGeometry({
                useNativeLine: false,
                dynamic: false
            }),
            culling: false
        });

        return linesMesh;
    },

    _udpateLinesMesh: function (seriesModel, linesMesh, start, end) {
        var data = seriesModel.getData();
        linesMesh.material.blend = seriesModel.get('blendMode') === 'lighter'
            ? graphicGL.additiveBlend : null;
        var curveness = seriesModel.get('lineStyle.curveness') || 0;
        var isPolyline = seriesModel.get('polyline');
        var geometry = linesMesh.geometry;

        var lineWidth = retrieve.firstNotNull(seriesModel.get('lineStyle.width'), 1);

        start = start || 0;
        end = end || data.count();

        geometry.resetOffset();
        var vertexCount = 0;
        var triangleCount = 0;
        var p0 = [];
        var p1 = [];
        var p2 = [];
        var p3 = [];<commit_msg>[linesGL] Fixed updateLayout<commit_after>import echarts from 'echarts/lib/echarts';
import matrix from 'zrender/lib/core/matrix';
import graphicGL from '../../util/graphicGL';
import ViewGL from '../../core/ViewGL';
import Lines2DGeometry from '../../util/geometry/Lines2D';

import retrieve from '../../util/retrieve';

echarts.extendChartView({

    type: 'linesGL',

    __ecgl__: true,

    init: function (ecModel, api) {
        this.groupGL = new graphicGL.Node();
        this.viewGL = new ViewGL('orthographic');
        this.viewGL.add(this.groupGL);

        this._coordSysTransform = matrix.create();
    },

    _reset: function (seriesModel, api) {
        this.groupGL.removeAll();
        this._updateCamera(api.getWidth(), api.getHeight(), api.getDevicePixelRatio());
        this._setCameraTransform(matrix.create());

        if (seriesModel.coordinateSystem.transform) {
            matrix.copy(this._coordSysTransform, seriesModel.coordinateSystem.transform);
        }
    },

    render: function (seriesModel, ecModel, api) {
        this._reset(seriesModel, api);

        if (!this._linesMesh) {
            this._linesMesh = this._createLinesMesh(seriesModel);
        }
        this.groupGL.add(this._linesMesh);
        this._udpateLinesMesh(seriesModel, this._linesMesh, 0, seriesModel.getData().count());

        // Remove all incremental meshes.
        this._incrementalLinesMeshes = [];
    },

    incrementalPrepareRender: function (seriesModel, ecModel, api) {
        this._reset(seriesModel, api);

        this._incrementalLinesMeshes = this._incrementalLinesMeshes || [];
        this._currentFrame = 0;
    },

    incrementalRender: function (params, seriesModel, ecModel, api) {
        var linesMesh = this._incrementalLinesMeshes[this._currentFrame];
        if (!linesMesh) {
            linesMesh = this._createLinesMesh(seriesModel);
            this._incrementalLinesMeshes[this._currentFrame] = linesMesh;
        }
        this._udpateLinesMesh(seriesModel, linesMesh, params.start, params.end);
        this.groupGL.add(linesMesh);
        api.getZr().refresh();

        this._currentFrame++;
    },

    updateLayout: function (seriesModel, ecModel, api) {
        var coordinateSystem = seriesModel.coordinateSystem;

        if (coordinateSystem.transform) {
            var diffTransform = matrix.create();
            matrix.invert(diffTransform, coordinateSystem.transform);
            matrix.mul(diffTransform, this._coordSysTransform, diffTransform);

            this._setCameraTransform(diffTransform);

            api.getZr().refresh();
        }
        else {
            // Can only render again.
            this.render(seriesModel, ecModel, api);
        }
    },

    incrementalPrepareLayout: function (seriesModel, ecModel, api) {
        if (seriesModel.coordinateSystem.transform) {
            this.updateLayout(seriesModel, ecModel, api);
            return {
                noProgress: true
            };
        }
        else {
            this.incrementalPrepareRender(seriesModel, ecModel, api);
        }
    },

    incrementalLayout: function (params, seriesModel, ecModel, api) {
        this.incrementalRender(params, seriesModel, ecModel, api);
    },

    _createLinesMesh: function (seriesModel) {
        var linesMesh = new graphicGL.Mesh({
            $ignorePicking: true,
            material: new graphicGL.Material({
                shader: graphicGL.createShader('ecgl.meshLines2D'),
                transparent: true,
                depthMask: false,
                depthTest: false
            }),
            geometry: new Lines2DGeometry({
                segmentScale: 10,
                useNativeLine: false,
                dynamic: false
            }),
            culling: false
        });

        return linesMesh;
    },

    _udpateLinesMesh: function (seriesModel, linesMesh, start, end) {
        var data = seriesModel.getData();
        linesMesh.material.blend = seriesModel.get('blendMode') === 'lighter'
            ? graphicGL.additiveBlend : null;
        var curveness = seriesModel.get('lineStyle.curveness') || 0;
        var isPolyline = seriesModel.get('polyline');
        var geometry = linesMesh.geometry;

        var lineWidth = retrieve.firstNotNull(seriesModel.get('lineStyle.width'), 1);

        start = start || 0;
        end = end || data.count();

        geometry.resetOffset();
        var vertexCount = 0;
        var triangleCount = 0;
        var p0 = [];
        var p1 = [];
        var p2 = [];
        var p3 = [];
{'fraction_non_alphanumeric': 0.11749648022526558, 'fraction_numerical': 0.003967746064251888, 'mean_word_length': 2.2831932773109243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3496311', 'n_tokens_mistral': 2178, 'n_tokens_neox': 2089, 'n_words': 426}