【问题标题】:How to add colored points with white shadow border in chart.js?如何在chart.js中添加带有白色阴影边框的彩色点?
【发布时间】:2018-09-26 19:28:53
【问题描述】:

尝试在 React chart.js 版本:2.7.2 中添加带有白色阴影边框的彩色点,但没有运气请任何帮助。

我现在拥有的

我的代码:

   <div  style={{height: '200px', width: '400px', position: 'relative'}} className={'line-chart'}>


                <Line data={{
                    labels: ["May 09", "May 15", "May 29", "Jun 03"],
                    datasets: [{
                        data: [
                            {
                                x: "May 09",
                                y: 80,
                            },
                            {
                                x: "May 15",
                                y: 98
                            },
                            {
                                x: "May 29",
                                y: 90
                            },
                            {
                                x: "Jun 03",
                                y: 110
                            },
                        ],
                        pointBackgroundColor: ["#f7aa2e", "#05b9af", "#ee734e", "#ee734e"],
                        pointBorderColor: 'rgba(0,0,0,.2)',
                        pointBorderWidth: 3,
                        pointRadius: 4,
                        pointHoverRadius: 5,
                        lineTension: 0,
                        borderWidth: 1,
                        fill: false,
                    }]
                }}
                      options={{
                          legend: {
                              display: false
                          },
                          responsive: true,
                          // maintainAspectRatio: false,
                          scales: {
                              yAxes: [{
                                  display: false
                              }],
                              xAxes: [{
                                  type: 'category',
                                  gridLines: {
                                      display: false
                                  }
                              }]
                          },
                          tooltips: {
                              enabled: false,
                          }

                      }}
                />

            </div>

我正在尝试做的事情

this chart with chart.js Version: 2.6.0 is the chart css different between this two versions?

【问题讨论】:

  • 嗨 Fadi,你找到解决办法了吗?我也在尝试做同样的事情?
  • @AbhishekSoni 我记得没有
  • 好的,没问题,我现在已经在画布上自定义绘制了,非常感谢您的回复,意义重大!

标签: javascript reactjs chart.js chartjs-2.6.0 react-chartjs


【解决方案1】:

如果您只想从点移除边框,则添加 pointBorderWidth: 0, 并移除 pointBorderColor: 'rgba(0,0,0,.2)',

【讨论】:

  • 嗨,我不想删除边框,我需要一个白色边框,周围有一个黑色阴影,就像第二张图片中一样
猜你喜欢
  • 2021-04-19
  • 1970-01-01
  • 2018-12-18
  • 1970-01-01
  • 2016-05-24
  • 1970-01-01
  • 2015-05-08
  • 2020-08-18
  • 2018-06-02
相关资源
最近更新 更多