Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8803953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:28:39+00:00 2026-06-14T01:28:39+00:00

I am trying to get a color gradient that looks like this: value 0

  • 0

I am trying to get a color gradient that looks like this: value 0 = green, value 20 = yellow, value 40 = red. So I am using a lineargradient with 2 or 3 stops, depending on if my actual data maximum exceeds 20 or not. This is the only way I could get the lineargradient to move through a HSL type color space. It works great. The problem is when I zoom, the lineargradient is reapplied to a potentially smaller scale. I want the yellow color to always be centered around a value of 20, with any possible zoom scenario. Now, when I zoom, the yellow may be centered around a much smaller value. Any idea how to accomplish this? Do I have to change the gradient every time a zoom happens? Here is the code:

  var data=env.client.data;
  var selected=env.client.selected;

  var max=_.max(data,function(slice){
    return(slice[1]);
  })[1];

  if(max>0){
    var stops=[
      [0,'hsla(120,50%,50%,0.5)']
    ];

    if(max>20){
      stops.push([20/max,'hsla(60,50%,50%,0.5)']);
      stops.push([1,'hsla('+Math.round(120-(120*(max/40)))+',50%,50%,0.5)']);
    }else{
      stops.push([1,'hsla('+Math.round(120-(60*(max/20)))+',50%,50%,0.5)']);
    }

    var chart=new Highcharts.Chart({
      chart:{
        height:250,
        renderTo:'chart',
        type:'areaspline',
        width:960,
        zoomType:'x'
      },
      legend:{
        enabled:false
      },
      plotOptions:{
        areaspline:{
          animation:false,
          fillColor:{
            linearGradient:{
              x1:0,
              y1:1,
              x2:0,
              y2:0
            },
            stops:stops
          },
          lineColor:'black',
          lineWidth:1,
          marker:{
            enabled:false,
            states:{
              hover:{
                enabled:true,
                radius:5
              }
            }
          },
          point:{
            events:{
              click:function(){
                var point=moment(this.x).utc();
                env.client.range.selected=point;
                $('#client-datetime').val(point.format('YYYY MMM DD, HH:mm'));
                _.publish('client date changed');
              }
            }
          },
          states:{
            hover:{
              lineWidth:1
            }
          }
        }
      },
      series:[{
        data:data,
        name:'Clients'
      }],
      title:{
        text:null
      },
      tooltip:{
        animation:false
      },
      xAxis:{
        maxZoom:12*60*60*1000,
        title:{
          text:null
        },
        type:'datetime'
      },
      yAxis:{
        max:max,
        min:0,
        minTickInterval:1,
        title:{
          text:null
        }
      }
    });
  }else{
    $('#chart').html('');
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:28:40+00:00Added an answer on June 14, 2026 at 1:28 am

    Figured out the issue. Apparently if the data set is larger than 300 points, the zoomed view only uses the closest 300 points and redraws, which thus impacts the effect of the gradient. Fortunately, this size is adjustable via the cropThreshold parameter. I just set that to the size of my data set (2017), and it works great, though a little slower, since it is still rendering all the data points, but most of them may be outside the viewable area, which is inefficient, except it maintains my gradient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to get Color information that i've stored in a text file and
Using the following code, trying to get the font color to animate on hover,
I am trying to get the RGB background color in IE using the following
I am trying to get a random color. I have done it using brute
I'm trying to replicate this: http://webdesignerwall.com/tutorials/css-gradient-text-effect however I can't seem to get it to
I'm trying to get rgb color info from every pixel using imagecolorat() and I'm
I have a div box that looks like this: .productholder { width: 954px; margin-left:
http://jsfiddle.net/UhNHW/ I'm trying to get a color block to slide in behind existing content
How can I convert a System.Windows.Media.Brush to System.Drawing.Brush? I'm trying to get the color
I'm trying to get d3 to change the color of plot points upon clicking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.