Pre loader

Tag: Legend

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1 vote
1k views

Hi!

As described in Deleting DataSeries Memory, deleting a series with all its data can be done by calling .delete() on the renderable (example 3) .

If i do just that, the legend doesn’t reflect that. Is there something else to do?

See repro based on Chart Legends Example – just added a 2s timeout after initialization that deletes the renderableSeries of data3. Removes the series from the chart but not from the legend.

1 vote
0 answers
5k views

Hello.

In my project, I am trying to display four SciChartSurfaces with a single legend. Furthermore, I want the Visibility changes of each series in the legend checkbox to be reflected in all SciChartSurfaces.

The following code achieves this, but I am not confident that it is the best solution. Is there a more Smart way to accomplish this?

MainWindow.xaml

<Window x:Class="SurveyFleetVisionChartLegend.MainWindow"
    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:local="clr-namespace:SurveyFleetVisionChartLegend"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
    Title="MainWindow"
    Width="800"
    Height="550"
    d:DataContext="{d:DesignInstance {x:Type local:MainWindowViewModel}}"
    mc:Ignorable="d">

<Window.DataContext>
    <local:MainWindowViewModel />
</Window.DataContext>
<Window.Resources>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</Window.Resources>
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition Height="auto" />
    </Grid.RowDefinitions>

    <s:SciChartSurface Grid.Row="0"
                       Margin="5"
                       VerticalAlignment="Stretch"
                       Background="WhiteSmoke"
                       CacheMode="{x:Null}"
                       ChartTitle="SciChartSurface1"
                       RenderableSeries="{s:SeriesBinding GraphSeriess1.Value,
                                                          Mode=OneWay,
                                                          UpdateSourceTrigger=PropertyChanged}">

        <s:SciChartSurface.XAxis>
            <s:NumericAxis DrawLabels="False"
                           GrowBy="0.1, 0.1" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis HorizontalContentAlignment="Left"
                           DrawLabels="False"
                           GrowBy="0.1, 0.1" />
        </s:SciChartSurface.YAxis>
        <s:SciChartSurface.ChartModifier>
            <s:ModifierGroup>
                <s:LegendModifier x:Name="TrendChartLegendModifier"
                                  ShowLegend="False"
                                  Visibility="Visible" />
            </s:ModifierGroup>
        </s:SciChartSurface.ChartModifier>
    </s:SciChartSurface>
    <s:SciChartSurface Grid.Row="1"
                       Margin="5"
                       VerticalAlignment="Stretch"
                       Background="WhiteSmoke"
                       ChartTitle="SciChartSurface2"
                       RenderableSeries="{s:SeriesBinding GraphSeriess2.Value,
                                                          UpdateSourceTrigger=PropertyChanged}">

        <s:SciChartSurface.XAxis>
            <s:NumericAxis DrawLabels="False"
                           GrowBy="0.1, 0.1" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis HorizontalContentAlignment="Left"
                           DrawLabels="False"
                           GrowBy="0.1, 0.1" />
        </s:SciChartSurface.YAxis>
    </s:SciChartSurface>
    <s:SciChartSurface Grid.Row="2"
                       Margin="5"
                       VerticalAlignment="Stretch"
                       Background="WhiteSmoke"
                       ChartTitle="SciChartSurface3"
                       RenderableSeries="{s:SeriesBinding GraphSeriess3.Value}">

        <s:SciChartSurface.XAxis>
            <s:NumericAxis DrawLabels="False"
                           GrowBy="0.1, 0.1" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis HorizontalContentAlignment="Left"
                           DrawLabels="False"
                           GrowBy="0.1, 0.1" />
        </s:SciChartSurface.YAxis>
    </s:SciChartSurface>
    <s:SciChartSurface Grid.Row="3"
                       Margin="5"
                       VerticalAlignment="Stretch"
                       Background="WhiteSmoke"
                       ChartTitle="SciChartSurface4"
                       RenderableSeries="{s:SeriesBinding GraphSeriess4.Value}">

        <s:SciChartSurface.XAxis>
            <s:NumericAxis DrawLabels="False"
                           GrowBy="0.1, 0.1"
                           VisibleRangeLimitMode="MinMax" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis HorizontalContentAlignment="Left"
                           DrawLabels="False"
                           GrowBy="0.1, 0.1" />
        </s:SciChartSurface.YAxis>
    </s:SciChartSurface>

        <!--  Display the legend for Chart1.  -->
        <!--  Synchronization of Visiblity of each series of each SciChartSurface is performed on the ViwModel side.  -->
        <s:SciChartLegend Grid.Row="4"
                          Grid.Column="1"
                          HorizontalAlignment="Stretch"
                          HorizontalContentAlignment="Center"
                          LegendData="{Binding LegendData,
                                               ElementName=TrendChartLegendModifier}"
                          Orientation="Vertical"
                          ScrollViewer.VerticalScrollBarVisibility="Auto"
                          ShowVisibilityCheckboxes="True" />
    </Grid>
</Window>

MainWindowViewModel.cs

    using Reactive.Bindings;
using Reactive.Bindings.Extensions;
using SciChart.Charting.Common.Extensions;
using SciChart.Charting.Model.ChartData;
using SciChart.Charting.Model.ChartSeries;
using SciChart.Charting.Model.DataSeries;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using System.Xml.Linq;

namespace SurveyFleetVisionChartLegend
{
    public class MainWindowViewModel
    {
        public ReactivePropertySlim<List<IRenderableSeriesViewModel>> GraphSeriess1 { get; set; } = new ReactivePropertySlim<List<IRenderableSeriesViewModel>>();
        public ReactivePropertySlim<List<IRenderableSeriesViewModel>> GraphSeriess2 { get; set; } = new ReactivePropertySlim<List<IRenderableSeriesViewModel>>();
        public ReactivePropertySlim<List<IRenderableSeriesViewModel>> GraphSeriess3 { get; set; } = new ReactivePropertySlim<List<IRenderableSeriesViewModel>>();
        public ReactivePropertySlim<List<IRenderableSeriesViewModel>> GraphSeriess4 { get; set; } = new ReactivePropertySlim<List<IRenderableSeriesViewModel>>();

        public ReactiveCommand RecreateCommand { get; set; }

        private List<string> chartNames;
        private Dictionary<string, bool> seriesVisibles { get; set; }
        private Random random = new Random();

        public MainWindowViewModel()
        {
            chartNames = new List<string>() { "Chart1", "Chart2", "Chart3" };
            seriesVisibles = new Dictionary<string, bool>();
            chartNames.ForEach(a => seriesVisibles.Add(a, true));

            GraphSeriess1.Value = createGraphSeriess("Chart");
            GraphSeriess2.Value = createGraphSeriess("Chart");
            GraphSeriess3.Value = createGraphSeriess("Chart");
            GraphSeriess4.Value = createGraphSeriess("Chart");

            // If the legend changes the Visibility of each series in GraphSeriess1,
            // Vary the Visibility of each series in other GraphSeriess.
            GraphSeriess1.Subscribe(s=> {
                if(s != null)
                    s.ForEach(a =>
                    {
                        a.ObserveProperty(b => b.IsVisible).Subscribe(_ =>
                        {
                            if (GraphSeriess2.Value != null)
                                GraphSeriess2.Value.First(c => c.DataSeries.SeriesName == a.DataSeries.SeriesName).IsVisible = a.IsVisible;
                            if (GraphSeriess3.Value != null)
                                GraphSeriess3.Value.First(c => c.DataSeries.SeriesName == a.DataSeries.SeriesName).IsVisible = a.IsVisible;
                            if (GraphSeriess4.Value != null)
                                GraphSeriess4.Value.First(c => c.DataSeries.SeriesName == a.DataSeries.SeriesName).IsVisible = a.IsVisible;
                            seriesVisibles[a.DataSeries.SeriesName] = a.IsVisible;
                        });
                    });
            });
        }

        private List<IRenderableSeriesViewModel> createGraphSeriess(string name)
        {
            return chartNames.Select((x,a) => createGraphSeries(x, a)).ToList();
        }

        private IRenderableSeriesViewModel createGraphSeries(string name, int index)
        {
            var dataSeries = new XyDataSeries<double>() { SeriesName = name};

            for (var i = 0; i < 5; i++)
            {
                dataSeries.Append(i, random.Next(100));
            }

            return new LineRenderableSeriesViewModel()
            {
                DataSeries = dataSeries,
                IsVisible = seriesVisibles[dataSeries.SeriesName],
                Stroke = Color.FromRgb((byte)(index * 200), (byte)(index * 100), (byte)(index * 100))
            };
        }
    }
}

That is all. Best regards.

1 vote
2k views

The SciChart Legend and Cursor Tooltip (Showed only Y axis value) are not display after changing the graph layout.
I need to show the graph legend and Tooltip for all the Y axis.

The chart should also show the x axis value and y axis value on the Tooltip for more clarity.

Before changing the layout the legend was showing the five series vertically one below the other. But i need to show the five legends in horizontally (One after the another).

I have added the chart definition code. The data is added though Ajax call and code for that ajax call is not added.

I have attached the image for your reference.

I have attached the zip file with the html file.

1 vote
2k views

Hello,

I am trying to make a legend for a graph with some complex data.

Here is an example of how my data is structured:

  • Data Set #1
    • Series A
    • Series B
    • Series C
  • Data Set #2
    • Series A
    • Series B
    • Series C
  • Data Set #3
    • Series A
    • Series B
    • Series C

By default, SciChartLegend will display 9 entries in the above example, one for every series. However, with many datasets, and more series per dataset, this quickly becomes extremely cumbersome.

What I’d like to do is show 6 items in the legend: a checkbox for each Data Set, and a checkbox for each Series Type.

If the user clicks the Data Set #1 check box => Data Set #1 Series A, Data Set #1 Series B, and Data Set #1 Series C are all shown/hidden.

If the user clicks the Series A check box => Data Set #1 Series A, Data Set #2 Series A, and Data Set #3 Series A are all shown/hidden.

This does not seem to cooperate with the native SciChartLegend, which views all the Data Series as a single flat list. My data is in more of a tree structure.

Do you have any recommendations on how to proceed? I think I will need to make a new UserControl derived from ChartDataObjectBase to replace the SciChartLegend control.

Any help greatly appreciated.

Thank you,

Kurt

1 vote
2k views

Hello,

I am trying to make a custom user control for the legend. I’d like to have a file, like MyLegend.xaml, along with a MyLegendViewModel.cs, which can be referenced in a larger view containing the associated surfaces, MyBigChartView.xaml / MyBigChartViewModel.cs. I can’t find any examples of this. Everything I’ve seen is about declaring an ItemTemplate or DataTemplate…

Can anyone point me towards a very simple example of using a custom xaml control to define the legend and then using that in another large xaml view?

0 votes
3k views

Hello,

I need to modify iOS SCIChart tooltip behavior. I’ve been trying to follow the example at “https://www.scichart.com/example/ios-using-tooltip-modifier/“.

Using SCIChart 4.4.0.5778 I’ve noticed some class methods and parameters don’t match, but I’ve figured out most of them I think. However, I cannot determine the method to use that is equivalent to:
“override func internalUpdate(with seriesInfo: SCIXySeriesInfo)” when subclassing “SCIXySeriesTooltip”.

I did take look at the example code that is packed with the SDK. I got compiler errors in the tooltip code in the file “TooltipCustomizationChartView” when I included the framework bundled with the SDK.

Thank you for the assistance.

  • C Bolton asked 2 years ago
  • last active 2 years ago
1 vote
2k views

I need to implement custom html legend instead of built-in options.
To hide built-in rollover I’m using series config:

    this.series.rolloverModifierProps.width = 0;
    this.series.rolloverModifierProps.height = 0;
    this.series.rolloverModifierProps.markerColor = "rgba(255, 255, 255, 0)";

I can’t set

 rolloverModifierProps.showRollover = false; 

because in that case rolloverModifierProps.tooltipDataTemplate handler is not firing.
My handler looks like

rolloverModifierProps.tooltipDataTemplate = (seriesInfo: SeriesInfo): string[] => {
            const ohlcInfo = seriesInfo as OhlcSeriesInfo;
            myOwnHandlerToPassDataToHtml({ high: ohlcInfo.highValue, low: ohlcInfo.lowValue, open: ohlcInfo.openValue, close: ohlcInfo.closeValue });
            return [];
        };

I’am wondering if there is any other way to hide rollover marker but keep tooltipDataTemplate handler firing?

0 votes
3k views

Would there be a straight-forward way to put the SciChart Legend from a LegendModifier inside a WPF Expander control, to show or hide the legend?

Would ScichartSurface need to be subclassed in order to accomplish this visual?

<s:LegendModifier ShowLegend="{Binding ShowLegend}" 
    Orientation="Vertical" 
    VerticalAlignment="Center" 
    HorizontalAlignment="Left"
    LegendPlacement ="Right"/>
0 votes
6k views

I was looking over Tutorial 07 – Tooltips and Legends and the Chart Legends API demo, and noticed that the checkboxes and legend font had some styling applied. But, when I implement a legend on my own it uses the default font (or whatever global font style I used) and the default HTML checkbox styling. I was wondering if you had modified the styling using an outside CSS file, if there is an API endpoint for modifying the styling of the legend, or if this is possibly a bug. I did see that there was an applyTheme() method available, but I thought that it might not apply to this situation. I also tried to look through the example code provided for the Chart API Demo, but I couldn’t find anything that pointed one way or the other.

I have attached screenshots of what the legend looks like in the two examples, as well as a screenshot of what the legend looks like when I implement it on my own. I have also included a zip file with the demo application I created.

Thanks,
Drew

0 votes
4k views

I have followed the example at: https://www.scichart.com/documentation/ios/current/legend-modifier.html for creating a legend with a custom item.

The initial problem I am trying to solve is that the default legend has a black background but my chart is white. If I set the background of the legend to white, this is a problem because the series text is white, so you can’t read it any longer. Therefore in order to have a legend with a white background to match my chart, I needed custom legend items to be able to set the series text color to black.

I have created my ChartLegendCell.swift file based on the example and my ChartLegendCell.xib which has a UIView and a UILabel. I incorporate these into my code exactly as in the example. However the legend does not show up upon render. I added a breakpoint inside the ChartLegendCell.swift class and I see bindSeriesInfo method called twice per series. What I noticed is that the first time it is called, printing out self.bounds shows (0,0,230,35) which is correct, but the second time it is called self.bounds is (0,0,0,0).

Is there more code which needs to be added in the ChartLegendCell.swift to make sure the width and height aren’t 0?

  • Brad Taber asked 4 years ago
  • last active 4 years ago
0 votes
9k views

Hello,

Would it be possible to receive some information on how to take the legend outside of the chart surface area? We are having an issue when the user selects more axis’ to be shown in the chart. The chart then shrinks horizontally making the legend difficult to access for removing the axis’.

A quick how to with some code example would be highly appreciated. To further highlight, this is Xamarin.iOS project we are talking about.

Thank you and have a nice day.

Best Regards

0 votes
0 answers
4k views

I looked at this thread but it doesn’t help me.

https://www.scichart.com/questions/wpf/dynamically-clearing-legends-from-the-legendmodifier

I have problem where an item is still shown in the legend even though no series is currently displayed on the chart.

For example.

  1. The SciChart RenderableSeries dependency property of my chart surface is a property in my view model named “Measurements”, I.e. ObservableCollection of IRenderableSeries.
  2. An ObservableCollection of another class named “ExampleList” is also in my view model.
  3. In a data grid elsewhere in the application a user selects 3 rows. The “ExampleList” collection now has 3 items in it. Part of the setter for that property is to call “Measurements.Clear()” and then follow that with a “Measurement.Add(newseries)” 3 times.
  4. When a user selects an individual item in the data grid that contains no points that could be displayed on the chart I only call “Measurements.Clear()” and I don’t subsequently called “Measurements.Add()”

My issue is that the legend never clears and shows the last series that was selected before selecting this new item which shouldn’t even be in the chart. It’s behaving as if the chart were not cleared; although I have verified that I definitely am calling “Measurements.Clear()”

0 votes
0 answers
7k views

Hello.

I have previously asked a question regarding Android and Xamarin (https://www.scichart.com/questions/android/legend-outside-of-chart-area).

Now, I have the same question, but for iOS. Do you have any examples available for taking chart legend outside of chart area on iOS?

Thank you and have a nice day!

Regards,
Paul.

0 votes
8k views

I’m trying to add annotations on a chart but they are rendering above my legend.

Initially (similar to most of the demo code I’ve seen), I setup my modifiers, then created my series and animated them in — then added my annotations (adding to annotationGroup). This created a timeline of blank chart surface with legend (good so far), annotations popping in before the chart series animated in (weird / not good) and on TOP of the legend (really bad), then the animation of the series after that.

I’ve tried about everything I can think of and the best I’ve been able to do is use a completion block of the animation rendering the series — and moved my chart modifiers (and legend) into that completion block. If I put the annotations in the completion block, they will render after the chart modifier and I have the same problem (even if placed after the chart modifiers). I have to set the annotations before the animation, and then the chart modifier in the completion block will work and the legend will be above the . Of course, this is a bit odd too — as first my annotations pop up by themselves on the blank surface, followed by my series animating in, then at the end of the 2 second animation, the legend just pops in.

I really would like my legend to be rendered first on the blank surface and the annotations and chart series to animate in together under my legend. I’m gathering that’s unlikely (at least the animation part) — but is there anyway I can place my legend first and still have the annotations go under it? It feels like the layers should be: modifiers > annotations > rendered series. I also I’ve read this order before in some WPF docs I believe, but doesn’t seem to be respected on iOS?

UPDATE: My current work around isn’t sufficient because I really need access to the renderable series to create the annotations which means I really can’t defer my chart modifiers (i.e. legend) until after the annotations. Additionally, if I need to update (remove / re-add) an annotation due to a series being deactivated in the legend, now my annotations are on top of the legend again.

0 votes
5k views

I am placing annotations at the top of every bar in a stacked bar graph (and a standard bar graph on another screen) showing the total of all the stacked bars by iterating through my data, generating the sum, and placing it at the correct x,y (an incredibly manual process that seems like there should be much easier to do but I found no other way to do it – if there is a better way, I would love to hear it, but that’s a secondary issue and not my current problem).

I also have a legend where the user can select / deselect series.

When the user selects/deselects a series from the legend, I need to hide all my annotations and then recreate them because the sums of the stacked bars has changed (or if no bars are showing, remove my annotation completely). My assumption is I could reiterate through my data and check series to see if they are visible (isVisible) and recalculate the sums and recreate the annotations (another very manual process but I can probably work it out).

My primary problem is I see no way for me to intercept that this legend event occurred. The series get hidden internally and I never have a chance to do anything with the annotations. It seems like this may be doable on other platforms but I’m at a loss on iOS. There is no delegate / block event handler / etc.

Any thoughts?

0 votes
7k views

Hello,
I managed to implement a chart legend with a custom datasource (using just a SCIChartLegend object as a subview, not SCILegendModifier). However, I am unable to place the legend at specified position, it always snaps to upper-left corner of the screen. When creating a SCIChartLegend instance using the initializer that takes a Rect as a parameter, but not supplying a custom datasource, it draws correctly according to offsets specified by the supplied rect’s X and Y. It does respond to changes in the legendPosition property, but it still doesn’t allow to draw the view with any margins (which is what I’m actually trying to achieve).

1 vote
6k views

We’d like to customize the look of our legends. We have 4 legends displaying different data, but right now the only thing we can change is the Theme. Is there any way to customize the legend items, like add some icons, change the point marker shape and size, change the check box icon etc…

P.S.: I’m not a trial user. We have an iOS, Android and WPF licenses purchased.

Project info:
Xamarin.iOS
SciChart.iOS 2.2.2.854

1 vote
8k views

We’re trying to make multiple legends on the screen, for example, 1 for the left axis and its data series, 1 for the right axis and its data series. I can see it’s possible in the WPF documentation, but in the iOS documentation it says “Coming soon!”. Do we need to wait for a future release of the Xamarin.iOS library or is it possible somehow now?

By the way, I’m not a trial user. We’ve just purchased a license today.

Thanks,
Lazar Nikolov

1 vote
0 answers
5k views

I am developing a WPF application with multiple series on a single surface.
I would like to have a legend displaying for each series a value based on user’s choice (e.g. first point, last point, average, min, max and so on).

How can i achieve this?

Thank you

0 votes
7k views

Hi All
By default legends are being draw on scichart surface. I want to draw them outside the scichart surface because as the number of render-able series increase legends hides them. Please give me suggestion how do i do it ?

0 votes
9k views

I am using the LegendModifier to bind my RenderableSeries to my legend.

In my legends Datatemplate, I have a checkbox and a colour picker.

I notice the LegendData object is of ChartDataObjectBase type. I would like to group my data in my legend (eg, with a label), rather than just display the list.

Is this possible, similar to the images attached ?

0 votes
7k views

I have issue with legend on high resolutions screens. Checkboxes and text is very small and hard to read. I couldn’t find any solution to change text size or provide my own template with text size for legend in Android SciChart.

I want to change legend text size depends on screen like it is in Android by declaring size in dimens.xml.

I do that for Axis labels but I don’t know how do the same for text in legend.

Does anyone know how to achieve this?

  • Marcin K asked 6 years ago
  • last active 6 years ago
0 votes
0 answers
12k views

iOS 11.2 with xCode 9.2

I have a chart with two data series and a legend. The chart lives in a view controller that is embedded in a navigation controller. I configured the navigation bar to hide itself when the phone it tilted into landscape mode: navigationController.hidesBarsWhenVerticallyCompact = true

When I tilt the phone the navigation bar is hidden as expected. However when I tap on the chart legend to turn off one of the data series I see the navigation bar re-appears. Screen shots attached.

0 votes
10k views

i currently place my custom (templated) legend inside the Scichartsurface (via xaml).

How can I offer the feature to drag the legend with the mouse to any location on the surface? Please note that I also use mouse movements and clicks for several chart modifiers so most likely I would have to check whether the mouse is hovering over the legend when a left mouse click event is raised?

Could you please get me started with some ideas or thoughts as I am not sure how to approach this issue.

Thanks

  • bbmat asked 7 years ago
  • last active 7 years ago
1 vote
9k views

Visual Studio 2015

This isn’t a critical issue since it is handled but since it didn’t do this for the old version I thought I’d bring it to your attention. Awesome product BTW.

I just upgraded my .NET 4.0 SciChart 2D application from SciChart version 4.1.1.8645 to 4.2.1.9358.
Now I get the following (handled) exception message in the output window if I use a legend with my chart:

Exception:
System.Windows.Data Warning: 40 : BindingExpression path error: ‘ScrollViewer’ property not found on ‘object’ ”LegendPlaceholder’ (Name=”)’. BindingExpression:Path=ScrollViewer.HorizontalScrollBarVisibility; DataItem=’LegendPlaceholder’ (Name=”); target element is ‘SciChartLegend’ (Name=”); target property is ‘HorizontalScrollBarVisibility’ (type ‘ScrollBarVisibility’)

This XAML the triggers the exception (comment it out and exception goes away):

                        <s:SciChartSurface.ChartModifier>
                            <s:ModifierGroup>
                                <s:LegendModifier ShowLegend="True" />
                            </s:ModifierGroup>
                        </s:SciChartSurface.ChartModifier>

How to reproduce:
– Take the EEG sample with the latest SciChart version (4.2.1.9358)
– Change the target framework to .NET 4.0
– Change the SciChart references to use the SciChart 4.2, net40 DLLs.

I made a test solution for the following combinations:
.NET 4.5 with SciChart 4.2 works
.NET 4.0 with SciChart 4.2 throws exception
.NET 4.0 with SciChart 4.1 works

0 votes
11k views

I followed this post http://support.scichart.com/index.php?/Knowledgebase/Article/View/17244/39/tutorial—custom-legend-with-color-picker-and-custom-point-markers for creating a custom Chart Legend and it worked great. One feature of it that I really liked was the checkbox behavior: CheckedChangeZoomExtentsBehaviour.EnableZoomExtentsOnChecked=”True” which zooms the chart to extents everytime you show or hide a series.

This checkbox behavior breaks when I move the Legend outside of the chart, which I accomplished by following this post: https://www.scichart.com/questions/question/moving-legend-outside-sci-chart-plots

How can I keep this checkbox behavior when moving the Legend outside of the Chart area?

Note: if I set ShowLegend=”True” in my s:LegendModifie> tag, the behavior properly works with the legend outside the Chart area, but now I have duplicate legends both inside and outside my chart area with this setting set.

<!-- LEGEND_ITEM_TEMPLATE -->
<DataTemplate x:Key="LegendItemTemplate" DataType="s:SeriesInfo">
            <!-- DataContext is of type SeriesInfo -->
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <!-- Visibility checkbox, bound to SeriesInfo.RenderableSeries.IsVisible -->
                <CheckBox Margin="5,0,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    behaviors:CheckedChangeZoomExtentsBehaviour.EnableZoomExtentsOnChecked="True"
                    Foreground="{StaticResource LegendTextBrush}"
                    IsChecked="{Binding RenderableSeries.IsVisible, Mode=TwoWay}"
                    Visibility="{Binding LegendData.ShowVisibilityCheckboxes, RelativeSource={RelativeSource AncestorType=s:SciChartLegend}, Converter={StaticResource BooleanToVisibilityConverter}}" />

                <s:PointMarker Grid.Column="1" Margin="5,0,0,0" Width="40" Height="10" VerticalAlignment="Center" HorizontalAlignment="Center"
                    DataContext="{Binding RenderableSeries}"
                    DeferredContent="{Binding LegendMarkerTemplate}"
                    Visibility="{Binding ShowSeriesMarkers, RelativeSource={RelativeSource AncestorType=s:SciChartLegend}, Converter={StaticResource BooleanToVisibilityConverter}}" />

                <!-- Series Name, bound to SeriesInfo.SeriesName -->
                <TextBlock Margin="5,0,5,0"
            Grid.Column="2"
            HorizontalAlignment="Left"
            Foreground="{StaticResource LegendTextBrush}"
            Text="{Binding SeriesName}" />
            </Grid>
        </DataTemplate>

<!-- LEGEND MODIFIER -->
    <s:LegendModifier x:Name="ChartLegend" ShowLegend="True" GetLegendDataFor="AllSeries" LegendItemTemplate="{StaticResource LegendItemTemplate}" ShowVisibilityCheckboxes="True"   />

<!-- MY LEGEND CONTROL ELSEWHERE ON THE PAGE -->
<s:SciChartLegend x:Name="legendControl" DockPanel.Dock="Top"
                                       Orientation="Horizontal" Margin="10"


                                       ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                       ScrollViewer.VerticalScrollBarVisibility="Auto"
                                       LegendData="{Binding LegendData, ElementName=ChartLegend, Mode=OneWay}"
                                       ShowVisibilityCheckboxes="True" />           
0 votes
17k views

Hello,
I would like to allow user click on Legend and highlight the corresponding Series on the chart but I don’t know if this feature is supported or not.

I tried to add mouse events to the Legend Modified but it seems like mouse events are not triggered

This is the simple code that I am using

<s:LegendModifier x:Name="chlLegend" ShowLegend="True" LegendPlacement="Top" Orientation="Horizontal" MouseDown="chlLegend_MouseDown" ScrollViewer.HorizontalScrollBarVisibility="Auto" />

Before investigating more I would like to ask you if you have any hints which is the correct way to implement this behavior.
Is the LegendModifier suitable for this or should I override instead the Legend Control Template?

Thank you in advance for the support

1 vote
12k views

I am trying to change the background color to match the background of the SciChartSurface but it just doesn’t want to change colors. I have a property bound to enable and disable the legend and that works fine. I tried doing the same for the “Background” property for SciChartLegend but nothing works. Even hard coding a brush doesn’t work. What am I missing?

I am using SciChart v3.42.0.6778

SciChartSurface instantiation in XAML. I am using the BrightSpark default theme.

<s:SciChartSurface Name="SciChartSurface"
Grid.Row="0"
Background="{Binding BackgroundColor, Converter={StaticResource ColorToSolidColorBrushConverter}}"
ChartTitle="{Binding GraphTitle}"
SeriesSource="{Binding GraphRenderModels}"
s:ThemeManager.Theme="BrightSpark">

Modifiers

<s:SciChartSurface.ChartModifier>
<s:ModifierGroup>
    <s:RubberBandXyZoomModifier IsAnimated="True"
                                IsEnabled="True"
                                IsXAxisOnly="False"
                                RubberBandFill="#99AAAAAA"
                                ZoomExtentsY="False" />
    <s:ZoomPanModifier ExecuteOn="MouseMiddleButton" IsEnabled="True" />
    <s:ZoomExtentsModifier ExecuteOn="MouseDoubleClick"
                           IsEnabled="True"
                           XyDirection="XDirection" />
    <s:MouseWheelZoomModifier IsEnabled="True" XyDirection="YDirection" />
    <s:YAxisDragModifier AxisId="LeftAxis" />
    <s:YAxisDragModifier AxisId="RightAxis" />
    <s:XAxisDragModifier ClipModeX="None" />
    <s:CursorModifier Name="CursorModifier" IsEnabled="{Binding ShowCursors, Mode=TwoWay}">
        <s:CursorModifier.LineOverlayStyle>
            <Style TargetType="Line">
                <Setter Property="Stroke" Value="LightGray" />
            </Style>
        </s:CursorModifier.LineOverlayStyle>
    </s:CursorModifier>
    <s:LegendModifier Margin="6"
                      GetLegendDataFor="AllSeries"
                      LegendPlacement="Inside"
                      Orientation="Horizontal"
                      ShowLegend="{Binding ShowLegend}"
                      ShowVisibilityCheckboxes="False" />
</s:ModifierGroup>

</s:SciChartSurface.ChartModifier>

When I attempt to change the background, I use the following:

<s:LegendModifier Margin="6"
GetLegendDataFor="AllSeries"
LegendPlacement="Inside"
Orientation="Horizontal"
    Background="{Binding BackgroundColor, Converter={StaticResource ColorToSolidColorBrushConverter}}"
ShowLegend="{Binding ShowLegend}"
ShowVisibilityCheckboxes="False" />

Which doesn’t work, though other color bindings in XAML work fine. If I change the color directly, say Background=”Red” or Background=”#FF0000″ It does not change either.

  • Alex Helms asked 9 years ago
  • last active 9 years ago
0 votes
13k views

FAQ: How to create a custom legend with TextFormatting for the FastHeatmapRenderableSeries? The provided legend in SciChart v3.4 does not allow text formatting.

1 vote
9k views

I’ve created a view with approximately 50 series, each containing ~200 datapoints.

I have noticed that rendering this with the legend showing, has a significant performance impact. I would expect the legend to have a cost, but I’m seing a big change in render time (the chart refreshes when the user checks a checkbox, so the performance has to be good).

I’ve added the legend using the following standard (I believe) xaml:

s:LegendModifier x:Name=”legendModifier”
IsEnabled=”True”
ShowLegend=”True”
Orientation=”Vertical”
Margin=”5″
LegendPlacement=”Inside”
GetLegendDataFor=”AllVisibleSeries”
ShowVisibilityCheckboxes=”False”
ShowSeriesMarkers=”True”
ScrollViewer.VerticalScrollBarVisibility=”Auto”/

When I set IsEnabled=”False” the performance improves significantly.

Does anybody have any hints to how performance can be improved?

Best regards

1 vote
10k views

Hi,

I created a custom point marker by deriving from CrossPointMarker and overwriting the DrawInternal function (when I derive from BasePointMaker the behaviour is the same):

   protected override void DrawInternal(IRenderContext2D context, double x, double y, IPen2D pen, IBrush2D brush)
    {
        double xOffset = Width * 0.5;
        double yOffset = Width * 0.5;
        context.DrawLine(pen, new Point(x - xOffset, y - yOffset), new Point(x + xOffset, y + yOffset));
        context.DrawLine(pen, new Point(x + xOffset, y - yOffset), new Point(x - xOffset, y + yOffset));
    }

When I set the PointMarker property of a FastLineRenderableSeries to an instance of this new Type I see the markers on the rendered line, but it does not show up in the legend (just a line with a small gap is drawn).
When I change the code to use a CrossPointMarker the marker is cross displayed on the line and in the legend.
What do I need to do to display the point marker in the legend as well?

Thanks in advance
Peter

0 votes
9k views

Hi All,
I am having an issue with legend as legend box is displays on chart and its also display series name on it but colors are not coming in legend only series name is displayed.
I also attached a IMAGE showing the above issue.

1 vote
17k views

Hi,

I have a chart showing data sets composed of multiple renderable series. Each data set is displayed using one FastLineRenderableSeries and three XyScatterRenderableSeries. All four series show in the legend for each data set, but I would only like to show the FastLineRenderableSeries in the legend for each data set. How can I do this?

I’ve seen the legendModifier.GetLegendDataFor property, but that can only be set to show options from this enum

public enum SourceMode
{
    AllSeries = 0,
    AllVisibleSeries = 1,
    SelectedSeries = 2,
    UnselectedSeries = 3,
}

which aren’t what I need. Some kind of flag on the renderable series saying whether they should be shown in the legend, or some way to specify the items source for the legend would be good.

Thanks!

1 vote
16k views

How can I only show Legends when the corresponding RenederableSeries is visible.
If the corresponding RenderableSeries is not visible then that Legend shouldn’t be shown.
Keep in mind my users will be able to hide and show RenderableSeries during runtime.

My xaml code is:

                                            <s:LegendModifier x:Name="legendModifier" ShowVisibilityCheckboxes="False" Orientation="Vertical" ShowLegend="{Binding ParentViewModel.ShowLegends, Mode=TwoWay}" Margin="10" />
                                        <s:SeriesSelectionModifier>
                                            <s:SeriesSelectionModifier.SelectedSeriesStyle>
                                                <Style TargetType="s:BaseRenderableSeries">
                                                    <Setter Property="StrokeThickness" Value="3"/>
                                                </Style>
                                            </s:SeriesSelectionModifier.SelectedSeriesStyle>
                                        </s:SeriesSelectionModifier>
1 vote
15k views

I have a chart with multiple dataseries, with each dataseries having annotations on top (like in the Trade Markers example). I have a legend which already shows or hides dataseries using a checkbox, but how can I make this checkbox also show or hide the annotations for that dataseries? Can I hook an event when this checkbox is triggered, or when the dataseries visibility changes?

1 vote
13k views

I need axes as described below. I can either modify your existing axis control or add my own in a canvas next to the SciChartSurface. So far I have been unable to modify your existing axis to fit my needs. A Y axis should look like this typical logarithmic axis (range 2 to 2000):

|-----------------  Resistivity ------------------|
2                                                2000

The specifications are
1.) Tick marks only at the end
2.) Title straddles the axis
3.) One axis per curve on the chart
4.) Axis uses same color as curve
5.) Axis uses same dash pattern as curve
6.) The edge of the chart is not an axis

This is basically a combination of a legend with multiple axes. I have not been able to get this effect with existing controls, so I have started to make my own in a canvas. To do this I need to line up my two tick marks with the edges of the chart. How can I obtain the location of the edges?

1 vote
13k views

How can i wrap legend? if legend width is out of window.

  • Raghupathy asked 9 years ago
  • last active 9 years ago
1 vote
13k views

I am stuck and do not seem to be able to make the legend become visible. I use a SciChartGroup and Datatemplate (MainChartView) as follows:

<UserControl x:Class="SciChartSample.Views.MainChartView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
         xmlns:resources="clr-namespace:SciChartSample.Resources"
         xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
         xmlns:mvvm="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
         mc:Ignorable="d" 
         d:DesignHeight="400" d:DesignWidth="600"
         DataContext="{Binding MainChartViewModel, Source={StaticResource Locator}}">

<i:Interaction.Triggers>
    <i:EventTrigger EventName="SizeChanged">
        <mvvm:EventToCommand 
            Command="{Binding UserControlResizedCommand, Mode=OneWay}"
            EventArgsConverterParameter="{Binding ElementName=LayoutRoot}"
            PassEventArgsToCommand="True" />
    </i:EventTrigger>
</i:Interaction.Triggers>

<UserControl.Resources>

    <!-- This allows setting the Height of a pane from a viewmodel -->
    <Style x:Key="ChartPaneStyle" TargetType="s:SciChartGroupPane">
        <Setter Property="Height" Value="{Binding PaneViewModel.Height, Mode=TwoWay}"/>
    </Style>

    <!-- A number of converters which change parameters of charts based on the IsFirstChartPane property -->
    <resources:BoolToValueConverter x:Key="MinorsPerMajorConverter" TrueValue="4" FalseValue="2"/>
    <resources:BoolToValueConverter x:Key="MaxAutoTicksConverter" TrueValue="8" FalseValue="4"/>
    <resources:BoolToValueConverter x:Key="GrowByConverter" >
    <resources:BoolToValueConverter.TrueValue>
        <s:DoubleRange Min="0.05" Max="0.05"/>
    </resources:BoolToValueConverter.TrueValue>
    <resources:BoolToValueConverter.FalseValue>
        <s:DoubleRange Min="0.02" Max="0.02"/>
    </resources:BoolToValueConverter.FalseValue>
    </resources:BoolToValueConverter>
    <resources:IsModifierTypeConverter x:Key="IsModifierTypeConverter" />

</UserControl.Resources>

<Grid>

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <!-- Databinds a SciChartGroup to a list of ChartPaneViewModels -->
    <!-- Child chart panes are generated using the ItemTemplate below -->
    <s:SciChartGroup Grid.Row="1" 
                     ItemsSource="{Binding ChartPaneViewModels}"
                     s:ThemeManager.Theme="{Binding ElementName=ThemeCombo, Path=SelectedItem}"
                     ItemContainerStyle="{StaticResource ChartPaneStyle}">

        <s:SciChartGroup.ItemTemplate>

            <DataTemplate>

                <s:SciStockChart Padding="0" 
                                 BorderThickness="0,0,1,1"
                                 ChartTitle="{Binding Title}"  
                                 IsXAxisVisible="{Binding IsFirstChartPane}"     
                                 IsPanEnabled="{Binding ParentViewModel.IsPanEnabled}"
                                 IsRubberBandZoomEnabled="{Binding ParentViewModel.IsZoomEnabled}"  
                                 VerticalChartGroupId="{Binding ParentViewModel.VerticalChartGroupId}"                                     
                                 SeriesSource="{Binding ChartSeriesViewModels}">

                    <s:SciStockChart.XAxisStyle>
                        <Style TargetType="s:CategoryDateTimeAxis">
                            <Setter Property="LabelProvider" Value="{Binding XAxisFormatting}"/>
                            <Setter Property="DrawMajorBands" Value="False"/>
                            <Setter Property="DrawMinorGridLines" Value="False"/>
                            <Setter Property="VisibleRange" Value="{Binding ParentViewModel.XVisibleRange, Mode=TwoWay}"/>
                            <Setter Property="GrowBy" Value="0, 0.02"/>

                        </Style>
                    </s:SciStockChart.XAxisStyle>

                    <s:SciStockChart.YAxisStyle>
                        <Style TargetType="s:NumericAxis">
                            <Setter Property="TextFormatting" Value="{Binding YAxisTextFormatting}"/>
                            <Setter Property="AutoRange" Value="Always"/>
                            <Setter Property="MinorsPerMajor" Value="{Binding IsFirstChartPane, Converter={StaticResource MinorsPerMajorConverter}}"/>
                            <Setter Property="MaxAutoTicks" Value="{Binding IsFirstChartPane, Converter={StaticResource MaxAutoTicksConverter}}"/>
                            <Setter Property="GrowBy" Value="{Binding IsFirstChartPane, Converter={StaticResource GrowByConverter}}"/>
                        </Style>
                    </s:SciStockChart.YAxisStyle>

                </s:SciStockChart>

            </DataTemplate>
        </s:SciChartGroup.ItemTemplate>
    </s:SciChartGroup>

    <StackPanel Grid.Row="0"
                Margin="2,4"
                Orientation="Horizontal">

        <ToggleButton Margin="2"
                      Command="{Binding PanModeCommand}"
                      s:ToggleButtonExtensions.GroupName="Modifiers"
                      IsChecked="True">
            <StackPanel Orientation="Horizontal" Width="47">

                <TextBlock Margin="3" Text="Pan" />
            </StackPanel>
        </ToggleButton>

        <ToggleButton Margin="2"
                      Command="{Binding ZoomModeCommand}"
                      s:ToggleButtonExtensions.GroupName="Modifiers">
            <StackPanel Orientation="Horizontal">

                <TextBlock Margin="3" Text="Zoom" />
            </StackPanel>
        </ToggleButton>

        <Button Margin="2" Command="{Binding ElementName=priceChart, Path=ZoomExtentsCommand}">
            <StackPanel Orientation="Horizontal">

                <TextBlock Margin="3" Text="Zoom Extents" />
            </StackPanel>
        </Button>

    </StackPanel>

    <Button Margin="259,4,261,6">
        <Button Content="LoadData" Height="30" Width="80" Command="{Binding LoadDataCommand}" CommandParameter="UserC"/>
    </Button>


</Grid>

My ChartView looks as follows:

<UserControl x:Class="SciChartSample.Views.ChartView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:visuals="clr-namespace:Abt.Controls.SciChart.Visuals;assembly=Abt.Controls.SciChart.Wpf"
         xmlns:sciChart3="clr-namespace:Abt.Controls.SciChart;assembly=Abt.Controls.SciChart.Wpf"
         xmlns:renderableSeries3="clr-namespace:Abt.Controls.SciChart.Visuals.RenderableSeries;assembly=Abt.Controls.SciChart.Wpf"
         xmlns:pointMarkers="clr-namespace:Abt.Controls.SciChart.Visuals.PointMarkers;assembly=Abt.Controls.SciChart.Wpf"
         xmlns:axes3="clr-namespace:Abt.Controls.SciChart.Visuals.Axes;assembly=Abt.Controls.SciChart.Wpf"
         xmlns:chartModifiers3="clr-namespace:Abt.Controls.SciChart.ChartModifiers;assembly=Abt.Controls.SciChart.Wpf"

         d:DesignHeight="577"
         d:DesignWidth="735"
         mc:Ignorable="d"
         DataContext="{Binding ChartViewModel, Source={StaticResource Locator}}">

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="368*"/>
        <ColumnDefinition Width="367*"/>
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
        <RowDefinition Height="32"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
    </Grid.RowDefinitions>

    <!-- Define Toolbar -->
    <StackPanel Grid.Row="0" Orientation="Horizontal" Grid.ColumnSpan="2">
        <ToggleButton Content="Zoom" Margin="3"
                      IsChecked="{Binding ZoomEnabled, Mode=TwoWay}"/>
        <ToggleButton Content="Pan" Margin="3"
                      IsChecked="{Binding PanEnabled, Mode=TwoWay}"/>
        <ToggleButton Content="MouseWheel" Margin="3"
                      IsChecked="{Binding MouseWheelEnabled, Mode=TwoWay}"/>
        <ToggleButton Content="Rollover" Margin="3"
                      IsChecked="{Binding RolloverEnabled, Mode=TwoWay}"/>
        <ToggleButton Content="Cursor" Margin="3"
                      IsChecked="{Binding CursorEnabled, Mode=TwoWay}" />
    </StackPanel>

    <visuals:SciChartSurface x:Name="MainChart" Grid.Row="1" sciChart3:ThemeManager.Theme="Chrome" Padding="30" Grid.RowSpan="2" Grid.ColumnSpan="2">

        <visuals:SciChartSurface.RenderableSeries>

            <renderableSeries3:FastLineRenderableSeries SeriesColor="DarkBlue" DataSeries="{Binding ChartData}">
                <renderableSeries3:FastLineRenderableSeries.PointMarker>
                    <pointMarkers:EllipsePointMarker Width="7" Height="7" Stroke="DarkBlue" Fill="DarkBlue" StrokeThickness="1"/>
                </renderableSeries3:FastLineRenderableSeries.PointMarker>
            </renderableSeries3:FastLineRenderableSeries>

        </visuals:SciChartSurface.RenderableSeries>

        <visuals:SciChartSurface.XAxis>
            <axes3:DateTimeAxis
                SubDayTextFormatting="dd/MM/yyyy HH:mm:ss.fff"
                VisibleRange="{Binding ChartData.XValues, Mode=OneWay}"
                GrowBy="0.1,0.1">
            </axes3:DateTimeAxis>
        </visuals:SciChartSurface.XAxis>

        <visuals:SciChartSurface.YAxis>
            <axes3:NumericAxis 
                VisibleRange="{Binding ChartData.YValues, Mode=OneWay}"
                GrowBy="0.1,0.1">
            </axes3:NumericAxis>
        </visuals:SciChartSurface.YAxis>

        <visuals:SciChartSurface.ChartModifier>
            <chartModifiers3:ModifierGroup>
                <chartModifiers3:RubberBandXyZoomModifier IsEnabled="{Binding ZoomEnabled, Mode=TwoWay}" IsXAxisOnly="True"></chartModifiers3:RubberBandXyZoomModifier>
                <chartModifiers3:ZoomPanModifier IsEnabled="{Binding PanEnabled, Mode=TwoWay}"></chartModifiers3:ZoomPanModifier>
                <chartModifiers3:MouseWheelZoomModifier IsEnabled="{Binding MouseWheelEnabled, Mode=TwoWay}"></chartModifiers3:MouseWheelZoomModifier>
                <chartModifiers3:RolloverModifier IsEnabled="{Binding RolloverEnabled, Mode=TwoWay}"></chartModifiers3:RolloverModifier>
                <chartModifiers3:CursorModifier IsEnabled="{Binding CursorEnabled, Mode=TwoWay}"  ShowTooltip="True" ShowTooltipOn="Always"  ></chartModifiers3:CursorModifier>
                <chartModifiers3:LegendModifier x:Name="legendSource" ShowLegend="True" Visibility="Visible" GetLegendDataFor="AllSeries"/>
            </chartModifiers3:ModifierGroup>
        </visuals:SciChartSurface.ChartModifier>

    </visuals:SciChartSurface>

    <visuals:SciChartLegend LegendData="{Binding LegendData, ElementName=legendSource, Mode=OneWay}"/>

</Grid>

Please note that I included a legendModifier in the ChartView and also defined a ChartLegend in same. But the legend is not visible at all. What am I doing wrong? Thanks

  • bbmat asked 9 years ago
  • last active 9 years ago
1 vote
21k views

how can i apply styling for legend in legend modifier? i want to apply the following style

<Style x:Key="LegendStyle" TargetType="s:LegendModifier">
        <Setter Property="ContentTemplate">
            <Setter.Value>        
                <DataTemplate>
            <s:SciChartLegend  x:Name="legendControl"  Margin="2,2" Orientation="Horizontal"  Background="Transparent" BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Auto"
                                Visibility="{Binding IsLegendVisible,Converter={StaticResource  BoolToVisibilityConverter}}" 
                                LegendData="{Binding LegendData,  ElementName=legendModifier,Mode=OneWay}">

                <s:SciChartLegend.Resources>
                    <SciChart:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
                </s:SciChartLegend.Resources>
                <s:SciChartLegend.ItemTemplate>
                    <DataTemplate DataType="SciChart:XyzSeriesInfo">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Rectangle Grid.Column="0"
                                                VerticalAlignment="Center"
                                                Stretch="Fill"
                                                Width="10"

                                                StrokeThickness="10"
                                                Stroke="{Binding SeriesColor,
                                                Converter={StaticResource ColorToBrushConverter}}" />
                            <TextBlock Grid.Column="1" Foreground="Black" 
                                                Margin="2,0,15,0"
                                                HorizontalAlignment="Center"
                                                Text="{Binding SeriesName}" FontWeight="Normal"/>
                        </Grid>
                    </DataTemplate>
                </s:SciChartLegend.ItemTemplate>
            </s:SciChartLegend>
        </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
  • Raghupathy asked 9 years ago
  • last active 9 years ago
1 vote
16k views

I have a case where there can be hundreds or even thousands of potential series on the surface.
When I use the LegendModifier, I only see the first 20 or so series.
What would it take to display a scrollbar so that the user can see all available series?
Thanks!

  • dwoerner asked 9 years ago
  • last active 9 years ago
1 vote
17k views

Hi,

I have a surface with multiple dataseries in it. I have a legend for each serie, setup like this:

chart.ChartModifier = new Abt.Controls.SciChart.ChartModifiers.LegendModifier() { Name = "legendModifier" };

var legend = new Abt.Controls.SciChart.Visuals.SciChartLegend { Margin = new Thickness(5) };

// Bind the legend to the data source
var legendDataBinding = new Binding("LegendData") { Source = chart.ChartModifier };
legend.SetBinding(Abt.Controls.SciChart.Visuals.SciChartLegend.LegendDataProperty, legendDataBinding);

And it works fine.
However, I would also like to bind the visibility of the legends to the visibility of the dataseries. I have tried this:

// Bind the legend visibility to the data source
var legendVisibilityBinding = new Binding("Visibility") 
{ 
    Converter = new BoolToVisibilityConverter(),
    
    Source = line.IsVisible
};
legend.SetBinding(Abt.Controls.SciChart.Visuals.SciChartLegend.LegendDataProperty, legendVisibilityBinding);

But it doesn’t seem to work, any suggestions, anyone?

BR
Jacob

  • JacobB asked 10 years ago
  • last active 10 years ago
Showing 41 results

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies