amcharts / editor4

amCharts Chart Editor based on amCharts 4
Other
27 stars 36 forks source link

import `jschardet` in static/js/3.5e655d40.chunk.js #91

Closed kouui closed 2 years ago

kouui commented 2 years ago

Hi. Thanks for this interesting project!

I am trying to add jschardet to @amcharts/editor4/am4editor/static/js/3.5e655d40.chunk.js, in order to detect type of csv encoding in function

             function u(e) {
                var t, n;
                (e = e || {}).chunkSize || (e.chunkSize = a.LocalChunkSize), l.call(this, e);
                var i = "undefined" != typeof FileReader;
                this.stream = function(e) { this._input = e, n = e.slice || e.webkitSlice || e.mozSlice, i ? ((t = new FileReader).onload = _(this._chunkLoaded, this), t.onerror = _(this._chunkError, this)) : t = new FileReaderSync, this._nextChunk() }, this._nextChunk = function() { this._finished || this._config.preview && !(this._rowCount < this._config.preview) || this._readChunk() }, this._readChunk = function() {
                    var e = this._input;
                    if (this._config.chunkSize) {
                        var r = Math.min(this._start + this._config.chunkSize, this._input.size);
                        e = n.call(e, this._start, r)
                    }
                   // different keyword specification corresponding to different csv encoding
                    t.readAsText(e, this._config.encoding); // for normal case, 'UTF-8'
                    //t.readAsText(e, 'Shift_JIS'); // for 'Shift_JIS'

                    i || this._chunkLoaded({ target: { result: o } })
                }, this._chunkLoaded = function(e) { this._start += this._config.chunkSize, this._finished = !this._config.chunkSize || this._start >= this._input.size, this.parseChunk(e.target.result) }, this._chunkError = function() { this._sendError(t.error) }
            }

I tried putting

import jschardet from '/path/to/jschardet.min.js'

or

const jschardet = require('/path/to/jschardet.js')

to the top of @amcharts/editor4/am4editor/static/js/3.5e655d40.chunk.js. As a result, neither of them works.

Is there any way to import external library jschardet into @amcharts/editor4/am4editor/static/js/3.5e655d40.chunk.js?

Thank you very much!

kouui commented 2 years ago

problem solved.