Tutuchan / chartjs

An implementation of the Chart.js library in R
MIT License
30 stars 7 forks source link

Tooltips only display after clicking on legend #8

Closed ThoDuyNguyen closed 8 years ago

ThoDuyNguyen commented 8 years ago

I make a test with the demo code and it seems that only after I click on legends, tooltip will be displayed

http://rpubs.com/thonguyenduy/demo-chartjs

Testing on RStudio Viewer looks fine.

Tutuchan commented 8 years ago

Thanks for the feedback!

You're right, it seems to be working that way with all types except the bar chart for some reason.

I'll try to look at this in the next couple of days.

Tutuchan commented 8 years ago

I just updated the package to a new version I have been working on.

Unfortunately, it will break your current code but can you take a look and tell me if it works better for you ?

ThoDuyNguyen commented 8 years ago

I have just tested the bar chart with flex dashboard, it seems that the chart does not fit perfectly when the dashboard resize or in full screen mode (the last one, you could see the charts perfectly fitted). The issue appear in both RStudio Viewer or when publish it to RPub My source code: https://gist.githubusercontent.com/ThoDuyNguyen/8c566510274b59f77ca790bee4a2d81c/raw/7e156c883cdd1ba555d26807a5c23cb078ba8bf1/chartjs-barchart.Rmd

My result: http://rpubs.com/thonguyenduy/test

About the syntax, I thought that "cjsSeries" could be clearer than "cjsAddSeries" and would be consistent with other layer. I will test more and have you feedback soon.

P/S: I use flexdashboard in my example because htmlwidget should resize and fit.. Therefore I remove height="200px"

Edit1 : Using line chart code snippet breaks RStudio Viewer Edit2 : Pie chart has resize problem like line bar chart. Edit3 : doughnut has resize problem Edit4: radar has resize problem Edit5: polararea has resize problem

Kind reagards.

Tutuchan commented 8 years ago

Thanks for all this.

I updated the package with cjsSeries instead of cjsAddSeries and fixed the RStudio Viewer issue.

I'll take a look at this resize problem tonight.

Tutuchan commented 8 years ago

I believe I fixed the resize problem.

Can you install again and let me know if it is fixed on your size ?

Thanks.

EDIT: Well I installed the last version of flexdashboard and it's broken again so nvm for now. EDIT2: Fixed again.

ThoDuyNguyen commented 8 years ago

At first, everything looks fine.

I found a case when the charts have weird behavior:

There is only one difference (polar area snippet code) between these 2 file.

EDIT0: In the bug case, you could notice that bars were not render in right scale at first.
EDIT1: If the dashboard only contains polar area, it seems the chart work fine.

Tutuchan commented 8 years ago

It seems to fail when the Polar Area chart is not rendered in the first page with this error:

Uncaught IndexSizeError: Failed to execute 'arc' on 'CanvasRenderingContext2D': The radius provided (-122) is negative.

I'll have a look tonight.

Tutuchan commented 8 years ago

This seems to be an error from the JS library, I managed to "fix it" by modifying its source code but I need to research this more.

For the time being, I suggest not using Polar Area charts in flexdashboards (or only on the first page).

ThoDuyNguyen commented 8 years ago

I put "Combo bar line" at the end of the dashboard and it seems to have strange behavior.

The rest of chart work fine.

Tutuchan commented 8 years ago

Do you mean something like this: https://gist.githubusercontent.com/Tutuchan/03ca319d93464944bddaae503a60dd81/raw/9719f850014e4cd7c594a3ee5ee774f8d39aef13/chartjs_combo.Rmd ?

Because it works fine for me.

Tutuchan commented 8 years ago

I'm closing this issue now because the original problem has been fixed, I'm opening other issues for the resize problem and the polar area problem.

ThoDuyNguyen commented 8 years ago

I had a quite busy week. I'll back to test and have feedback to you soon.

Thank you for your work and keep it coming.

Kind reagards