Code Monkey home page Code Monkey logo

Comments (7)

WangLei802 avatar WangLei802 commented on May 28, 2024

image

from tree-chart.

WangLei802 avatar WangLei802 commented on May 28, 2024

如上图 我需要给他这一行 一个随机色

from tree-chart.

ssthouse avatar ssthouse commented on May 28, 2024

@WangLei802 是希望把蓝色换成其他的随机颜色吗?

这样的话, 需要去修改这个蓝色方块绘制时的画笔颜色, 相关代码片段:
https://github.com/ssthouse/organization-chart/blob/master/src/components/org-chart.js#L308

将这个method中的 self.context.fillStyle = '#3ca0ff' 换成你想要的随机色即可

from tree-chart.

WangLei802 avatar WangLei802 commented on May 28, 2024

你好这边是需要 第二行 每个块的颜色都不一样

from tree-chart.

WangLei802 avatar WangLei802 commented on May 28, 2024

@ WangLei802 是希望把蓝色换成其他的随机颜色吗?

这样的话,需要去修改这个蓝色方块绘制时的画笔颜色,相关代码片段:https
//github.com/ssthouse/organization-chart/blob/master/src/components/org-chart.js#L308

将这个方法的中self.context.fillStyle = '#3ca0ff'换成你想要的随机色即可

你好这边是需要第二行每个块的颜色都不一样

from tree-chart.

ssthouse avatar ssthouse commented on May 28, 2024

你好这边是需要第二行每个块的颜色都不一样

要每个都不一样的话, 写一个函数用来随机生成颜色即可, 如:

randomColor () {
    let letters = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
    let color = '#'
    for (let i = 0; i < 6; i++) {
      color += letters[Math.floor(Math.random() * 16)]
    }
    return color
  }

from tree-chart.

WangLei802 avatar WangLei802 commented on May 28, 2024

from tree-chart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.