vaadin / vaadin-charts-flow

Vaadin Charts for Flow
Other
7 stars 11 forks source link

Cannot use Vaadin charts in NPM mode #342

Closed markathomas closed 4 years ago

markathomas commented 4 years ago

The Chart object only has @HtmlImport defined, no @JsModule or @NpmPackage, so it is not compatible with NPM mode. Please advise how to rectify as it's totally useless for my team right now

markathomas commented 4 years ago

If I clone the class into my source tree and change the top to:

@Tag("vaadin-chart")
@NpmPackage(value = "@vaadin/vaadin-charts", version = "^6.3.0")
@JsModule("@vaadin/vaadin-charts/vaadin-chart.js")
public class Chart extends Component implements HasStyle, HasSize {

I get a chart; however, setting the class name on a data series item is not working

alvarezguille commented 4 years ago

@markathomas are you using vaadin-charts-flow? what version? Chart.java has @HtmlImport, @NpmPackage and @JsModule since 7.0.0 included in 14.0.0 https://github.com/vaadin/vaadin-charts-flow/blob/7.0.2/addon/src/main/java/com/vaadin/flow/component/charts/Chart.java#L72-L76

Starting from 8.0.0 @HtmlImport was removed since it's not supported in Vaadin 15+.

markathomas commented 4 years ago

Yes, I'm using vaadin-charts-flow with Vaadin Flow 14 but a 6.x version as that's what is in the directory. There is no 7.0.0 in the directory.

alvarezguille commented 4 years ago

Oh, ok, sorry for the confusion, directory might not be showing the latest version. Will take a look at that. Are you using maven? You can see the available versions in maven central repository https://search.maven.org/artifact/com.vaadin/vaadin-charts-flow

The simplest way to make sure you get the right version for your flow project is to use the vaadin-bom, which will set the right version for the dependencies.

You can find more info about adding components dependencies and using the bom in this docs article

By using the right version you will have @NpmPackage and @JsModule out of the box, you don't need to add those on your own.

Hope this helps!

markathomas commented 4 years ago

Thank you, definitely might want to check directory as that was very confusing.