Establishing the bottom limit for the vertical axis on a column chart with the Visualization Google API

I am currently working on implementing the Google Chart API alongside AngularJS.
I attempted to adjust the min property of the vertical axis for my column chart to 0 using the following code:

var dataMois = CaDuMois.query(function(){
    $scope.comparatifVentes.data = {
        "cols": [
            {id: "t", label: "Month", type: "string"},
            {id: "s", label: "Sales", type: "number"}
        ],
        "rows": [
            {c: [
                {v: d.getFullYear()-4},
                {v: dataMois[4].value},
            ]},
            {c: [
                {v: d.getFullYear()-3},
                {v: dataMois[3].value}
            ]},
            {c: [
                {v: d.getFullYear()-2},
                {v: dataMois[2].value},
            ]},
            {c: [
                {v: d.getFullYear()-1},
                {v: dataMois[1].value},
            ]},
            {c: [
                {v: "Current "+d.getFullYear()},
                {v: dataMois[0].value},
            ]}
        ],
        "vAxis.viewWindow": [{min:"0"}]
    };
    $scope.comparatifVentes.type = "ColumnChart";
    $scope.comparatifVentes.options = {
        'backgroundColor': '#f5f5f5',
        'title': "Total Sales Amount (€) for the Last 5 Months of "+monthNames[n],'height':"250"
    }
});
<div class="row">
    <div class="col-md-12">
        <div google-chart chart="comparatifVentes" style="{{chart.cssStyle}}"/>
    </div>
</div>

However, despite setting the min to 0, the value displayed on my chart remains at 250000.
Could I possibly be making an error somewhere in my implementation?

Answer №1

According to the documentation on Visualization: Column Chart:

vAxis.viewWindow.min

The minimum horizontal data value to display.

Not taken into account when vAxis.viewWindowMode is set to 'pretty' or 'maximized'. Type: number Default: auto

I believe there might be a typo in the word “horizontal”.

This code snippet demonstrates the correct way of implementing it:

// create it correctly
var options = {
    vAxis : { 
        viewWindow : { 
            min : 0 
        }
    } 
}

If you need to modify it after creation, you can do it like this:

// use this if the variable already exists
options.vAxis.viewWindow.min = 123;

Your initial implementation is incorrect for two main reasons:

// avoid doing it this way
var options = { "vAxis.viewWindow" : [{min:"0"}] }
  • This creates options["vAxis.viewWindow"] instead of options["vAxis"]["viewWindow"]
  • It places the value inside an object and that object within an array. Thus, to access it, you would need to refer to it as:
    options["vAxis.viewWindow"][0]["min"]

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

Error: The current element cannot be clicked. Please try again

I have been attempting to trigger a click event on another button within an onClick event function. An error occurred: Uncaught TypeError: this.clickBack.current.click is not a function The React version being used is 16.8.6 constructor(props) { s ...

Issue with Phong material not responding to area light in a three.js.obj model

Trying to incorporate both a phong material and a shader area light onto my .obj model has proven to be problematic. I attempted using an array within Meshface material to load both materials, but the model vanishes completely when both are applied simulta ...

Creating a custom type for accepted arguments in a Typescript method

Below is the structure of a method I have: const a = function (...args: any[]) { console.log(args); } In this function, the type of args is any[]. I am looking to create a specific type for the array of arguments accepted by this method in Typescript. ...

Triggering multiple onClick events in React / Material-UI when used within a data.map() loop

My English may not be perfect. {data.sort(getSorting(order, orderBy)) .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) .map(n => { {/*........*/} <Button onClick={this.handleLsClick}> Open Menu < ...

Tips for updating a value within ng-repeat only if the value is equal to "string"; otherwise, hide it from display

I'm having trouble updating the data in my table to display "Yup" or blank space based on certain conditions. I am new to this and tried a solution, but it's not working: {{ person.value ? "Yup":" "}} .. Can anyone help me with this? angular.m ...

What's the best way to trigger an event within a tag in a Vue.js component?

app.js Vue.component("popup",{ template : /*html*/` <div class="popup is-active" > <div class="popup-background"></div> <div class="popup-card"> <header class=" ...

Creating content by extracting key value pairs from a JSON object retrieved from Firebase

After setting up a Firebase database and populating it with JSON data, I found code from the Firebase documentation that allows me to update the data in real time. While this works well for my needs, I also want to access the values in the JSON to create l ...

Exploring the concepts of arc functions in discord/js programming

Example: Having trouble understanding how to create an arc in JavaScript based on a percentage input? Here's a simple explanation: feed it a percentage and it will create an arc that represents that percentage of a circle. I've managed to get t ...

Determining the best use-case for a React framework like Next or Gatsby versus opting for Create React App

As I delve into the world of React and JavaScript, I find myself in the fast-paced prototyping stage. I can't help but ponder at what point developers choose to utilize frameworks like Next.js or Gatsby.js over the usual Create React App. I'm pa ...

Select a background using the Konvas.js library by clicking on a CSS class

I am attempting to use Konvas.js to change the background when clicking on an image with the imgback class: Link to Code I want to avoid assigning an id to each individual image Here is the code snippet: Jquery: $('.back').click(function(){ ...

The requested command is not being recognized

Just starting out with these commands as I dive into learning Angular.js through a book. npm install –g grunt-cli npm install –g bower npm install –g generator-angular After successfully running all the commands, I attempted to create a folder in C ...

The rationale behind organizing analogous variables into groups

Currently, I am grappling with determining the optimal logic for grouping parameters within a specified tolerance level. Let me illustrate this with an example... Task1: parameter1=140 Task2: parameter1=137 Task3: parameter1=142 Task4: parameter1=139 Task ...

Creating the jquery/javascript code needed to produce an event or alert similar to the "Confirm Navigation" prompt used on sites like Stack Overflow

Similar Question: How can I have a confirmation message when navigating away from a page after making changes? I've noticed an interesting feature on Stackoverflow: when you start writing a new question and attempt to leave the page, it prompts y ...

Include a link to a JavaScript file within a dynamically created HTML page in a Delphi VCL application

I am currently developing a Delphi XE5 VCL Forms Application which includes a TIdHTTPServer on the main form. Within this server, there is a CommandGet procedure called IdHTTPServer: procedure TForm1.IdHTTPServerCommandGet(AContext: TIdContext; ARequest ...

Unlocking Discord Account Information through OAuth2

Currently, I am in the process of developing a moderation bot for Discord. I am working on implementing a paid plan and as part of that, I require users to log in with their Discord account using OAuth2. This allows me to retrieve user data and identify wh ...

Does the syntax for the $.ajax() function appear to be incorrect in this instance?

I am attempting to use .ajax to retrieve the source HTML of a specific URL (in this case, www.wikipedia.org) and insert it into the body of a document. However, the code provided below is not producing the expected outcome. <!DOCTYPE html> < ...

Utilizing KnockoutJS to Apply CSS Binding Based on Dropdown Selection

Check out the live example here: http://jsfiddle.net/0gmbbv5w/ In my application, I have an object retrieved from the database that I bind to a <select> var NoticeType = function (noticeType) { this.NoticeTypeId = ko.observable(noticeType.Notic ...

A Fresh Approach for Generating Unique UUIDs without Bitwise Operators

To generate UUIDs in TypeScript, I have implemented a method inspired by the solution provided on Stack Overflow. The code effectively converts JavaScript to TypeScript. generateUUID(): string { let date = new Date().getTime(); if (window.performa ...

Which Express.js template allows direct usage of raw HTML code?

I am in search of a template that utilizes pure HTML without any alterations to the language, similar to Jade but keeping the HTML as is. The reason behind this inquiry is: I prefer the simplicity and clarity of HTML I would like to be able to easily vi ...

How can parameters be included in ng-href when using ng-click?

So I have this list of products and I want to pass the current product id when clicking on ng-href by using a function with ng-click in the ng-href. This is what my html file looks like: <div class="agile_top_brands_grids" ng-model="products" ng-repe ...