0

Ever since I've updated SciChart in my application, I've been struggling to make it look and feel somewhat similar to how it used to. Thanks to Dr. ABT I was able to get rid of plaid bands, but now I'm facing problems with grid lines.

In the previous version of SciChart all the grid lines and tick lines seemed to automatically inherit colors defined in styles somewhere upstream in the application. In the new version the lines are just black. So I had to manually override MajorGridLineStyle, MajorTickLineStyle, MinorGridLineStyle and MinorTickLineStyle for each instance of SciChart. But one instance is problematic, because the application logic requires the Y axis to be added from code. Because of this I am unable to style its grid lines in xaml.

I have tried to add the styles in code:

_yAxis = new NumericAxis()
                {
                    ...
                    DrawMajorBands = false,
                    MajorGridLineStyle = MajorLineStyle,
                    MinorGridLineStyle = MinorLineStyle
                };

The result is that not only are the grid lines not shown, but the actual data series disappears from the graph (along with some line annotations) and all that is displayed is the X axis with its grid lines. I've done some experimenting and I've verified that it's the code that add the styles that causes the problem. The styles I'm using are analogous to the ones I have defined in xaml (which are working properly)

MajorLineStyle = new Style(typeof(Line));
MajorLineStyle.Setters.Add(new Setter(Line.StrokeProperty, Brushes.Pink));            
MajorLineStyle.Setters.Add(new Setter(Line.StrokeThicknessProperty, 1));
MajorLineStyle.Setters.Add(new Setter(Line.OpacityProperty, 0.6));

Is this a bug in SciChart, or am I doing something wrong? Is there a way to add have style for programmatically defined axes in the xaml? Is there a way to override the line colors on SciChartSurface level so I don't have to do it individually for each type of line?

Community
  • 1
  • 1
Shaggydog
  • 3,456
  • 7
  • 33
  • 50
  • `The new gridlines are just black` - Are they? Afaik they obey theme colors. Individual theme colors can be overridden https://www.scichart.com/documentation/v4.x/Overriding%20Colors%20of%20our%20Themes.html you can apply implicit styles http://stackoverflow.com/questions/13016932/how-to-create-a-style-based-on-default-style or create or apply a style in code-behind https://social.msdn.microsoft.com/Forums/vstudio/en-US/21b90141-0b8e-48fc-9936-2ba215bd344a/programatically-creatingapplying-style-resources?forum=wpf – Dr. Andrew Burnett-Thompson Apr 10 '17 at 10:22
  • Well I don't know exactly what the charts are using, but the fact of the matter is that the lines are black now, and they used to be a shade of beige that we use in the application before I switched the dlls. And no other styling code was touched. I've tried nested styles, it didn't do anything. And like I explained, trying to add the style in code resulted in the chart breaking. I'll try overriding the theme, I haven't tried that one yet. – Shaggydog Apr 10 '17 at 10:37
  • Overriding the theme colors via ThemeManager works, but it overrides colors for all SciChart instances in the application. So I'll guess I'll create a custom theme. That should do the trick. – Shaggydog Apr 10 '17 at 12:06
  • This and your previous question sound like you've started with the default theme (SciChartv4Dark) and tried to set colors in XAML. That's OK just you need to set all the colours :) It's better to start with a theme that more closely matches what you want to achieve, then apply styles selectively. For more info on how to style a chart, see https://www.scichart.com/wpf-chart-example-xaml-styling which shows every element in beautiful technicolour :) – Dr. Andrew Burnett-Thompson Apr 10 '17 at 14:20
  • SciChart v3's default style was 'BlackSteel.xaml'. SciChart v4's default theme is 'SciChartv4Dark.xaml'. If you want it back how it was, I suggest using theme = Blacksteel – Dr. Andrew Burnett-Thompson Apr 24 '17 at 15:14

0 Answers0