Has Chart.defaults.global.legend.onClick been moved in v4.2.0? - chart.js

I get "Uncaught TypeError: Cannot read properties of undefined (reading 'onClick')" for the following code:
var original = Chart.defaults.global.legend.onClick;
It worked in chart.js v2.

As of Chart.js release 3.x
global namespace was removed from defaults. So Chart.defaults.global is now Chart.defaults.
legend, title and tooltip namespaces were moved from Chart.defaults to Chart.defaults.plugins.
For further information, please consult section Defaults in 3.x Migration Guide at https://www.chartjs.org/docs/latest/migration/v3-migration.html.

I finally found the answer to my problem in the Legend documentation:
"The doughnut, pie, and polar area charts override the legend defaults. To change the overrides for those chart types, the options are defined in Chart.overrides[type].plugins.legend."
As I am working on doughnut chart, I changed the code to:
var original = Chart.overrides.doughnut.plugins.legend.onClick;
and it works.

Related

Am I missing a chart.js component or helper?

I experimented with my code on the chartjs website (using their editor on one of their samples pages) and it works perfectly. When I copy and paste it into my page, the chart won't even render. When I delete the line "type: 'time'," the chart renders fine, but not with the intended x axis (which makes me think the rest of my code is OK). When I delete the entire 'scales' section, it also renders. It's something in that section that is tanking my chart. Am I missing a component or helper that is required for the 'time' type to function? I have the latest version of chart.js installed (3.7.0), but that's the only external script I have linked.
scales: {
x: {
type: 'time',
time: {
unit:'month',
},
title: {
display: true,
text: 'Date'
}
},
}
OK, so yes I figured out I was missing some files: Luxon 1.0, and the Luxon adapter (chartjs-adapter-luxon), available on GitHub (https://github.com/chartjs/chartjs-adapter-luxon). I struggle with GitHub sometimes, plus I didn't want to link to any non-local files. I managed to find and view each file in a browser window, and then just saved each page's source as a plain text doc, which I named appropriately. Stashed those in the same local directory as my chart's HTML page and then linked each file to my chart's page in its HTML. My chart sprang to life and all is well. I take it there's a better way to get a file off of GitHub, but I couldn't figure that out. Apologies for the knumbskullery, but it worked...

Chart.js ignoring fill to start

I have a line chart made with Chart.js. It has positive and negative values. I want to 'fill' it with a background color, but to the bottom of graph–not to 0.
After reading the documentation I figured you'd need to set the fill property to 'start'. But this doesn't seem to work?
Here's a fiddle. Below is a picture to explain.
According to Chart.js documentation:
2 prior version 2.6.0, boundary values was 'zero', 'top', 'bottom'
(deprecated)
If anyone runs into this issue–don't be me. Check that you're using 2.6+ and not 2.4 like me.. 🤦‍♂️

Chart.js line chart not showing point on top most value

Just like to ask why the point is not displayed on the top most line (blue line, red line is showing the point sample chart). I'm using version 2.7, thanks.
There is a bug listed in v2.7.0 with this issue.
Here are some options, most of them are listed in the issue above.
Try v2.6.0
Add some extra space on top using stepSize option
Wait for a bug fix

Raphael arrow heads not shown up in pdf

I am creating a chart using raphael.js. In my chart there are rectangles which are connected using arrows. I am exporting this svg using Raphael Export and then converting this svg string to pdf using batik. But in the pdf i am not getting the arrowheads at the connectors connecting the various rectangles in the pdf. I am using raphael graffle for creating connection between rectangles.
I really need those arrows in the pdf. Please let me know what could be the issue.
Also adding defs tag statically and replacing the arrow-head attribute with marker-end-url by manipulating the svg string doesn't looks like a good solution.Is there any other way of doing it.?
I think i have found the issue.
It seems like the issue is with the defs tag(that contains the marker ids) of raphael are not included in exported svg and also marker-end-url attribute is not present in the path elements because of which arrow-heads are not showing.
In path elements of rapahel, while export, instead of marker id another attribute is added which is "arrow-end": "classic-midium-midium". So when i added the defs tag of raphael into my generated svg and replace the arrow-end attribute with the marker-end-url attribute by giving the required value the arrow heads appeared.
But now the issue is with the positioning of arrow heads. In the exported svg the x and y coordinates of horizontal and vertical arrowheads is slightly more which leads to intersection of arrows with the object(rectangles in my case) which doesn't look good. But yes for now i am going with it.I have modify raphael.export.js. So for any one who looking for solution have to add following 2 lines of code in raphael.export.js
1.In R.fn.toSVG function add following after initialization of svg variable at line number 217
You have to append defs tag of raphael to svg variable here. Not able to post here.
2.In the serializer variable where the tag for path is creatd add following line at line number 199
initial['marker-end'] = "url(#raphael-marker-endclassic33)";
Thanks

Change image for Map aonnation view in rubymotion

I want to change UIAnnotationView image on mapkit in rubymotion language.
Any one know this, kindly help me.
How about a complete working example? I just tested it :)
A budy and I converted a LOT of iOS code from the iOS Cookbook to RubyMotion
There's a whole chapter on Maps, but the one that looks to answer your question best is this:
https://github.com/IconoclastLabs/rubymotion_cookbook/tree/master/ch_6/06_custompins
It's just like colored pins, but your main difference will be this
pinImage = UIImage.imageNamed("ilpin.png")
annotationView.image = pinImage
Goodluck! - Gant from Iconoclast Labs
I think you mean, an MKAnnotationView? If so, you just need to set the image property to a new UIImage. See this Gist:
https://gist.github.com/3049611
Based on the RubyMotionSamples Beer project - https://github.com/HipByte/RubyMotionSamples/blob/master/Beers/app/beer_map_controller.rb
I have added a new image file called 'signpost.png' under 'resources', and altered the code from using a pin to using a straight up annotation, with the new custom image.
The following code works fine to change the UIAnnotationView's image
view = MKAnnotationView.alloc.initWithAnnotation(annotation, reuseIdentifier:ViewIdentifier)
view.image = UIImage.imageNamed("ptr.jpg")
view.canShowCallout = true
I have saved the image ptr.jpg in resources folder.