Datapoint style in Silverlight Chart Series(ColumnSeries/BarSeries/LineSeries) -
i have wierd issue style of silverlight charting controls. when create datapointstyle anyseries ignore existing default color combination. starts showing me same(orange) color haven't set in background of datapointstyle.
what want create custom tooltip , leave background is. not working me. suggestion appreciated.
cheers!
vinod
i think trick not apply data-point style chart itself, rather individual colours make palette.
i started following, uses piechart. same principles should apply when using other types of chart:
<usercontrol x:class="chartpalettedemo.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" mc:ignorable="d" d:designheight="300" d:designwidth="400"> <usercontrol.resources> <style x:key="pointstyle" targettype="toolkit:datapoint"> <setter property="dependentvaluestringformat" value="the value {0:n0}" /> <setter property="ratiostringformat" value="" /> </style> </usercontrol.resources> <toolkit:chart> <toolkit:chart.series> <toolkit:pieseries itemssource="{binding path=data}" independentvaluebinding="{binding path=key}" dependentvaluebinding="{binding path=value}" datapointstyle="{staticresource pointstyle}" /> </toolkit:chart.series> </toolkit:chart> </usercontrol>
this gave me pie chart customised tooltip text segments orange.
the next step set custom palette. palette used silverlight toolkit charts resourcedictionarycollection
, each contained resourcedictionary
representing colour within palette. can find 'default' palette chart within themes\generic.xaml
in assembly system.windows.controls.datavisualization.toolkit
. can use tool such blend or ilspy @ palette.
i took 'default' palette, and:
- removed of setters
datashapestyle
(i'm not sure they're necessary, can keep them if wish), - changed
targettype
of eachdatapointstyle
control
toolkit:datapoint
, and - added
basedon="{staticresource pointstyle}"
eachdatapointstyle
.
this last point sets custom tooltip format each palette entry.
this left me following, added <usercontrol.resources>
:
<toolkit:resourcedictionarycollection x:key="chartpalette"> <!-- blue --> <resourcedictionary> <radialgradientbrush x:key="background" gradientorigin="-0.1,-0.1" center="0.075,0.015" radiusx="1.05" radiusy="0.9"> <gradientstop color="#ffb9d6f7" /> <gradientstop color="#ff284b70" offset="1" /> </radialgradientbrush> <style x:key="datapointstyle" targettype="toolkit:datapoint" basedon="{staticresource pointstyle}"> <setter property="background" value="{staticresource background}" /> </style> </resourcedictionary> <!-- other styles copied similarly, omitted brevity --> </toolkit:resourcedictionarycollection>
i removed datapointstyle="{staticresource pointstyle}"
pieseries
, added palette="{staticresource chartpalette}"
<toolkit:chart>
element instead. when ran application got 4 segments of pie use different colours.
acknowledgement: of has been taken atomlinson's post on silverlight forums @ http://forums.silverlight.net/post/330170.aspx.
Comments
Post a Comment