Feature #3659
closedHow do I control the color of text in Wt::WCartesianChart
0%
Description
0 down vote favorite
I am using Wt::WCartesianChart. (C++11 on Ubuntu 14.04 with default gcc tool chain) I wrote the following code:
void DecorateChart( WCartesianChart* chart )
{
WAxis& x_axis = chart->axis( Wt::Chart::Axis::XAxis );
WColor clrX( 255, 0, 0 );
WPen pX;
pX.setColor( clrX );
pX.setWidth( 3 );
x_axis.setPen( pX );
...
}
This code works fine. x axis on the chart is displayed in bright red. But the label fonts are still rendered in black.
How do I control the color of fonts on the x Axis, and in general, the color of fonts in Wt::Chart widgets - WFont does not seem have a way to control colors - no pen, no brush, no color properties.
Updated by Mikey Nosihcan about 10 years ago
I am still quite new to Wt, and reading through the docs I found WStandardPalette, so I also tried:
WColor clrS( 0, 255,255 );
WPen cp = chart->palette( )->strokePen( 0 );
cp.setColor( clrS );
So that the fonts would show in bright blue/green but this did seem to have any effect. I am unclear as to how add, access and use pens and brushes with WStandardPalette.
Updated by Koen Deforche about 10 years ago
- Tracker changed from Support to Feature
- Assignee set to Koen Deforche
That doesn't change the color in the palette (standard palette doesn't allow that).
You will want to implement a custom palette (specialize Wt::Chart::WChartPalette).
As to the original question: an API call indeed seems to be missing to configure the pen color used for rendering text.
Updated by Mikey Nosihcan about 10 years ago
You will want to implement a custom palette (specialize Wt::Chart::WChartPalette).
OK - will do that, see what it gets me. I did see the docs talking about that, haven't had a chance to get into it yet.
An API call indeed seems to be missing to configure the pen color used for rendering text.
I guess that should become a feature request. I am working with mathematical charts, and I also prefer a dark background with various colors showing different axes in different colors and their relationships to one another - having fonts to match the axis color and that will show up well on dark backgrounds is quite important.
But over-all I am very excited with Wt - I have worked a good deal with gtkmm and Qt so I was up and running with it very quickly. I have been waitng for a tool like this for a long time - finally I can use C to write browser based apps - it's like the holy grail of development for me.
Tnx
Updated by Koen Deforche almost 10 years ago
- Status changed from New to InProgress
- Assignee changed from Koen Deforche to Benoit Daccache
- Target version set to 3.3.4
There's a missing setTextPen() in WCartesianChart that's used for all renderLabel() calls in WCartesianChart and WAxis.
Updated by Benoit Daccache almost 10 years ago
- Status changed from InProgress to Resolved
Added WCartesianChart::setTextPen() and WAxis::setTextPen()
Updated by Koen Deforche over 9 years ago
- Status changed from Resolved to Closed