Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treemap colorScale range begins with 0.85 transparency #4529

Closed
AntoineArt opened this issue Jun 14, 2024 · 2 comments
Closed

Treemap colorScale range begins with 0.85 transparency #4529

AntoineArt opened this issue Jun 14, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@AntoineArt
Copy link

AntoineArt commented Jun 14, 2024

Description

Hi, I can't find a way to get the main tile's color to be exactly the color I set, as it seems to be set by default with an opacity of 0.85.

For context I am using React.

Steps to Reproduce

  1. Use this chart :
'use client';

import ApexChart from '@/modules/utils/apexcharts';
import { Props } from 'react-apexcharts';
import React from 'react';

const defaultOptions: Props['options'] = {
  legend: {
    show: false,
  },
  chart: {
    type: 'treemap',
    toolbar: {
      show: false,
    },
  },
  grid: {
    padding: {
      top: -10,
    },
  },
};

export const SalesTreemap = (props: any) => {
  const max = Math.max(
    ...props.series[0].data.map((item: any) => {
      return item.y;
    })
  );
  const min = Math.min(
    ...props.series[0].data.map((item: any) => {
      return item.y;
    })
  );
  const options = {
    ...defaultOptions,
    title: {
      text: props.title,
      align: 'left',
      style: {
        fontSize: '12px',
      },
    },
    plotOptions: {
      treemap: {
        enableShades: true,
        shadeIntensity: 0.5,
        reverseNegativeShade: true,
        distributed: false,
        useFillColorAsStroke: false,
        dataLabels: {
          format: 'scale',
        },
        colorScale: {
          ranges: [
            {
              from: min,
              to: max,
              color: '#006fee',
            },
          ],
          inverse: false,
        },
      },
    },
  };

  return (
    typeof window !== 'undefined' && (
      <ApexChart
        options={options}
        series={props.series}
        type='treemap'
        height='100%'
      />
    )
  );
};
  1. Run it with a series like :
const series = [
    {
        "data": [
            {
                "x": "Vendeurs",
                "y": 18
            },
            {
                "x": "Service location",
                "y": 2
            },
            {
                "x": "Atelier",
                "y": 4
            },
            {
                "x": "Magasin pièces",
                "y": 4
            },
            {
                "x": "Secrétariat commercial",
                "y": 2
            }
        ]
    }
]
  1. Open your developer tools in your browser
  2. Select the main tile
  3. look at the fill element like here :
    image

Expected Behavior

The color range should begin at 100% opacity, not 85%.
When I set a parameter, I expect it to be used exactly as is, not modified, because here it creates a mismatch between the treemap's main color and my other charts'colors.

@AntoineArt AntoineArt added the bug Something isn't working label Jun 14, 2024
@brianlagunas
Copy link
Member

brianlagunas commented Jun 14, 2024

Please provide a link to a reproduction application. If not, this issue will be closed.

@junedchhipa
Copy link
Contributor

Fixed the original issue. For a quick fix, you can set the opacity in fill options

options = {
  fill: {
     opacity: 1,
   }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants