Open y0nd0 opened 3 years ago
same issue, @100pah Is there a solution? @y0nd0 have you solved the problem?
@y0nd0 @GreedyPirate this way works for me:
import { transform } from 'echarts-stat'
echarts.registerTransform(transform.regression)
which is even better 'cause you don't need to import the whole ecStat package if you are going to use just one transformation.
same issue, there is no 'transform' available from echarts-stat package
my packages versions : "echarts": "^5.2.0", "echarts-stat": "^1.2.0", "ngx-echarts": "^7.0.1",
anyone solved the problem ?
any news? the same problem
same issue, any suggestions please
@y0nd0 @GreedyPirate this way works for me:
import { transform } from 'echarts-stat' echarts.registerTransform(transform.regression)
which is even better 'cause you don't need to import the whole ecStat package if you are going to use just one transformation.
there is no 'transform' available from echarts-stat package. Which version do you use please? @dvago
@CDFO2
"echarts": "^5.1.2",
"echarts-stat": "^1.2.0",
@dvago I'm having below versions.
"echarts": "^5.2.1",
"echarts-stat": "^1.2.0",
I've tried downgrading echarts to 5.1.2, but then its giving following error.
Property 'registerTransform' does not exist on type 'typeof echarts'
@CDFO2 are you importing the library as:
import * as echarts from 'echarts'
Note: the above is bad practice but it's a work around.
@dvago Yes, following exactly the same as mentioned here.
import * as echarts from 'echarts';
import ecStat from 'echarts-stat';
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;
echarts.registerTransform(ecStat.transform.regression);
@CDFO2 I would try with this and see what happens:
import * as echarts from 'echarts';
import { transform } from 'echarts-stat';
echarts.registerTransform(transform.regression);
var myChart = echarts.init(document.getElementById('main'));
var option; // whatever option you want to pass
myChart.setOption(option);
This sequence (importing the library, registering the transformation and init the chart) has been provided by one of the library maintainer a few months ago.
I'm not fully sure if this helps out 'cause the error says "echarts doesn't contain the function registerTransform so you can't call it" (this method is not even documented within echarts website https://echarts.apache.org/en/api.html#echarts)
I've been raising a proposal and this guy opened an issue related to this registerTransform but it still open: #15124
Any update for the transform problem?
Come on guys! when are you going to fix this?
A fix would be really helpful!!
Resorting to module augmentation till a fix is available:
import type { ExternalDataTransform } from "@manufac/echarts-simple-transform";
/**
* Needed because of: https://github.com/ecomfe/echarts-stat/issues/35
* Module augmentation: https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/
declare module "echarts-stat" {
let transform: {
regression: ExternalDataTransform;
histogram: ExternalDataTransform;
clustering: ExternalDataTransform;
};
}
Took some hints from https://github.com/ecomfe/echarts-stat/pull/41 as well.
temporary solution:
const ecStatLocal: any = ecStat; echarts.registerTransform(ecStatLocal.transform.regression);
I had the same issue and i found this solution:
I replaced
import ecStat from 'echarts-stat';
with
import * as ecStat from 'echarts-stat';
and
echarts.registerTransform(ecStat.transform.regression);
with
echarts.registerTransform(ecStat['transform'].regression);
in this way everything works as it should, but I have no idea of the reason why.
Anyway I hope it helps ;)
The above doesn't work anymore because of TypeScript, you can try this instead:
import { registerTransform } from 'echarts';
import * as ecStat from 'echarts-stat';
registerTransform((ecStat as any).transform.regression);
Found Another way of implementing in Angular
Run Register Transform inside lifecycle hook.
import * as echarts from 'echarts'
import * as ecStat from 'echarts-stat';
ngOnInit () : void {
echarts.registerTransform((ecStat as any).transform.regression);
}
您好,这里是周敏。您的来信我已收到,我会在查看后的第一时间给你回复。
import { transform } from 'echarts-stat'
this should be the correct solution, the current solutions are not tree shakeable
If you are interested in regression, you can use my script. I took and rewrote several files from the library and now I don’t need to install the entire library. This solved the problem with imports. Most likely it will not work in strict typescript mode. But in normal mode everything works.
https://github.com/oleksandr-kupenko/echarts-stat-regression
您好,这里是周敏。您的来信我已收到,我会在查看后的第一时间给你回复。
temporary solution:
const ecStatLocal: any = ecStat; echarts.registerTransform(ecStatLocal.transform.regression);
or:#41
this works. i imported the ecStat and change it to any type. and follow the rest.
import * as ecStat from 'echarts-stat';
const ecStatLocal: any = ecStat; echarts.registerTransform(ecStatLocal.transform.histogram);
临时解决方案:
const ecStatLocal: any = ecStat; echarts.registerTransform(ecStatLocal.transform.regression);
或:#41
It's useful,thanks.
How to use transform regression in echarts (ngx-echarts) TypeScript? Missing type?
ecStat.d.ts
Goal: https://echarts.apache.org/examples/en/editor.html?c=scatter-linear-regression