How to extend an existing chart?
See original GitHub issueIm looking to currently change the draw() function of the doughnut to add rounded ends. I have managed to kinda get it working with a registered plugin but not for all my datasets. Is there a way to create my own version of the doughnut?
I know in pure JS i could use something like
Chart.elements.Arc.prototype.draw = function() {
var ctx = this._chart.ctx;
var vm = this._view;
var sA = vm.startAngle;
var eA = vm.endAngle;
ctx.beginPath();
ctx.arc(vm.x, vm.y, vm.outerRadius, sA + window.arcSpacing, eA - window.arcSpacing);
ctx.strokeStyle = vm.backgroundColor;
ctx.lineWidth = vm.borderWidth;
ctx.lineCap = 'round';
ctx.setLineDash([15]);
ctx.stroke();
ctx.closePath();
};
But im not clear on how to actually extend and create my own chart to use that draw in react-chart-js.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
Update the data in an existing chart - Microsoft Support
Changes you make will instantly show up in the chart. Right-click the item you want to change and input the data--or type a...
Read more >Create Helm chart extending an existing chart - Stack Overflow
I want to extend the Gitlab helm chart, to do so I am adding it as a requirement of my own chart. The...
Read more >Modify Excel Chart Data Range - CustomGuide
1. Select the chart 2. Click the Design tab. 3. Click the Select Data button.
Read more >How to Extend a Trendline on Excel
Because there are a variety of charts available, such as line and bar, determine the best chart style to suit the type of...
Read more >How to extend Chart capabilities using AdvancedFormat?
OutSystems Charts are based on the Highcharts API and, have an option to extend the capabilities of the existing chart component by adding...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m working on a bar chart with customized rounded corners, not doughnut but I was able to extend the draw function with
react-chartjs-2
. The below code may give you some ideas on how to get it done.In order to extend the draw function, usually you need to use
componentWillMount()
, but it’s going to be deprecated in the future, soconstructor()
is one place to draw before render.To have rounded bars in bar chart, you would need do something like this:
And then add a
cornerRadius
value to theoptions
object, like this:How do you replace
var ctx = this._chart.ctx; var vm = this._view;
when using React hooks?