JQuery Flot - Grid lines disappearing behind filled lines

Trying to create a real-time flot and facing the challenge of not being able to see the grid through the filled data lines.

If there are any ideas on making the filling transparent like in the example picture linked below, I would appreciate suggestions for implementing it in my Fiddle!


The goal is to achieve something similar to: Desired Outcome

Link to my working area on Fiddle: My Fiddle Work

Code:


$(function () {

    getRandomData = function(){
        var rV = [];
        for (var i = 0; i < 10; i++){
             rV.push([i,Math.random() * 10]);
        }
        return rV;
    }

    getRandomDataa = function(){
        var rV = [];
        for (var i = 0; i < 10; i++){
             rV.push([i,Math.random() * 10 + 5]);
        }
        return rV;
    }

    getSeriesObj = function() {
        return [
        {
            data: getRandomDataa(),
            lines: { 
                show: true, 
                fill: true,
                lineWidth: 5,
                fillColor: { colors: [ "#b38618", "#b38618" ] },
                tickColor: "#FFFFFF",
                tickLength: 5
            }
        }, {
            data: getRandomData(),
            lines: {
                show: true,
                lineWidth: 0,
                fill: true,
                fillColor: { colors: [ "#1A508B", "#1A508B" ] },
                tickColor: "#FFFFFF",
                tickLength: 5
            }
        }];
    }

    update = function(){
        plot.setData(getSeriesObj());
        plot.draw();
        setTimeout(update, 1000);
    }

    var flotOptions = {  
        series: {
            shadowSize: 0, 
            tickColor: "#FFFFFF"
        },
        yaxis: {
            min: 0, 
            autoscaleMargin: 0,
            position: "right",
            transform: function (v) { return -v; },    
            inverseTransform: function (v) { return -v; }, 
            font: { color: "#FFFFFF" },
            tickColor: "#FFFFFF"
        },
        grid: {
            backgroundColor: { colors: [ "#EDC240", "#EDC240" ], opacity: 0.5 }, 
            show: true,
            borderWidth: 1,
            borderColor: "#FFFFFF",
            verticalLines: true,
            horizontalLines: true,
            tickColor: "#FFFFFF"
        }
    }; 

    var plot = $.plot("#placeholder", getSeriesObj(), flotOptions);

    setTimeout(update, 1000);
});

Many thanks!

Answer №1

To specify the fill color and transparency level using flot, you can utilize the rgba() color specification as shown below:

fillColor: { colors: [ "rgba(179, 134, 24, .2)", "rgba(179, 134, 24, .2)" ] },

An alpha value of 0 represents full transparency, while an alpha value of 1 signifies full opacity.

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

How to Retrieve Data from an HTML Table using the Laravel Framework

I have a unique and interactive Dynamic Sortable Table where I can effortlessly add or delete rows likethis uploaded image here. There is an intriguing loop in my controller that runs precisely 4 times, based on the number of columns in the table. However, ...

Problem with passing values using jQuery AJAX GET method

Currently, I am facing an issue with a jQuery AJAX call that uses the type 'GET' method. Here is the code snippet: $.ajax({type:'GET',url:'/createUser',data:"userId=12345&userName=test", success:function(data){ al ...

Getting the output from AJAX when the onreadystatechange event occurs

Struggling with retrieving a value from a function and storing it in a variable? Getting an "undefined" result due to JavaScript's asynchronous nature? Unsure how to fix this using "callbacks" or "promises"? Check out the code snippet below. The goal ...

Overlaying Div Concealed by Background Video Filter

Whenever we add a filter to our background video, the div overlay ends up moving behind the video and becoming hidden. To see an example of this issue, check out this fiddle showcasing the background video with the text overlay: https://jsfiddle.net/dyrepk ...

Having trouble with gapi.client.request() not functioning properly?

I've been trying to use the Google API for freebase, and even though I'm following the correct call as per the documentation, it seems like there is an issue. The Chrome debugger is showing that something is wrong with this supposedly simple call ...

Allow users to copy and paste on a website where this function is typically restricted

Just wanted to mention that I have very little coding knowledge, so I appreciate your patience. I'm attempting to paste something onto a site that doesn't allow it. Here is the link to the javascript they used to block it: A friend of mine recom ...

How to utilize Node.js to send a document to Amazon S3

I recently wrote a function to upload files to S3 using the 'aws-sdk' in JavaScript, but I encountered an issue. When I replaced Body with Body: "test", the function executed successfully and I could see the content 'test' in my S3 buc ...

Navigation panel featuring points of interest

Greetings, my name is Kasper! I am currently working on incorporating waypoints into the sidebar of my portfolio website, a feature I just recently discovered. However, I seem to be struggling with getting it right. Here is a snippet of my code: < ...

Button maintains focus even after being clicked

At the moment, I have a button that carries out navigation to another route when clicked. Here is the relevant code snippet: <button (click)="goBack()" mat-button aria-label="Previous Screen" role="navigation"> <mat-icon>keyboard_a ...

The issue with Firebase's real-time database is that data constantly gets overwritten within a single node

Having an issue with writing data to my Firebase realtime database. Below is the code I am using: firebase.database().ref("ac/0/").set(null); firebase.database().ref("ac/0/").once('value', function(snapshot){ for(var i=0; ...

The touchstart event is activated when you touch an item within

Is it possible to retrieve the index of ul li elements with touchstart, similar to how it can be done with a click function? <ul id = "list" ontouchstart="touchStart(event,'issues')"> <li> ...

Tips on including a trash can symbol to rows in a bootstrap table using React

I am working on a table that contains various fields, and I want to add a trash icon to each row so that when it is clicked, the specific row is deleted. However, I am encountering an issue where the trash icon is not showing up on the row and I am unable ...

How can we improve our vertical division method?

Looking for a more efficient way to create a vertical divider between two divs. I want the divider to be centered between the "why choose" and "gallery" sections. Here is an example of what I'm trying to achieve. I've attempted the following co ...

Can you explain the distinction between InternalArray and Array within Google's V8 engine?

The Google Javascript engine v8 has the InternalArray and Array components. While Array is accessible to users, InternalArray is designated for internal use only. What sets these two apart? Are InternalArray and Array essentially the same thing? ...

What is the best way to arrange 5 images in a single row using the bootstrap grid system?

I managed to recreate the following screenshot using Bootstrap 4.1: https://i.sstatic.net/fXaSt.png Check out this fiddle for my attempt, although the alignment of the images is not quite right. The HTML code I used in the fiddle to replicate the screen ...

Utilizing AJAX to transfer information into a modal window in CodeIgniter

I find it a little embarrassing to admit, but a few months ago I had asked the same question. Unfortunately, I failed to implement it with codeigniter back then. If you're curious, you can check out my old question. My current challenge involves upd ...

Modify the form's action attribute when submitted

I am trying to create a form with multiple buttons that will change the action and target properties when a specific button is clicked. Below is my code snippet: <div id="root"> <form :action="form.action" ref="form" :target="form.target"&g ...

Unable to add padding to <b> tag

Can anyone explain why the padding-top property is not taking effect for the <b> tag? Check out this link <b>hello world</b>​ b { padding-top: 100px; } ​ ...

Tips on how to properly handle Promises in a constructor function

My Angular Service is currently making http requests, but I am looking to retrieve headers for these requests from a Promise. The current setup involves converting the promise to an Observable: export class SomeService { constructor(private http: HttpCl ...

Making an element transparent in CSS without affecting the text within it

Recently, I created a menu block element and decided to apply an opacity of 0.4/40 to it. However, I encountered an issue where the text within the menu block was also affected by the opacity. My aim is to have the opacity only impact the menu block itsel ...