CandlestickChart colors setting

129 views
Skip to first unread message

Ji Joe

unread,
Aug 31, 2012, 6:07:34 AM8/31/12
to google-visua...@googlegroups.com
I recently made a candlestickChart to show some financial datas. And set the risingColor.fill red and fallingcolor.fill green.
But the color of the stick of candle that present the highest and lowest value of the datas can not be like as the fill .They only show the color of the serie
I want the colors of the sticks in one serie be different, but the serie color option offers only one,
Could someone give me some advices for this problem?Thank you!

asgallant

unread,
Aug 31, 2012, 12:18:03 PM8/31/12
to google-visua...@googlegroups.com
The color of the "wicks" of candles is determined by the series color, and there is no way to override that.  You can make a feature request for it here, if you want.

You could try separating your candlestick series into two different series, one for the rising values and one for the falling values.  A DataView should take care of that for you without too much trouble, maybe something like this:

var view new google.visualization.DataView( data );
view.setColumns([0{
    type'number',
    labeldata.getColumnLabel(1),
    calcfunction (dtrow{
        // if column 2 <= column 3, it's rising, so include here
        return (dt.getValue(row2<= dt.getValue(row3)dt.getValue(row1null;
    }
}{
    type'number',
    labeldata.getColumnLabel(2),
    calcfunction (dtrow{
        // if column 2 <= column 3, it's rising, so include here
        return (dt.getValue(row2<= dt.getValue(row3)dt.getValue(row2null;
    }
}{
    type'number',
    labeldata.getColumnLabel(3),
    calcfunction (dtrow{
        // if column 2 <= column 3, it's rising, so include here
        return (dt.getValue(row2<= dt.getValue(row3)dt.getValue(row3null;
    }
}{
    type'number',
    labeldata.getColumnLabel(4),
    calcfunction (dtrow{
        // if column 2 <= column 3, it's rising, so include here
        return (dt.getValue(row2<= dt.getValue(row3)dt.getValue(row4null;
    }
}{
    type'number',
    labeldata.getColumnLabel(1),
    calcfunction (dtrow{
        // if column 2 > column 3, it's falling, so include here
        return (dt.getValue(row2dt.getValue(row3)dt.getValue(row1null;
    }
}{
    type'number',
    labeldata.getColumnLabel(2),
    calcfunction (dtrow{
        // if column 2 > column 3, it's falling, so include here
        return (dt.getValue(row2dt.getValue(row3)dt.getValue(row2null;
    }
}{
    type'number',
    labeldata.getColumnLabel(3),
    calcfunction (dtrow{
        // if column 2 > column 3, it's falling, so include here
        return (dt.getValue(row2dt.getValue(row3)dt.getValue(row3null;
    }
}{
    type'number',
    labeldata.getColumnLabel(4),
    calcfunction (dtrow{
        // if column 2 > column 3, it's falling, so include here
        return (dt.getValue(row2dt.getValue(row3)dt.getValue(row4null;
    }
}]);

Ji Joe

unread,
Sep 3, 2012, 3:34:33 AM9/3/12
to google-visua...@googlegroups.com
Oh,It's a good method.
But when i combined it with my ChartRangeFilter, the range changed and it showed an error that  Cannot set property 'width' of null    One or more participants failed to draw() 
Also the candles' positions are not normal,a little excursion.
在 2012年9月1日星期六UTC+8上午12时18分03秒,asgallant写道:

asgallant

unread,
Sep 3, 2012, 8:22:49 PM9/3/12
to google-visua...@googlegroups.com
Try setting the candlestick chart's ChartWrapper's view.columns option to the array used in the view.setColumns() call instead of using the DataView object.

As for the positioning, there isn't anything that can be done about it if you split the series like this.  You actually have two series being drawn side-by-side at each data point, but since one of them has no data at each point, then you don't see the second candlestick.
Reply all
Reply to author
Forward
0 new messages