Alter the hue within Google Chart

I'm working on customizing a Google Bar Chart with Material design and running into an issue with changing the background color. I've tried using backgroundColor and fill identifiers in the options, but the inner area of the chart where the data is displayed remains white. Here's the code I've been working with:

 var barchart_options = {
            width: 600,
            height:350,
            backgroundColor : '#CFC3F8',

            .......

When attempting to use the fill identifier, I updated the code like this:

backgroundColor : {fill:'#CFC3F8'},

I even took a screenshot to show the issue:

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

Answer №1

there is also a possibility to set the backgroundColor of the chart area

var preferences = {
  backgroundColor: '#CFC3F8',
  chartArea: {
    backgroundColor: '#CFC3F8'
  }      
};

only the color is required

check out the snippet below for a working example...

google.charts.load('current', {
  callback: drawChart,
  packages: ['bar']
});

function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['Year', 'Sales', 'Expenses', 'Profit'],
    ['2014', 1000, 400, 200],
    ['2015', 1170, 460, 250],
    ['2016', 660, 1120, 300],
    ['2017', 1030, 540, 350]
  ]);

  var options = {
    backgroundColor: 'magenta',
    chartArea: {
      backgroundColor: 'cyan'
    }
  };

  var chart = new google.charts.Bar(document.getElementById('chart_div'));

  chart.draw(data, google.charts.Bar.convertOptions(options));
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

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

Store image selection in state

I am currently working on building an imagePicker in ReactNative, but I am running into an issue when trying to select the image. The error message I am receiving is: TypeError: this.setState is not a function. (In 'this.setState ({ avatar: data}) &a ...

Ways to authenticate custom kinds in JSON schema?

When working with JSON Schema, one of the challenges I have faced is the limitation on supporting ‘double’ and ‘float’ types for numeric values. While using AJV in JavaScript to validate a schema, it fails due to this restriction. Is there a way to ...

How to determine if a scrolling action is initiated manually using jQuery

Here is a question that was previously asked long ago: Detect jquery event trigger by user or call by code Despite previous inquiries, a conclusive answer has not been provided (or I may just be inadequate at searching). My query pertains to distinguish ...

Stop the page from scrolling when scrolling within a specific DIV to address the [Violation] warning appearing in the console

Initially, it may seem like a duplicate question that has been answered here, but there are additional aspects that need to be addressed. How do I resolve the following [Violation] warning in the Google Chrome console? [Violation] Added non-passive eve ...

What is the process for exporting data from MongoDB?

Recently, I created a web application for fun using Handlebars, Express, and Mongoose/MongoDB. This app allows users to sign up, post advertisements for others to view and respond to. All the ads are displayed on the index page, making it a shared experie ...

Can default query parameters be predefined for a resource in AngularJS?

When working with a simple resource like the one defined below, it is possible to utilize the Receipt.query() method to retrieve a collection from the server. In addition, by calling Receipt.query({freightBill: 123}), a query parameter such as freightBill ...

How can I adjust iframe content to fit properly on a mobile device screen?

I am facing a challenge where I need to embed an iframe into an external website over which I have no control. The only thing I can specify is the size of the iframe on my own website. My goal is to ensure that the content within the iframe adjusts to fit ...

A custom class that uses toggleClass() does not trigger an alert upon a click event

I am encountering an issue with the toggleClass() function in jQuery that I haven't seen addressed before. Despite successfully toggling the class of one button when clicked, I am unable to trigger a click event on the newly toggled class. Here is th ...

Implement dynamic configuration injection by allowing users to specify the name of a configuration file during runtime, instead of having it fixed in the code

In my development using webpack, I am exploring ways to make my application configurations more dynamic. Presently, the project is a create-react-app that has been ejected. For instance, when creating a local build in my package.json file, I include the f ...

Performing a password-protected JavaScript Ajax request that includes special characters

Within my JavaScript page, I have implemented an Ajax call shown in the code snippet below. The PHP page resides within a corporate intranet that demands domain authentication (without basic auth). To extract the username (u) and password (p), I am using j ...

Integrating webpack and Vue async components from separate projects or domains

Having recently ventured into webpack, I have watched several tutorials and successfully configured it for my project. One of the challenges I encountered was loading vuejs components asynchronously using the following method: <template> <div ...

Tips for bringing in and taking out data in Vue

I have a set of files called total.vue and completeness.vue. I aim to display the chart from total.vue within completeness.vue, which is my designated admin dashboard where I plan to feature 2 or 3 additional charts. For this task, I will be exporting con ...

The browser sends a request for a file, the server then downloads a pdf, and finally, the

Here is the process I am trying to achieve: 1) A browser sends an ajax request to the server, requesting a pdf file. 2) The server downloads the pdf file and returns it for display. 3) The browser then displays the downloaded pdf in an existing iframe. Be ...

After reaching the conclusion, the code restarts

Any ideas on how to reset this code every 10-20 seconds? I'm struggling to find a solution! I'm new to coding, so any assistance would be greatly appreciated. Here's the code: var items = document.getElementsByClassName('btn-primary n ...

Encountered an npm installation error: The rollbackFailedOptional issue arose during the npm session with the verb npm-session a0d68 while attempting the command npm install --save

Every time I attempt to install babel, I encounter the following error message: rollbackFailedOptional: verb npm-session a0d68 The version of Node currently installed is 12.16.1 The version of npm being used is 6.13.4 All I want is to get babel up and ...

Tips for resolving the error: finding the right loader for handling specific file types in React hooks

data = [{ img: '01d' }, { img: '02d' }] data && data.map((item) => ( <img src={require(`./icons/${item['img']}.svg`).default} /> )) I am facing an issue with the message Error: Module parse failed: U ...

Using ng-checked directive with a radio button in AngularJS

Within my angular application, I have implemented a loop to iterate through a collection and display the records using input type="radio". <tr ng-repeat="account in vm.pagedAccounts.items" ng-class="{ 'highlight': (account.row ...

When attempting to call a bundle file using browserify from React, an unexpected character '�' Syntax error is thrown: react_app_testing/src/HashBundle.js: Unexpected character '�' (1:0

Hey there, I'm currently struggling with an unexpected unicode character issue. Let me provide some context: I've created a simple class called HashFunction.js that hashes a string: var crypto = require('crypto') module.exports=class H ...

Unable to access the 'fn' property of undefined in Handlebars causing a TypeError

I encountered an issue with my custom handlebars helper. When I fail to define values for the parameters, I receive the following error message. module.exports = function(src, color, classatr, options) { if (typeof src === 'undefined') src ...

What is the method to spin an item in three js while keeping its axis in focus?

Looking to rotate a globe object around its y-axis smoothly? I have come across a helpful function for achieving this: function rotateAroundObjectAxis(object, axis, radians) { var rotationMatrix = new THREE.Matrix4(); rotationMatrix.makeRotationAxis ...