How to create multi-colored vAxis ticks in Google Charts with corresponding light backgrounds

I have been working on customizing the vAxis ticks in my Google chart to display multiple colors. Here is the code I currently have:

var gridlines = [
    '#ff0000',
    '#00ff00',
    '#0000ff'
];
var container = document.getElementById('chart_div');
var chart = new google.visualization.ColumnChart(container);
google.visualization.events.addListener(chart, 'ready', function () {
    var gridlineIndex = 0;
    Array.prototype.forEach.call(container.getElementsByTagName('rect'), function(rect, index) {
        if (rect.getAttribute('height') === '1') {
            rect.setAttribute('fill', gridlines[gridlineIndex]);
            gridlineIndex++;
        }
    });
});
chart.draw(data, options);

The current result can be seen here.

However, I am aiming for a similar look to this image, with different background colors under the ticks. Can someone please guide me on how to achieve this?

Thank you in advance.

Answer №1

https://i.sstatic.net/abcde.png

I implemented this feature using a stepped area chart within the combo chart from the Google library... where each stepped area represents the value for ticks.

For more information, click on this jsfiddle link

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

socket.io establishes several sockets for each connection

At times, when the server is experiencing some load, connecting to the page may result in multiple sockets being created. If there is significant lag, the connection may never be established while additional sockets are generated every second indefinitely. ...

Is there a skilled coder available to troubleshoot this carousel's HTML code?

Hello, I am struggling with the code snippet below that uses Bootstrap to create a carousel. The next and previous buttons are not working properly. <div id="testimonial-carousel" class="carousel slide" data-ride="carousel&qu ...

The functionality of Bootstrap tooltips becomes disabled as soon as any element on the page is clicked

When initializing Bootstrap tooltips on my page, I follow this approach <script> $(document).ready(function () { $(function () { $('[data-toggle="tooltip"]').tooltip(); }); }); </script> A questio ...

Managing an indefinite amount of values within a PHP script

When submitting the data form, there will be a range of 10 to 100 values to be sent to the PHP file. The quantity of inputs is stored in a JavaScript function variable named count, but I am unsure of how to pass this value to the PHP file. One approach I ...

Script designed to track modifications on a specific webpage

Attempting to purchase items online has become a frustrating challenge as stock seems to disappear within minutes of being added :/ I am currently working on creating a custom grease/tampermonkey script to monitor the page and notify me when products beco ...

Spontaneously generating models

Explaining this concept can be a bit complex. I am tasked with creating an object that contains properties from dynamic HTML code. To illustrate, let's use an example: Firstly, here is my data object: var myObject = {Field1: 'Value1', Fiel ...

Style applied directly to .col elements

I want to customize the styling of the .col elements on a single page without affecting other pages. I've tried adding the following code snippet to my CSS file: .col { border: 1px solid #7851A9; } However, this also styles the element ...

Experiencing issues with transferring JSON response from Axios to a data object causing errors

When I try to assign a JSON response to an empty data object to display search results, I encounter a typeerror: arr.slice is not a function error. However, if I directly add the JSON to the "schools" data object, the error does not occur. It seems like th ...

`I am unable to locate the JSON file within Angular 2`

I am experiencing issues loading a .json file from a service file in my Angular2 project. I have set up my Angular2 app using angular-cli and the file structure looks like this: src > app > menu-item > menu-item.service.ts menu-list.json Bel ...

Modify the navbar background color in bootstrap-vuejs

As per the information provided in the documentation, the instructions for setting styles for the navigation bar are as follows: <b-navbar toggleable="lg" type="dark" variant="info"> <!-- Or --> <b-navbar toggleable="lg" type="dark" variant ...

Send image data in base64 format to server using AJAX to save

My goal is to store a base64 image on a php server using the webcam-easy library (https://github.com/bensonruan/webcam-easy). I added a button to the index.html file of the demo: <button id="upload" onClick="postData()" style=" ...

Guide on utilizing `ReactCSSTransitionGroup` for developing an expandable/collapsible list

Utilizing ReactJS to implement a collapsible/expandable list with animation has been my latest endeavor. To access the code, simply visit this link. Upon clicking the Extend button located at the top of the list, I anticipate the items to appear within 1 s ...

What could be the reason for getting undefined when printing console.log(fibonacci(3))?

let array = [0, 1, 1]; const fibonacciSequence = (number) => { if (number < 2) { return array[number]; } else if (number == 2) { console.log(array.length-1); console.log((array[array.length-1])); // return (ar ...

Utilizing AJAX and jQuery to Cast Your Vote in a Poll

I have recently set up a basic poll using AJAX JSON jQuery to interact with the server side, but it seems to be malfunctioning. I would appreciate any guidance on where I may have made a mistake. I am still learning jQuery and JSON. JavaScript <script ...

Tips for managing cross-referencing visibility between two distinct div elements using AngularJS

Currently, I am working on an AngularJS project and facing a specific issue that I need help with. I have two div elements to deal with. The first div contains a list of images as anchors which are generated using the ngRepeat directive. The second div s ...

Show the list in a circular buffer fashion

I am working on a project that involves creating a unique UI element. In Frame #2 of my professionally designed diagram, I envision a list that functions as a ring buffer/rolodex when it exceeds four items. The list would scroll in a loop with the top and ...

Ways to generate data following the integration of Firebase Firestore in Vue.JS

How can I display the orders data retrieved from Firebase in my browser console? See the image link below for reference. https://i.sstatic.net/HPlaC.png This is the code snippet for fetching data from Firebase and displaying it in the console: orders(){ ...

Erase text from an ASP TextBox within a user control by utilizing jQuery on the main page

I am facing a challenge with an ASP .NET webpage that contains dynamically generated user controls (multiple instances of a single control) within multiple repeaters. Each user control has a text box, and I want to clear its content using an HTML button lo ...

Ways to extract only numbers from a string

I have encountered a frustrating issue in VueJS: I am receiving an object with the following structure: { "description": "this is our List.\n Our Service includes:\n-1 something\n-2 something else\n and another thing\n"}` My dile ...