简体   繁体   English

React Google Charts Candlestick colors 和灯芯未显示

[英]React Google Charts Candlestick colors and wicks not displaying

I am trying to implement the React Google Charts candlestick charts, and I am plugging in my own data into the charts but when the charts are displayed, the candlesticks are all being displayed in one color at a time even when I change the color options.我正在尝试实现 React Google Charts 烛台图表,并且我将自己的数据插入到图表中,但是当显示图表时,即使我更改颜色选项,烛台也一次以一种颜色显示。

options={{
        legend: "none",
        bar: { groupWidth: "100%" }, // Remove space between bars.
        candlestick: {
          fallingColor: { strokeWidth: 0, fill: "#a52714" }, // red
          risingColor: { strokeWidth: 0, fill: "#0f9d58" } // green
        }
      }}

I am almost certain my data is shaped correctly (this is the ordered_data array of arrays passed to the charts data property.我几乎可以肯定我的数据形状正确(这是传递给图表数据属性的 arrays 的 ordered_data 数组。

  data={this.state.ordered_data}

The wicks are also not displaying on the charts even though my data fits into the same shape as the default example data.即使我的数据与默认示例数据的形状相同,灯芯也不会显示在图表上。

I am linking to a codesandbox showing my charts.我正在链接到显示我的图表的代码框。

The chart without any wicks and with all candles with the same color looks as shown below没有任何灯芯且所有蜡烛颜色相同的图表如下所示在此处输入图像描述

The codesandbox with the code for the chart is embedded below.下面嵌入了带有图表代码的代码框。 Here's the official example for using this chart: React Google Charts candlestick .这是使用此图表的官方示例: React Google Charts 烛台 I've tried to customize the colors using the options fallingColor and risingColor settings to no avail.我尝试使用选项fallingColor 和risingColor 设置自定义colors 无济于事。 How can I get the wicks to display?我怎样才能让灯芯显示出来?

You can view the shape of my data from the console in the codesandbox.您可以在代码框的控制台中查看我的数据的形状。

 <iframe src="https://codesandbox.io/embed/charming-oskar-15lkf?fontsize=14&hidenavigation=1&theme=dark" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="charming-oskar-15lkf" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>

looking at the code sandbox and the data in the console,查看代码沙箱和控制台中的数据,
it looks as though your data is structured as follows...看起来您的数据结构如下...

"day", "open", "high", "low", "close"

but according to the data format for Google's Candlestick Chart,但根据谷歌烛台图的数据格式
the data should be structured as follows...数据结构如下...

"day", "low", "open", "close", "high"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM