ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  GetColor doesn't work after layoutAxes();
Posted by Lars on Apr-23-2020 19:47
Im working with an heatmap and the functionality works great when setting the color scale direct based on thresholds.

To get a better flexibility, we would like to use the ColorGradient function, but now the head map is empty (white fields). The GetColor() function is always returning -16777216 instead of the color code to set/plot the correct heat tile.

# Specify the color and scale used and the threshold position
# my $colorScale = [1950, $colorRed, 2000, $colorYellow, 2045, $colorGreen, 2084, $colorYellow, 2150, $colorRed];
my $colorScale = [0xFF4040, 0xFF8D40, 0xFFDA40, 0xDAFF40, 0x8DFF40, 0x40FF40, 0x40FF8D, 0x40FFDA, 0x40DAFF, 0x408DFF, 0x4040FF];
$cAxis->setColorGradient(0, $colorScale);
$cAxis->setLinearScale($minLegend,$maxLegend, 0); #($maxLegend-$minLegend)/5);

# Set color axis labels to use Arial font

# only test output to verify if HASH is transformed correctly
   foreach $key (sort by_hierachy keys %$data_hash)
  # do whatever you want with $key and $value here ...
  $value = $data_hash->{$key}{Value};
  $deviation = $data_hash->{$key}{Deviation};
  my @cpu_line = split(/-/, $key );
  print log_file timestamp, "Hash contains $key with $valuen";
  # generate String Arrays for Chart Director Implementation
  # coordinates are based on data input for CPU 1-1
  my @xCoor = ($cpu_line[0]) x 1;
      my @yCoor = ($cpu_line[1]) x 1;
  my @xyValue = ($value) x 1;
  my $color = $cAxis->getColor($value);
  print $color;
  $c->addScatterLayer(@xCoor, @yCoor, "", $perlchartdir::SquareShape, $cellSize, $color, 0x888888)->addExtraField(@xyValue);

I'm using an XYChart.


  Re: GetColor doesn't work after layoutAxes();
Posted by Peter Kwan on Apr-24-2020 03:01
Hi Lars,

The layoutAxes only affects the x-axis and y-axis. The colorAxis is considered as part of the ContourLayer, and to use it, you need to call BaseChart.layout. Unluckily, you cannot add any additional layers after layout.

For your case, you may create the colorAxis on a separate chart and layout that chart. Then you can use it in the chart that contains the scatter layers.

Peter Kwan

  Re: GetColor doesn't work after layoutAxes();
Posted by Lars on Apr-30-2020 17:22
great idea, I was able to build me a temporary ContourChart ColorAxis to adjust and reuse the color code for the headmap. Its working great and also the runtime is not really higher working the additional helper function.

Thx, Lars