RadControls for Windows 8

RadControls for Windows 8RadControlsforWindows8http://www.telerik.com/help/wpf/radchartview-populating-with-data-static-data.htmlRadCartesianChartchart=newRadCartesianChart();      chart.HorizontalAxi

大家好,又见面了,我是你们的朋友全栈君。

RadControls for Windows 8

http://www.telerik.com/help/wpf/radchartview-populating-with-data-static-data.html

RadCartesianChart chart = new RadCartesianChart();

            chart.HorizontalAxis = new CategoricalAxis();

            chart.VerticalAxis = new LinearAxis() { Maximum = 100 };

            LineSeries line = new LineSeries();

            line.Stroke = new SolidColorBrush(Colors.Blue);

            line.StrokeThickness = 2;

            line.DataPoints.Add(new CategoricalDataPoint() { Value = 20 });

            line.DataPoints.Add(new CategoricalDataPoint() { Value = 40 });

            line.DataPoints.Add(new CategoricalDataPoint() { Value = 35 });

            line.DataPoints.Add(new CategoricalDataPoint() { Value = 40 });

            line.DataPoints.Add(new CategoricalDataPoint() { Value = 30 });

            line.DataPoints.Add(new CategoricalDataPoint() { Value = 50 });

            chart.Series.Add(line);

            LineSeries line2 = new LineSeries();

            line2.Stroke = new SolidColorBrush(Colors.Orange);

            line2.StrokeThickness = 2;

            line2.DataPoints.Add(new CategoricalDataPoint() { Value = 5 });

            line2.DataPoints.Add(new CategoricalDataPoint() { Value = 44 });

            line2.DataPoints.Add(new CategoricalDataPoint() { Value = 3 });

            line2.DataPoints.Add(new CategoricalDataPoint() { Value = 55 });

            line2.DataPoints.Add(new CategoricalDataPoint() { Value = 22 });

            line2.DataPoints.Add(new CategoricalDataPoint() { Value = 11 });

            chart.Series.Add(line2);

            this.LayoutRoot.Children.Add(chart);

提示信息:

http://www.telerik.com/help/silverlight/radchartview-features-tooltip.html

<telerik:RadCartesianChart x:Name=”radCartesianChart” Margin=”8″ Grid.Row=”2″ Grid.ColumnSpan=”2″>                               
    <telerik:RadCartesianChart.Behaviors>
    <telerik:ChartTooltipBehavior Placement=”Top” />
</telerik:RadCartesianChart.Behaviors>
<telerik:RadCartesianChart.TooltipTemplate>
                <DataTemplate>
                    <Grid>
                        <Path Data=”M-1236,-441 L-1180,-441 -1180,-424 -1228,-424 -1230.5,-420 -1233,-424 -1236,-424 z”
                                  Stretch=”Fill” Fill=”Beige”  StrokeThickness=”2″/>
<StackPanel Margin=”5,5,5,18″>
<StackPanel Orientation=”Horizontal”>
                                   <TextBlock Text=” 值:” FontWeight=”Bold” FontSize=”11″/>
                                   <TextBlock Text=”{Binding Path=DataItem.Value}” FontWeight=”Bold” FontSize=”11″/>
<TextBlock Text=” “/>
                       </StackPanel>

<StackPanel Orientation=”Horizontal”>
                                   <TextBlock Text=” 时间:” FontWeight=”Bold” FontSize=”11″/>
                                   <TextBlock Text=”{Binding Path=DataItem.Category}” FontWeight=”Bold” FontSize=”11″/>                                 
<TextBlock Text=” “/>
                       </StackPanel>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </telerik:RadCartesianChart.TooltipTemplate>

//标签模板

<telerik:LineSeries ShowLabels=”True” PointTemplate=”{StaticResource PointTemplate1}”>
    <telerik:LineSeries.LabelDefinitions>
<telerik:ChartSeriesLabelDefinition>
         <telerik:ChartSeriesLabelDefinition.Template>
             <DataTemplate>
                <TextBlock Text=”MyTest”/>
             </DataTemplate>
         </telerik:ChartSeriesLabelDefinition.Template>
     </telerik:ChartSeriesLabelDefinition>
</telerik:LineSeries.LabelDefinitions>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”10″ Value=”10″/>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”20″ Value=”20″/>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”30″ Value=”30″/>
    </telerik:LineSeries>

代码:

                #region //标签模板,显示标签                
                line.LabelDefinitions.Add(new ChartSeriesLabelDefinition { Template = (DataTemplate)XamlReader.Load(CreateItemTemplate()) });
                #endregion

//点模板、标签模板、提示信息

<telerik:RadCartesianChart Margin=”10,10,8,0″ >    
<telerik:RadCartesianChart.Resources>
               <DataTemplate x:Key=”PointTemplate1″>
                   <Ellipse x:Name=”ellipse” Height=”6″ Width=”6″ Fill=”Black”/>
               </DataTemplate>
           </telerik:RadCartesianChart.Resources>
    <telerik:RadCartesianChart.Behaviors>
    <telerik:ChartTooltipBehavior Placement=”Top” VerticalOffset=”20″/>
</telerik:RadCartesianChart.Behaviors>
<telerik:RadCartesianChart.TooltipTemplate>
                <DataTemplate>
                    <Grid>
                        <Path Data=”M-1236,-441 L-1180,-441 -1180,-424 -1228,-424 -1230.5,-420 -1233,-424 -1236,-424 z”
                                  Stretch=”Fill” Fill=”Beige” Stroke=”Gray” StrokeThickness=”2″/>
<TextBlock Text=”Profit for ” FontWeight=”Bold” FontSize=”11″/>
<TextBlock Text=”{Binding Path=DataItem.Value}” FontWeight=”Bold” FontSize=”11″/>
                    </Grid>
                </DataTemplate>
            </telerik:RadCartesianChart.TooltipTemplate>
    <telerik:RadCartesianChart.HorizontalAxis>
    <telerik:CategoricalAxis/>
    </telerik:RadCartesianChart.HorizontalAxis>
    <telerik:RadCartesianChart.VerticalAxis>
    <telerik:LogarithmicAxis LabelOffset=”0″ LogarithmBase=”10″ LastLabelVisibility=”Visible” LineThickness=”1″ MajorTickOffset=”0″ TickThickness=”1″ ZIndex=”0″ ShowLabels=”False”/>
    </telerik:RadCartesianChart.VerticalAxis>
    <telerik:LineSeries ShowLabels=”True” PointTemplate=”{StaticResource PointTemplate1}”>
    <telerik:LineSeries.LabelDefinitions>
<telerik:ChartSeriesLabelDefinition>
         <telerik:ChartSeriesLabelDefinition.Template>
             <DataTemplate>
                <TextBlock Text=”MyTest”/>
             </DataTemplate>
         </telerik:ChartSeriesLabelDefinition.Template>
     </telerik:ChartSeriesLabelDefinition>
</telerik:LineSeries.LabelDefinitions>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”10″ Value=”10″/>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”20″ Value=”20″/>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”30″ Value=”30″/>
    </telerik:LineSeries>
<telerik:LineSeries ShowLabels=”True”>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”10″ Value=”50″/>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”1111″ Value=”30″/>
    <telerik:CategoricalDataPoint Category=”{x:Null}” IsSelected=”False” Label=”30″ Value=”30″/>
    </telerik:LineSeries>
    </telerik:RadCartesianChart>

//代码添加模板

                var pointTemplate = chartObject.Resources[“PointTemplate1”] as DataTemplate; //获取xaml中的模板对象

                #region //标签模板,显示标签                
                line.LabelDefinitions.Add(new ChartSeriesLabelDefinition { Template = (DataTemplate)XamlReader.Load(CreateItemTemplate(c.ToString())) });
                #endregion

 private string CreateItemTemplate(string strColor)
        {

            string strText = string.Format(“<TextBlock Text=\”{0}\” Foreground=\”{1}\” Margin=\”0,0,0,0\”/>”, “{Binding Label}”, strColor);
            StringBuilder template = new StringBuilder();
            template.Append(“<DataTemplate “);
            template.Append(“xmlns=’http://schemas.microsoft.com/winfx/”);
            template.Append(“2006/xaml/presentation’ “);
            template.Append(“xmlns:x=’http://schemas.microsoft.com/winfx/2006/xaml’>”);

            //template.Append(“<Grid>”);
            //template.Append(“<Path Data=\”M-1236,-441 L-1180,-441 -1180,-424 -1228,-424 -1230.5,-420 -1233,-424 -1236,-424 z\” Stretch=\”Fill\” Fill=\”Beige\” Stroke=\”Gray\” StrokeThickness=\”2\”/>”);
            //template.Append(“<TextBlock Text=\”{Binding Label}\” Foreground=\”{Binding m_listColors}\” Margin=\”0,0,0,0\”/>”);
            //template.Append(“</Grid>”);

            template.Append(strText);

            template.Append(“</DataTemplate>”);
            return template.ToString();
        }

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/162012.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • vbs代码之“电脑系统崩溃”「建议收藏」

    vbs代码之“电脑系统崩溃”「建议收藏」熟练掌握vbs脚本,可以让你…我也不知道。具体操作:新建文本文档,将本段代码复制进入文本,保存;将后缀.txt改为.vbs即可。codeCreateObject(“SAPI.SpVoice”).Speak”你的电脑受到ddos木马攻击,系统严重瘫痪,电脑系统将在三秒后崩溃”setWshShell=WScript.CreateObject(“WScript.Shell”)WScript.Sleep2000CreateObject(“SAPI.SpVoice”).Speak”电脑系统已

    2022年5月27日
  • gateway网关详解_网关怎么设置才能上网

    gateway网关详解_网关怎么设置才能上网本文介绍了微服务中Gateway的使用,正在学习Gateway或者准备学习的大佬看过来哟

    2022年10月11日
  • 英语词汇表

    英语词汇表Aa(an)art.一(个、件……)abandonv.放弃,抛弃abilityn.能力;才能ablea.能够;有能力的abnormala.不正常的aboardprep.在(或上)船,飞机,火车等abolishv.废除abortionn.流产aboutad.大约;到处;四处prep.关于;

    2022年5月12日
  • 卷积神经网络和图像识别[通俗易懂]

    卷积神经网络和图像识别[通俗易懂]卷积神经网络与图像识别我们介绍了人工神经网络,以及它的训练和使用。我们用它来识别了手写数字,然而,这种结构的网络对于图像识别任务来说并不是很合适。本文将要介绍一种更适合图像、语音识别任务的神经网络结构——卷积神经网络(ConvolutionalNeuralNetwork,CNN)。说卷积神经网络是最重要的一种神经网络也不为过,它在最近几年大放异彩,几乎所有图像、语音识别领域的…

    2022年6月2日
  • java中clone的用法_java clone是浅拷贝吗

    java中clone的用法_java clone是浅拷贝吗一.Cloneable的用途Cloneable和Serializable一样都是标记型接口,它们内部都没有方法和属性,implementsCloneable表示该对象能被克隆,能使用Object.clone()方法。如果没有implementsCloneable的类调用Object.clone()方法就会抛出CloneNotSupportedException。二.克隆的分类(1)浅克隆(s

    2022年10月14日
  • 小米BL不解锁刷机「建议收藏」

    小米BL不解锁刷机「建议收藏」关于小米NOTE顶配近期解锁的问题中发现还有很多人不会用9008模式刷机,现出个简单教程方便米粉们救砖。硬件:小米NOTE顶配手机win10系统的电脑手机与电脑相连的数据线软件:老版本的miflash(版本号:2015.10.28。0)最新版本miflash最新解BL锁工具或者小米助手(用来装驱动)开发版6.17及以前的线刷包随便下一个一个你最终想刷的版本(推荐最新稳定版)…

    2022年4月30日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号