Insert a stylish border to frame the Google pie chart

I recently created a Google Pie chart and I'm looking to add a border around it. Can anyone provide assistance with this task? Below is the code for the Google Chart along with an image of how I would like it to appear.

    <!DOCTYPE html>
    <html>
    <head>

    <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.js"></script>

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

    google.load("visualization", "1", {
        packages: ["corechart"]
    });

    google.setOnLoadCallback(drawChart);

    var values = [];

    $(document).ready(function() {
        $.ajax({
            type: "GET",
            url: "ChartData.xml",
            dataType: "xml",
            success: function(xml) {
                $(xml).find('Pie').each(function() {
                    var sTitle = $(this).find('Title').text();
                    var sValue = $(this).find('Value').text();

                    if (!isNaN(+sValue)) {
                        sValue = +sValue;
                    }

                    values.push([sTitle, sValue]);
                });

                drawChart(values);
            },
            error: function() {
                alert("There was an issue processing the XML file.");
            }
        });
    });

    function drawChart(val) {

        var data = google.visualization.arrayToDataTable(val);

        var options = {'title':'Sample Charts', 'width':650, 'height':600, pieHole: 0.5, colors: ['#F6891F', '#A59B91', '#72C5EF', '#53585A', '#C8502B'], tooltip: {showColorCode: true}, is3D: false };

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
    }
    </script>
    <title>My Read</title>
    </head>

    <body>
        <div id="piechart" style="border: 1px solid black;"></div>
    </body>
    </html>

Answer №1

#donutchart {
    width:150px;
    margin: 15px;
    border:3px solid blue;
    border-radius: 80px;
    -webkit-border-radius: 450px;
    -moz-border-radius: 450px;
}

Feel free to experiment with this CSS style. Adjust the dimensions as needed. Hopefully, this will be helpful for your project.

Answer №2

An old query, but there may still be someone who finds this information helpful:

function drawPieBorder(chart) {
    var layout = chart.getChartLayoutInterface();
    var chartArea = layout.getChartAreaBoundingBox();
    var svg = chart.getContainer().getElementsByTagName('svg')[0];
    var radius = chartArea.height/2;
    var path = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
    path.setAttribute('stroke', 'black');
    path.setAttribute('stroke-width', 1);
    path.setAttribute('fill', 'transparent');
    path.setAttribute('cx', radius + chartArea.left);
    path.setAttribute('cy', radius + chartArea.top);
    path.setAttribute('r', radius);
    svg.appendChild(path);
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting up express with mongodb - A step-by-step guide

Currently exploring the world of Express App, I am attempting to configure mongodb using express and node.js. Facing a few issues in this process and seeking assistance. I have included directory references for better understanding. 1- The variable config ...

Is your display:inline-block feature not functioning properly?

I am currently designing the homepage for this website and I am attempting to arrange the category divs under the header in a grid layout, with 3 divs per row. I have been trying to achieve this using display:inline-block, but so far, I can only get the d ...

"THREE JS: Bringing Life to Visuals through

There is a model with animation. I recently upgraded to a new animation system but I can't seem to get it to work. Could it be that I set up the export incorrectly? Here are the files for reference: Snippet of the code: var mixer = new THREE.Animati ...

Discovering the block's height with the power of Jquery

I have written a piece of code that sets the height of a block of text and then applies that height to an image within the block. However, the size of the image ends up being smaller than the size of the block. https://i.stack.imgur.com/QUFWy.png <scr ...

What is the process for assigning specific tags to specific items within an array?

As I navigate through a list of students, I am encountering an issue with my tag functionality. Currently, when a student adds a tag to their container, it is being added to every student's tags instead of just the intended student. How can I modify t ...

Troubleshooting: Issues with Material-UI's Disabled attribute functionality

I am facing an issue with disabling the edit button after clicking on complete. I have tried passing the state in the disabled attribute, but it doesn't seem to work. I suspect it may be due to the asynchronous nature of setState. Additionally, when p ...

Issues with updating the style in Internet Explorer and Firefox using JavaScript are currently unresolved

I am facing an issue with my program where a name from an auto-complete is sent to a JavaScript function that dynamically creates a label with a button inside. Surprisingly, the DOM methods used to set style properties do not work in Firefox and IE 7, but ...

Struggling with a syntax error in the JSON response from IMGUR API?

ETA: Take a look at the JSFiddle to see for yourself, remember to check your console: http://jsfiddle.net/GZNwK/1/ Currently, my goal is to fetch data from a subreddit using the IMGUR API: $.getJSON('http://imgur.com/r/cats.json?callback=?',fun ...

Tips for declaring the OpenLayers map object globally

I have successfully created a map with ol 6 and added an OSM layer. Now I am trying to incorporate a vector layer that is coded in another JavaScript file, using the same 'map' object. Despite my efforts to declare it globally, it doesn't se ...

Closing an Angular Modal Service from External Elements - Learn the Techniques

This is the official angular-modal-service Github page. If you're looking for some examples, check out the angular-modal-service examples here. For my current project, I am working on developing a "Custom Modal" without relying on Bootstrap. Here&ap ...

Stretching the Mantine Accordion Section

The Mantine accordion requires that its content be of type Accordion.Item, as indicated in the documentation for the children props. This means that even functions returning AccordionItem will not be recognized. Therefore, only AccordionItem(s) created in ...

What is the best way to create a button with this functionality?

In the form that I have created, it is opened in a bootstrap modal style. This form contains a button that, when clicked, triggers an alert box to appear. The code snippet used for this functionality is as follows: echo "<script>"; echo "alert(&apos ...

The DOM assigned a new source to an image

Currently, I am working on a project that involves both jquery and PHP. In this project, users are able to upload images which are then displayed in blocks. The uploading functionality is already working, but I am facing an issue with setting the image sou ...

The functionality of the angularjs class seems to be malfunctioning

I'm a new learner of angularjs and I've created a simple page below. I have a style called "item" that I'm trying to apply to a div, but it's not working. However, if I use inline style, then it works fine. Can someone please help me f ...

Should React.cloneElement be used to pass new children or copy props.children?

I am having trouble understanding the third parameter "children" of React.cloneElement and how it relates to this.props.children. After reading a helpful guide on higher order components, I implemented the following code: render() { const elementsTre ...

Hiding a column in jQuery DataTables

Can the jquery datatables plugin be used to easily hide and show a table column? I've successfully refreshed the table data by using fnClearTable and fnAddData. However, I'm facing a challenge in one of my table views where I need to hide certa ...

Is it possible to conceal solely the content within the Bootstrap Modal?

Is there a unique approach to only concealing the content within the modal, without hiding the modal itself? The goal is to click "next" and have the content of the next modal displayed, without reopening the modal itself but simply transitioning to the ne ...

A dedicated folder for hosting the static assets generated by Nuxt.js

I have a quick question I'm looking to create a dedicated directory for the static files generated by Nuxt Js Currently, Nuxt Js compiles all files into a single directory called 'dist' As I am utilizing Django Server as my backend, I nee ...

Having trouble editing a form with React Hooks and Redux?

Seeking assistance with creating an edit form in React that utilizes data stored in Redux. The current form I have created is displaying the values correctly, but it appears to be read-only as no changes are being reflected when input is altered. Any advic ...

Avoiding the reset of a variable when utilizing state in React

Is it possible to have a variable in React that remains unchanged during rendering without using context or moving it up the components hierarchy? import React, {useState,useMemo,useRef} from 'react' const Component=()=>{ const [state,setS ...