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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • iPhone 各机型屏幕尺寸

    iPhone 各机型屏幕尺寸iPhone各机型屏幕尺寸手机设备型号屏幕尺寸分辨率点数(pt)屏幕显示模式分辨率像素(px)屏幕比例iPhoneSE4.0吋320×568@2x640x113616:9iPhone6/6s/7/8/SE24.7吋375×667@2x750x133416:9iPhone6p/7p/8p5.5吋414×736@3x1242x220816:9iPhoneXR/116.1吋414×896@2x828x179219

    2022年5月14日
    130
  • 欧式距离、标准化欧式距离、马氏距离、余弦距离

    欧式距离、标准化欧式距离、马氏距离、余弦距离目录欧氏距离标准化欧氏距离马氏距离夹角余弦距离汉明距离曼哈顿(Manhattan)距离1.欧式距离欧式距离源自N维欧氏空间中两点x1,x2x1,x2x_1,x_2间的距离公式:d=∑i=1N(x1i−x2i)2‾‾‾‾‾‾‾‾‾‾√d=∑i=1N(x1i−x2i)2d=\sum_{i=1}^N\sqrt{(x_{1i}-x_{2i})^2}2.标准化…

    2022年6月19日
    20
  • endnote参考文献改为文字(参考文献endnote格式)

    最简单的,自动下载style:打开endnote—-edit—-outputstyles—-openstylemaneger—-在新打开的界面中点击中部的getmoreontheweb,此时自动连接endnote官网,在网页中部的搜索窗口输入目标杂志名称,点击search,然后在弹出的resultsfound下方点击搜索结果后方的download,下载文件,之…

    2022年4月16日
    254
  • 钩子函数是什么?(函数那个小钩子哪里调出来)

    什么是钩子函数?先来看一段百科:钩子函数是Windows消息处理机制的一部分,通过设置“钩子”,应用程序可以在系统级对所有消息、事件进行过滤,访问在正常情况下无法访问的消息。钩子的本质是一段用以处理系统消息的程序,通过系统调用,把它挂入系统。emmmm,认认真真读三遍。get关键词,在系统级对所有消息进行过滤,这是什么意思呢?是说钩子函数是在一个事件触发的时候,在系统级捕获到了他,然后做一…

    2022年4月12日
    50
  • Response.Write具体介绍

    Response.Write具体介绍

    2021年12月6日
    38
  • CSS控制文本超出指定宽度显示省略号和文本不换行

    一般的文字截断(适用于内联与块):.text-overflow{display:block;/*内联对象需加*/width:31em;/*何问起hovertree.com*/word

    2021年12月23日
    46

发表回复

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

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