Pre loader

Tag: SciChartLegend

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

Hello,

I’m trying to include a legend modifier for a collection of LineRenderableSeriesViewModel, everything works fine except I’m not able to set the series Name to show in the legend, because this view Model doesn’t have a Name property to set so all I get is the series markers (and visibility checkboxes but don’t really need those), does someone know how to show these names?

I tried extending said ViewModel with a custom one adding a Name property but didn’t work.

Thanks a lot,

Marco

1 vote
1k views

As part of a recent flag added to 3.2.509, I moved from 3.2 to 3.2.509; it looks like positioning of the scichart legend has changed. The style is now appearing as position: absolute — I don’t have access to source, but I wonder if this was part of 3.2.491, which mentioned something about positioning of the legend?

Anyway, if this was an intended change — and if it’s not something I managed to do to myself — it broke my implementation of an outside-of-plot legend. This is how the style is currently appearing:

<div class="scichart__legend" style="height: 100%; position: absolute; display: flex; left: 0; top: 0; text-align: center;">
...
</div>

This is how it appeared my currently deployed code:

<div class="scichart__legend" style="height: 100%; display: flex; float: left; text-align: center;">
...
</div>

Anyway, should be able to figure something out I hope — I’m no CSS wizard — but wanted to flag it as a possible breaking change that might not have been intended.

1 vote
2k views

Greetings,
i have three Series in a SciChart.js (Community-Version) Surface.
The Legend i added shows me all three of them and their names and checkboxes do hide or show the series.

Here is my problem: Is there a way to hide one Series (a FastCandlestickRenderableSeries) from the Legend? I only want to show the other two Series (FastLinerenderableSeries).

Somethin like a Parameter “showInLegend: false,”? I did not find something like this in the documentation(https://www.scichart.com/documentation/js/current/typedoc/classes/legendmodifier.html).

Thank you

1 vote
2k views

I am trying to place a legend outside a Piechart without success. When I create the legend modifier like below everything works as expected:

    let legendModifier = SCIPieChartLegendModifier()
    legendModifier.sourceSeries = renderableSeries
    legendModifier.margins = UIEdgeInsets(top: 17, left: 17, bottom: 17, right: 17)
    legendModifier.position = [.bottom, .centerHorizontal]

However when I try to place it outside like below the app crashes with:
NSInvalidArgumentException’, reason: ‘-[SCIPieSegment seriesName]: unrecognized selector sent to instance 0x281881500

    legend = SCIChartLegend()
    legend.backgroundColor = SCIColor(.red)
    let dataSource = SCISeriesInfoLegendDataSource(legend: legend)
    legendModifier = SCIPieChartLegendModifier(legend: legend, dataSource: dataSource, useAutoPlacement: false)
    legendModifier.sourceSeries = renderableSeries.series
    legendModifier.margins = UIEdgeInsets(top: 17, left: 17, bottom: 17, right: 17)
    legendModifier.position = [.left, .top]

Note: I am using SwiftIUI and add the legend container to the swiftui view wrapped in an UIViewRepresentable

UIViewRepresentable(container: legend.container!)

if i comment out legendModifier.sourceSeries = renderableSeries.series the crash does not appear but the legend does not show.

0 votes
2k views

I am creating a graph for 10 data series using Scichart, with the most optimal legend placement for the graph being “Top” with Horizontal Orientation as shown in the code below. I would like to keep the spacing compact so all the data series can be visible without the need for the scrollbar, however because of the checkboxes for selecting each series being enabled I cannot compress the spaces to make all the data series visible. I did try using a custom legend with the typical binding but to no avail. I have attached an image of the current legend as well.

<s:LegendModifier Name="legendModifier" Margin="1" Width="1" ShowLegend="True" Orientation="Horizontal"
                                  HorizontalAlignment="Left" VerticalAlignment="Top"
                                  LegendPlacement="Top" ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                  Visibility="Visible"/>

Is it possible to format the legend so as to keep all the series names visible while maintaining the checkboxes for displaying or hiding individual data series?

  • Gil Owu asked 1 year ago
  • last active 11 months ago
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
0 answers
9k views

Hello!

The legend is in horizontal orientation, and Im displaying multiple series.

When the legend is inside the chart (default config), Im able to scroll left or right to see all available series.

But when it is moved outside the chart, it is no longer scrollable. Checkboxes are still clickable to show or hide series.

Thinking it might be something interfering with the scroll gesture, I started a new project following the Android tutorial. It still stops working as soon as I move it outside the chart.

Is this a bug, or am I missing something?

This does not happens on iOS.

Regards

XML Layout
`

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_margin="30dp"
        android:id="@+id/chart_layout"
        android:layout_width="match_parent"
        android:layout_height="500dp"
        android:orientation="horizontal"/>

    <com.scichart.charting.visuals.legend.SciChartLegend
        android:id="@+id/legend"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_margin="10dp"/>
</LinearLayout>

`

Legend and LegendModifier config

    final SciChartLegend legend = findViewById(R.id.legend);
    legend.setLegendOrientation(Orientation.HORIZONTAL);

    final LegendModifier legendModifier = new LegendModifier(legend, false);

    surface.getChartModifiers().add(legendModifier);
1 vote
2k views

I have a SciChartLegend below my chart that was using the default item template in v6.4, and I could change the color of my legend labels simply by setting the Foreground property of the SciChartLegend. However, when I updated to SciChart 6.5.1, the font of my legend labels changed to all black. If I investigate my UI using Snoop, I see the following Binding error on the TextBlock.Foreground property for one of my legend items:

System.Windows.Data Error: 4 : Cannot find source for binding with reference ‘RelativeSource FindAncestor, AncestorType=’SciChart.Charting.Visuals.RenderableSeries.LegendPlaceholder’, AncestorLevel=’1”. BindingExpression:Path=Foreground; DataItem=null; target element is ‘TextBlock’ (Name=”); target property is ‘Foreground’ (type ‘Brush’)

I also tried v6.5.0, and this behavior did not occur – it is new in v6.5.1

Below is the definition of my legend.

<s:SciChartLegend x:Name="legend"
                  LegendData="{Binding ElementName=LegendModifier, Path=LegendData}"
                  Orientation="Horizontal"
                  BorderBrush="White"
                  FontSize="14"
                  BorderThickness="1"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  ShowVisibilityCheckboxes="True">
    <s:SciChartLegend.ItemsPanel>
        <ItemsPanelTemplate>
            <chartUtils:UniformWrapPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </s:SciChartLegend.ItemsPanel>
</s:SciChartLegend>
0 votes
3k views

Hello,

I’m probably missing something obvious, but how can I change the font/colors of JUST the scichart legend (not axes labels or other text) in Android.

Thank you.

  • C Bolton asked 2 years ago
  • last active 2 years ago
0 votes
4k views

I have added a real time value legend to my chart. This is working well, based upon examples I have found here at the forum and in the SciChart documentation.

My question is this:
How can I position this new legend (includes series color, series name and series YValue ) so that it is in relation to a single or multiple Y axis’s displayed. In other words I like it to positions itself in relation to the YAxis so it does not overwrite it, and stays on the plotting area.

Appreciate the help
Thank you
Anders

1 vote
3k views

After seeing some strange behavior in my application, I have a simple repro case where hiding a renderable series that’s in a vertically stacked columns collection causes the entire screen to go black. I’ll attach a full viewDidLoad() below, but here’s the basic setup:

    let rsLeftSingle = SCIStackedColumnRenderableSeries()
    rsLeftSingle.dataSeries = dataSeriesLeftSingle
    rsLeftSingle.yAxisId = yAxisLeft.axisId
    rsLeftSingle.fillBrushStyle = SCISolidBrushStyle(color: UIColor.yellow)
    rsLeftSingle.strokeStyle = SCISolidPenStyle(color: UIColor.yellow, thickness: 2.0)

    let rsLeftDouble = SCIStackedColumnRenderableSeries()
    rsLeftDouble.dataSeries = dataSeriesLeftDouble
    rsLeftDouble.yAxisId = yAxisLeft.axisId
    rsLeftDouble.fillBrushStyle = SCISolidBrushStyle(color: UIColor.blue)
    rsLeftDouble.strokeStyle = SCISolidPenStyle(color: UIColor.blue, thickness: 2.0)

    let stacks = SCIVerticallyStackedColumnsCollection()
    stacks.add(rsLeftSingle)
    stacks.add(rsLeftDouble)
    surface.renderableSeries.add(stacks)

    let legendModifier = SCILegendModifier()
    surface.chartModifiers.add(legendModifier)

That code displays a stack of yellow and blue bars, with a legend and checkboxes (both checkboxes selected). When I tap a checkbox to deselect it, the SCIChartSurface() goes blank, the legend remains on screen, and I see this message in the console:

Exception raised with reason: All stacked series in on collection should have the same amount of X Values

When I reselect that checkbox, I get my plot back.

There are no changes being made to the underlying data. Hiding/showing works correctly for horizontally stacked collection and for other renderable series types.

What’s your recommended workaround?

0 votes
3k views

Hello!

I have a SciChartSurface with 193 series on it and my application needs to display a legend with 193 items. The requirement is that a legend should be located underneath the plot as a scrollable panel with items arranged in a wrap-panel fashion. The problem is that it takes a long time to render this many items because WrapPanel does not use Virtualization.

I found a 3-rd party control (https://github.com/sbaeumlisberger/VirtualizingWrapPanel) that implements virtualization in a WrapPanel. However, it is designed to work inside a ListBox/ListView and does not as an ItemPanelTemplate for SciChartLegend.

Is it possible to render LegendData in a custom control? I’ve noticed that LegendData is a ChartDataObject. However, when I bind its SeriesInfo property my ListBox is not populated.

Here is my XAML:

In my SciChartSurface I’ve added a modifier:

<s:SciChartSurface.ChartModifier>
                    <s:ModifierGroup>
                        <!--  Turn this legend off because we've got a custom one below  -->
                        <s:LegendModifier GetLegendDataFor="AllSeries" ShowLegend="False" />
                        <local:ErrorBarExclusionLegendModifier x:Name="mwErrorBarExcluder" />
                        <s:TooltipModifier />
                        <local:MouseClickChartModifier RightClickPosition="{Binding RightClickPosition, Mode=OneWayToSource}" />
                    </s:ModifierGroup>
</s:SciChartSurface.ChartModifier>

Then I declare a ListBox:

<ListBox
                Grid.Row="4"
                Grid.Column="0"
                Height="220"
                ItemTemplate="{StaticResource SciChartLegendItemTemplate}"
                ItemsSource="{Binding LegendData, ElementName=mwErrorBarExcluder, Converter={StaticResource SeriesConv}}">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <wtk:VirtualizingWrapPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>

Since I can’t bind ItemsSource to ChartDataObject I wrote a simple converter that extracts the collection of SeriesInfo objects:

public object Convert(object aValue, Type aTargetType, object aParameter, CultureInfo aCulture)
{
    ChartDataObject fSource = aValue as ChartDataObject;

    return fSource?.SeriesInfo;
}

What am I doing wrong?

Thank you in advance for your suggestions.

1 vote
4k views

SciChart 3.1.0.5175
iOS 13.5
Xcode 10.15.5

If I am using the API incorrectly please let me know. I am not aware of any requirement to wait after using the SciChart API.

It appears the SCILegendModifier has some kind of timing bug. If you draw a chart on a surface with a legend, then clear the chart, then add another plot to the same surface you will notice the legend has stale data. However, if you clear the surface and wait a second before you add the new plot it will work as expected.

I created a sample Xcode project to demonstrate the issue. See the attachment chart.zip

I also created a video to demonstrate the issue: https://youtu.be/1JBTd1sfVgI

I have a workaround so this is not urgent, but I would like to remove the delay for my production release.

0 votes
8k views

I would like to change the color of chart legend, but have failed to find information on how can I do this for iOS. Any sort of tutorial would be highly appreciated.

Worst case scenario would be to create a custom theme that is based on Bright Spark theme and update legend parameters there, but for this I would need to know what exactly does Bright Spark theme looks like.

Looking forward to any recommendations.

Best Regards,
Paul.

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
7k views

I am trying to add a legend to my chart similar to how is done in the LegendChartView.swift code in the sample app. However the legend does not show and I get several NSLayoutConstraints conflicts such as this one:

[LayoutConstraints] Unable to simultaneously satisfy constraints.   Probably at least one of the constraints in the following list is one you don't want.   Try this:       (1) look at each constraint and try to figure out which you don't expect;       (2) find the code that added the unwanted constraint or constraints and fix it.  (
    "<NSLayoutConstraint:0x283528af0 UIButton:0x13c52d840.height == 25   (active)>",
    "<NSLayoutConstraint:0x2835285f0 UIButton:0x13c52d840.bottom == UIView:0x13c545060.bottom - 4   (active)>",
    "<NSLayoutConstraint:0x2835285a0 V:|-(4)-[UIButton:0x13c52d840]   (active, names: '|':UIView:0x13c545060 )>",
    "<NSLayoutConstraint:0x283528b40 'UIIBSystemGenerated' SCIDefaultLegendItem:0x13c543f90.top == UIView:0x13c545060.top   (active)>",
    "<NSLayoutConstraint:0x283528b90 'UIIBSystemGenerated' V:[UIView:0x13c545060]-(0)-|   (active, names: '|':SCIDefaultLegendItem:0x13c543f90 )>",
    "<NSLayoutConstraint:0x283529c20 'UIView-Encapsulated-Layout-Height' SCIDefaultLegendItem:0x13c543f90.height == 0   (active)>" )

Will attempt to recover by breaking constraint  <NSLayoutConstraint:0x283528af0 UIButton:0x13c52d840.height == 25   (active)>

The internal SCIDefaultLegendItems look to keep setting their width and height to 0 which causes conflicts with the underlying UIButton and UILabel components.

Any thoughts on how to get around this? My chart has four series. I have seen the article on drawing the legend outside the chart surface area however I do not want to do that.

Thank you!

  • Brad Taber asked 4 years ago
  • last active 4 years ago
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.

1 vote
9k views

Hello.

I am working on Xamarin Android project with C#. Since having a legend within the chart causes problems with too many axis’ (no scrolling is available thus selecting different series in a legend becomes unavailable) and having a legend outside of chart area, anywhere we desire, would be of a preference, is there a tutorial on how could I achieve such a thing? Our project needs this functionality for both Android and iOS.

Would be grateful if anyone could help out with this issue.

Thank you in advance!

  • pauzu asked 5 years ago
  • last active 5 years ago
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?

1 vote
6k views

I’m having difficulty determining the easiest method of placing the legend outside of the chart surface in iOS. I’ve done a ton of trial and error and have run into several issues. I understand that the SCIChartLegend class is just a subclass of UICollectionView. The problem seems to be these two things:

— When adding a legend via SCILegendModifier it only allows for custom placement if using SCILegendModifier’s initializer which also requires you assign an SCILegendDataSource. Or at least that’s required for the initializer with the useAutoPlacement parameter that I can then set to false (not even sure if that would work once I got that far).

— Placing the SCIChartLegend view manually without first initializing an SCILegendModifier with it results in none of the legend cells being loaded. I would imagine this is due to a missing SCILegendDataSource.

It seems like these could be overcome if I could somehow construct a default instance of SCILegendDataSource. Unfortunately, SCILegendDataSource only exposes one initializer which requires I pass it a xib name for the legend items. But I do not want to customize the legend items- I simply want to be able to construct the default SCILegendDataSource because that is apparently required to get the SCIChartLegend working.

Am I making this more complicated than it needs to be? What’s the simplest path to placing the chart legend where I want in iOS?

  • Sean Young asked 5 years ago
  • last active 5 years ago
0 votes
8k 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.Android
SciChart.Android 2.2.2.854

Version
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

0 votes
0 answers
8k views

Hi
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
8k views

I am building an application that plots over 600 series, I want to have a method of filtering the series in the legend, is this possible with SciChart Legend API?

Also, how can I set the checkbox’s of all the series to unchecked as defualt when data is imported? At the moment, when the data is pulled into the application the legend populates the series and the checkboxes are checked as default.

If I can supply any further information, please let me know.

Thanks

1 vote
6k views

I have created the following style for my charts legend:

   <Style  TargetType="{x:Type s:SciChartLegend}">
        <Setter Property="Background" Value="DarkGray"/>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate DataType="{x:Type s:XyzSeriesInfo}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Ellipse Grid.Column="0" 
                              VerticalAlignment="Center"
                              Stretch="Fill"
                              Width="40"
                              Height="40"
                              StrokeThickness="3"
                              Stroke="{Binding ????, Converter={StaticResource SlitValveToBrushConverter}}" />
                        <TextBlock Grid.Column="1"
                                   Margin="5,0,10,0"
                                   HorizontalAlignment="Center"
                                   Text="{Binding SeriesName}" />
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

I want to bind the Stroke of my ellipse to the Z Value (the string part) of my DataSeries (property is called ChartItems) which is of type XyzDataSeries3D<DateTime, int, string>

How can I bind to the Z Value?

2 votes
8k views

I managed to spearate the legend from the SciChartSurface, however the way I did it is very hackish. I couldn’t find any documentation on how it is supposed to be done correctly.

The way I did it (Kotlin code):

val legend = SciChartLegend(context)
legendModifier = LegendModifier(legend)
legendModifier.setOrientation(Orientation.VERTICAL)
legendModifier.setLegendPosition(Gravity.START or Gravity.TOP, 0)
legendModifier.setSourceMode(SourceMode.AllVisibleSeries)
legendModifier.setShowSeriesMarkers(true)
legendModifier.setShowCheckboxes(true)


val modifierGroup = chartBuilder.newModifierGroup().build()
modifierGroup.childModifiers.add(legendModifier)
chartSurface.chartModifiers.add(modifierGroup)

if(legend.parent != null)
{
    (legend.parent as ViewGroup).removeView(legend)
}

val linearLayout = LinearLayout(context)
linearLayout.orientation = LinearLayout.VERTICAL
linearLayout.addView(legend)
linearLayout.addView(chartSurface)

I was surprised that passing the legend to LegendModifier constructor also adds it to it’s layout. So I had to manually remove it and add it to my LinearLayout. It does work, but as I said, it is a hackish way of doing it. My question is, how is it done correctly?

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
0 votes
10k views

I have a legend modifier and I’m trying to set the max height like this:

<s:LegendModifier ShowLegend="True" Orientation="Vertical" LegendPlacement="Inside"
    ScrollViewer.HorizontalScrollBarVisibility="Auto"
    ScrollViewer.VerticalScrollBarVisibility="Auto"
    MaxHeight="165" />

However the setting has no effect on the max height. Is there somewhere else I need to set this? Thank you.

  • AE Admin asked 7 years ago
  • last active 7 years ago
0 votes
0 answers
9k views

I am working with Wpf on window.

I have defined a legend modifier with a template.

<s:ModifierGroup>
                    <s:LegendModifier
                        ShowLegend="True"
                        Orientation="Horizontal"
                        Margin="20"
                        LegendPlacement="Inside"
                        LegendItemTemplate="{DynamicResource TopDownLegendTemplate}"
                        GetLegendDataFor="AllSeries"
                        ShowVisibilityCheckboxes="True"/>
                </s:ModifierGroup>

Always, when the chart is rendered, the legend is not (see legendOff.PNG)

Most times, after some chart updates (e.g by moving a slider that affects the data displayed), the legend comes back on (see legendOn.PNG)

Always, when the legend is rendered, then it will stay rendered.

A similar code is elsewhere in my project and does not give this problem so I can’t say for sure it is a bug. It certainly is an unexpected behavior.

Another piece of useful information is that my template uses a converter in the xaml code. I have put a breakpoint in this converter and verified the code is not being called (hence nothing is trying to render the legend) when the chart is rendered.

Any idea?

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
12k views

I am working on an application where I have multiple XY data series. For one of the series, we are producing annotation data for some of the points. There are 8 different types of annotations that can be created. Based on the response you gave to a previous question, I am creating the annotations as separate data series instead of as actual annotation objects since there are thousands of them. Performance starts to suffer as the number of annotations increases.

The issue I’m running into now is the number of series is now 14 which is unwieldy for displaying in a legend. My current legend is horizontally oriented as shown in the attached image. I would prefer that the user not have to scroll to view all of the legend items and am trying to figure out how to achieve that.

Is there a way to specify a fixed width for the legend and have items wrap to a new line if there is not enough room for them? I didn’t see that as being an option for the standard legend template.

Also, is there a way to use multiple legends for a chart? Ideally it would be nice to split the series that are associated with annotation data into their own legend instead of mixing them in with the legend for the normal data. The SeriesInfo object doesn’t appear to have any property that would allow me to categorize the data.

Thanks,
Scott

  • sdamge asked 8 years ago
  • last active 8 years ago
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
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
0 answers
14k views

Hi,

I think I have found a bug. If LegendModifier has Margin (i.e. 10) it forces ModifierGroup to grow to VisibleWidth/Height 20×20. Than you can clearly see that the modifier group is placed outside the “chart area” and creates additional “topleft margin”.

Setting Grid.Row=”3″ and Grid.Column=”2″ on ModifierGroup looks like a fix.

Thanks

1 vote
14k views

I am dynamically adding and removing items from an observablecollection of Irenderable series in my viewmodel, and binding it to the renderableseries on the chart surface. However, when I add and remove items that I want to be ordered, and are appropriately ordered in the collection, they are not ordered on the legend.

Is there a way to reorder the series in the legend (MVVM solution would be great)?

You can replicate the issue (or the symptom), by toggling the visibilty of the series in the below example by clicking the checkbox within the legend and then switching the getlegenddatafrom to visible series, and then switch back. (no longer in ABC order).

https://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/CreateMultiseriesChart/MultipleLinesView.xaml

Thanks,
Jason

  • morseja asked 9 years ago
  • last active 3 months 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
0 answers
9k views

Hello,

I need to show a EntitySet in a graph. this EntitySet will have a column called Time. I want to use the Time column on the X-Axis. I then want to show the other columns on the Y-Axis. I furthermore need to filter out the ID and NodeID columns before displaying on the Graph. The user can actually pick what EntitySet they want to graph so I don’t believe I can use XAML code to hard code this…I will need to do this dynamically in C#. I also need to be able to generate something like a Legend and allow the end user to show or hide each of the columns on the Y-Axis. I didn’t see a good example in the demos on what I need to accomplish. An example or some code snippets would greatly be appreciated.
Thanks

—Dave

0 votes
11k views

Hi

Based on some window’s size logic I want an ItemTemplateSelector to set the correct ItemTemplate.
But it doesn’t seem like the SciCharLegend picks up the ItemTemplateSelector, because whatever I put into the ItemTemplates it is totally ignored and only the default is rendered.

public class SciChartLegendTemplateSelector : DataTemplateSelector
{
    public DataTemplate NormalItemTemplate { get; set; }
    public DataTemplate SmallItemTemplate { get; set; }

    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
        return NormalItemTemplate;
    }
}

<DataTemplate x:Key="SciChartLegendNormalItemTemplate">
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="NORMAL"></TextBlock>
    </StackPanel>
</DataTemplate>
<DataTemplate x:Key="SciChartLegendSmallItemTemplate">
    <StackPanel Orientation="Vertical">
        <TextBlock Text="SMALL"></TextBlock>
    </StackPanel>
</DataTemplate>
<templateSelectors:SciChartLegendTemplateSelector x:Key="SciChartLegendTemplateSelector"
                                                  NormalItemTemplate="{StaticResource SciChartLegendNormalItemTemplate}"
                                                  SmallItemTemplate="{StaticResource SciChartLegendSmallItemTemplate}"/>

<s:SciChartLegend x:Name="legendControl"
                  s:ThemeManager.Theme="BrightSpark"
                  VerticalAlignment="Bottom"
                  HorizontalAlignment="Stretch"
                  Background="White"
                  FontSize="10"
                  FontStretch="UltraCondensed"
                  LegendData="{Binding LegendData,
                                       ElementName=legendModifier,
                                       Mode=OneWay}"
                  ShowVisibilityCheckboxes="True"
                  ItemTemplateSelector="{StaticResource SciChartLegendTemplateSelector}">
Showing 41 results

Try SciChart Today

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

Start TrialCase Studies