Open erkanisuf opened 2 years ago
Ayo, Download the unminified file, and change where new event is defined to this: native: { buttons: buttons, type: e.original.type == "click" ? "mousemove" : e.original.type }, It loses context between charts. You're welcome
Hit the same issue.
It appears that sync is working on chartjs version 3.4.x but not newer versions. I was able to pin chartjs to ~3.4.1
to work around this temporarily.
type: e.original.type == "click" ? "mousemove" : e.original.type
this worked for me. very nice
Ayo, Download the unminified file, and change where new event is defined to this: native: { buttons: buttons, type: e.original.type == "click" ? "mousemove" : e.original.type }, It loses context between charts. You're welcome
Thanks, it's work in "chart.js": "^3.7.1", "chartjs-plugin-crosshair": "^1.2.0"
@Bodrosh I am also facing the same issue. Can you please upload an example on codesandbox with react-chartjs ?
@geriatricdan Thank you so much :) I was stuck with this and you saved my time. Any idea why reset zoom button was placed below instead of on top of the graph ?
@geriatricdan possibly PR so they can put this fix in the official plugin 👀
@erkanisuf Does zoom works ? graph not showing up after zoom. it goes away
I am not using the zoom but yes its feels wierd and buggy
I have done a range of fixes and improvements to the chartjs-plugin-crosshair.js file. It works out of the box with the latest version of chart.js. I don't thing the Owner of the code is maintaining it anymore or is doing PR reviews. If anybody wants to try out me "fork" of the code hier it is
@savejeff It looks zoom doesn't work with above attached file.
what kind of zoom are you talking about? If you are talking about the zoom where you click and drag sideways to zoom into the area draged over, this works perfectly find with the code in the zip file. i use it daily. Other zoom like pitch and scroll zoom are not implemented in this library.
check this: do you have the latest version of chats.js is your code correct? check the code from the examples does it give you any errors in the console ?
i would start looking for the fault in you code.
No errors on console. but when i zoom, line chart vanished. After reset zoom click, i can see the line chart.
I am using latest version of charts.js react-chart-2.js
dont know about react. i can assure you, that it works with chart.js 3.7.1.
@savejeff
Thanks for your zip - It syncs perfect also with 3.8.0..
I have one problem: I cannot switch on/off the datasets by clicking on the smbol and text in the legend (sync or w/o sync).
Now I made more tests: I want that the tooltips on the last datapoint is shwon on the first call of the chart.
When I add this code to my config file, the tooltip is shown, but then the problem with legend happens.
you can see this effect at www.zebrafell.de/test.html.
Without this plugins code the click to the legend works..
Do you have an idea what I can do?
plugins: [
{
afterDatasetUpdate: (chart) => {
if (!chart.tooltip.getActiveElements().length) {
sets = [];
for (let index = 0; index < data.datasets.length; index++) {
sets[index] = {
datasetIndex: index,
index: chart.data.datasets[index].data.length - 1,
};
}
chart.tooltip.setActiveElements(sets);
chart.update();
}
},
},
],
I find finally the solution: I deleted the chart.update()
Problem is solved!!
@cmark1302 sorry, did you manage to find a working solution for react-chart-2
? Thanks.
It seems that the fix by @geriatricdan is already contained in the repository code, but at the wrong place:
var newEvent = {
// REMOVED FROM HERE
// type: e.original.type == "click" ? "mousemove" : e.original.type, // do not transmit click events to prevent unwanted changing of synced charts. We do need to transmit a event to stop zooming on synced charts however.
chart: chart,
x: xScale.getPixelForValue(e.xValue),
y: e.original.y,
native: {
// INSERTED HERE
type: e.original.type == "click" ? "mousemove" : e.original.type, // do not transmit click events to prevent unwanted changing of synced charts. We do need to transmit a event to stop zooming on synced charts however.
buttons: buttons
},
stop: true
};
Im also struggling with this. Only managed to get the synced tooltips working with chartjs 3.5.1.
I have the same problem. sync is not working in Chart.js version 4. It is working up to version 3.5.1, but not after
I also have this problem, can confirm that it works with chart.js 3.5.1 but not greater version.
There is a fix available in branch 4.0.1 but unfortunately no plugin.js file to use it in web application.
How can i get such file to import it in html via <script> src... </script>
tag ?
Any help would be great , thanks in advanced!
Update:
Ok, realized that i have to pull repository, switch to branch 4.0.1 --> npm install
--> gulp build
--> find files in dist folder :D
Ok, realized that i have to pull repository, switch to branch 4.0.1 -->
npm install
-->gulp build
--> find files in dist folder :D
Can you explain more? Please.
Can you explain more? Please.
Hi, you have to compile version 4.0.1 by yourself, because there are no precompiled releases. To do that you have to:
git checkout 4.0.1
)npm install
gulp install
dist
folder.Thank you for getting back. I just did what you said, but it still doesn’t work for me. It’s telling something about “interpolate “ not being apart of some object type.
Same issues with sync and zoom here.
I use the fork (patched) version compatible with chartjs 4. It works except that : From first chart, I have crosshair and tooltip, but in second I have only the crosshair and not the tooltips. If I move cursor from the second chart, I have both crosshair and both tooltips. I use the group 1 and do not suppress tooltips. I disable zoom also (have zoom plugin).
switching to 3.4.1 made it work
I am using chartjs version 3.7 , plugin version 1.2.0 and react-chartjs version 4.0.0 . The sync is not workinng for some reason .
Import and registration :
options setup:
I used two identical charts with exacly same props/data. But the sync is gone. When i have used the plugin with chartjs before version 3v and plugin version 1.1.2 , the sync has worked. Am i missing something or is this some kind of bug?