Hello,
I would like to implement a simple FastColumnRenderableSeries with an HorizontalLineAnnotation. But I would like it to be sideways.
Here is my current code:
g = new FastColumnRenderableSeries(); colums = new UniformXyDataSeries<double>();> using (m_sciChartSurface.SuspendUpdates()) { colums.Append(1); } g.DataSeries = colums; m_sciChartSurface.RenderableSeries.Add(g);> m_xAxis = new NumericAxis(); m_yAxis = new NumericAxis(); m_sciChartSurface.XAxis = m_xAxis; m_sciChartSurface.YAxis = m_yAxis; m_xAxis.Visibility = System.Windows.Visibility.Hidden; m_yAxis.AutoRange = AutoRange.Never; m_yAxis.VisibleRange = new DoubleRange(-3, 2); HorizontalLineAnnotation hla = new HorizontalLineAnnotation(); hla.Y1 = 1; hla.StrokeThickness = 5; hla.Stroke = Brushes.Red; m_sciChartSurface.Annotations.Add(hla); m_xAxis.AxisAlignment = AxisAlignment.Left; m_xAxis.FlipCoordinates = true; m_yAxis.AxisAlignment = AxisAlignment.Top; m_yAxis.FlipCoordinates = true;
However, the HorizontalLineAnnotation behaves strangely.
Anny suggestions?
Thank you.
- Marc Vahldieck asked 3 months ago
- last active 3 months ago
Hello
I have this chart with CategoryXAxis` as X and **NumericAxis as Y. I update its IohlcDataseries with new prices for creating a live chart. I also added a HorizontalLineAnnotation on Y-Axis to point to the current price. The problem is when chart auto-scales on Y-axis it only tries to cover price data and not the Line annotation, and its label is half visible.
- niazi curiosity.mobile2 asked 3 years ago
- last active 3 years ago
Hi, i want to make something like that : https://i.ibb.co/617TmD2/screenshot-line.png
I have tried HorizontalLineAnnotation but i successed to have it only on bottom graph : https://i.ibb.co/qsCjjGd/screen-bot-graph.png
Here how i initialize my top graph :
@Override
public void initGraph(Context context) {
Log.d(TAG, "initGraphs");
SciChartSurface spectogramSciChart = new SciChartSurface(context);
spectogram.addView(spectogramSciChart);
xAxis = new NumericAxis(context);
xAxis.setAutoRange(AutoRange.Always);
xAxis.setDrawMinorTicks(false);
xAxis.setDrawMajorBands(false);
xAxis.setDrawMinorGridLines(false);
xAxis.setAxisAlignment(AxisAlignment.Left);
xAxis.setFlipCoordinates(true);
xAxis.setAxisTitle("Frequences (KHz)");
xAxis.setAxisTitleOrientation(AxisTitleOrientation.VerticalFlipped);
spectogramSciChart.getXAxes().add(xAxis);
yAxis = new NumericAxis(context);
yAxis.setVisibleRange(new DoubleRange(startSpectrogramRange, endSpectrogramRange));
yAxis.setDrawLabels(false);
yAxis.setDrawMinorTicks(false);
yAxis.setDrawMajorBands(false);
yAxis.setDrawMinorGridLines(false);
yAxis.setAxisAlignment(AxisAlignment.Bottom);
yAxis.setFlipCoordinates(true);
yAxis.setAxisTitleOrientation(AxisTitleOrientation.Horizontal);
spectogramSciChart.getYAxes().add(yAxis);
FastUniformHeatmapRenderableSeries f = new FastUniformHeatmapRenderableSeries();
scichartTools.getSpectrogramDS().setStartX(0f);
scichartTools.getSpectrogramDS().setStepX(0.9f);
f.setDataSeries(scichartTools.getSpectrogramDS());
f.setMaximum(100);
f.setMinimum(-30.0);
f.setColorMap(new ColorMap(
new int[]{ColorUtil.Transparent, ColorUtil.DarkBlue, ColorUtil.Purple, ColorUtil.Red, ColorUtil.Yellow, ColorUtil.White},
new float[]{0f, 0.0001f, 0.25f, 0.50f, 0.75f, 1f}
));
spectogramSciChart.getRenderableSeries().add(f);
scichartTools.getSpectrogramValues().setSize(scichartTools.getFftSize() * scichartTools.getBatchSize() * 2);
// I add the line but it's not displayed
HorizontalLineAnnotation horizontalLine = new HorizontalLineAnnotation(context);
horizontalLine.setHorizontalGravity(Gravity.FILL_HORIZONTAL);
horizontalLine.setY1(5f);
horizontalLine.setLabelValue("Label");
spectogramSciChart.getAnnotations().add(horizontalLine);
}
You can see at the bottom of the function that i added it, but it doesn’t work on this graph. Why ? Maybe the graph is drawing over my line ?
Thanks,
Best regards
- damien gaillard asked 4 years ago
- last active 4 years ago
Or say, how can I prevent movement of HorizontalLineAnnotation when dragging the grip of X1(typically the left grip)?
- zhengyang qu asked 4 years ago
- last active 4 years ago
We have a SciChartSurface that displays data, and includes a collection of threshold lines that can be modified by the user by dragging.
To accomplish this, we are using a class that inherits from ChartModifierBase that includes an attached property for binding an IEnumerable:
public static readonly DependencyProperty ThresholdsSourceProperty =
DependencyProperty.Register
(
"ThresholdsSource",
typeof(IEnumerable),
typeof(CustomThresholdModifier),
new PropertyMetadata(null, OnThresholdsSourceChanged)
);
public IEnumerable ThresholdsSource
{
get { return (IEnumerable)GetValue(ThresholdsSourceProperty); }
set { SetValue(ThresholdsSourceProperty, value); }
}
The property includes a callback method (OnThresholdsSourceChanged) which is used to populate the Annotations collection of the parent SciChartSurface:
private static void OnThresholdsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var thresholdAnnotationModifier = d as CustomThresholdModifier;
if (thresholdAnnotationModifier != null)
{
var newValue = e.NewValue as IEnumerable;
if (newValue == null) return;
thresholdAnnotationModifier.RebuildAnnotations();
}
}
private void RebuildAnnotations()
{
if ((ParentSurface == null) || (ThresholdsSource == null)) return;
var annotationCollection = ParentSurface.Annotations;
annotationCollection.Clear();
foreach (IThresholdViewModel item in ThresholdsSource)
{
var threshold = new CustomHorizontalLineAnnotation{ DataContext = item };
annotationCollection.Add(threshold);
}
}
When this code is run, a binding exception occurs, but not until all of the code is successful. The exception:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement
or FrameworkContentElement for target element.
BindingExpression:Path=RotationAngle; DataItem=null; target element is
‘RotateTransform’ (HashCode=28139356); target property is ‘Angle’
(type ‘Double’)
The exception is clearly thrown downstream by some WPF thread, or I’d be able to wrap a try/catch around this and have better details.
If I comment out the line that creates the CustomHorizontalLineAnnotation, no exception.
If I add a short artificial delay before the first creation of CustomHorizontalLineAnnotation, no exception.
If I set “ShowLabel” = False in the HorizontalLineAnnotation, no exception.
If I add a dummy creation of CustomHorizontalLineAnnotation in the constructor of my CustomThresholdModifier, no exception.
If I add a dummy creation of AnnotationLabel in the constructor of my CustomThresholdModifier, no exception.
In short, the root cause of the binding exception seems to be coming from the creation of an AnnotationLabel in HorizontalLineAnnotation, either through setting ShowLabel=True, or adding it to the AnnotationLabels collection of the HorizontalLineAnnotation.
Any thoughts? I’d like to use the dummy creation of AnnotationLabel in the constructor as the solution to the problem, but this feels too much like a hack, and likely wont pass muster for my team. Maybe there’s some “best practice” being violated here, in using the modifier to update the annotation on property change?
Thanks!
- Robin Warren asked 5 years ago
- last active 5 years ago
Hello everyone,
I am the beginner of SciChart, now I able to create a candlestick chart with a HorizontalLineAnnotation but it doesn’t display well.
I have checked-out this tutorial
https://www.scichart.com/documentation/v5.x/webframe.html#The%20HorizontalLineAnnotation%20Type.html
I tried to convert the C# code and XML document to Kotlin but it seems there are no class AnnotationLabel found from the library.
Bellow is my screenshot
You can see the issue is the HorizontalLineAnnotation doesn’t contain the label (with value). What I need is it should have a label as bellow
Bellow is my implementation (in Kotlin)
val xAxis = sciChartBuilder.newCategoryDateAxis().build()
val yAxis = sciChartBuilder
.newNumericAxis()
.build()
val currentAnnotation = sciChartBuilder
.newHorizontalLineAnnotation()
.withBackgroundColor(0xFFFCB51E.toInt())
.withYValue(currentValue).build()
val rSeries = sciChartBuilder.newCandlestickSeries()
.withStrokeUp(upColor)
.withFillUpColor(upColor)
.withStrokeDown(downColor)
.withFillDownColor(downColor)
.withDataSeries(dataSeries)
.build()
UpdateSuspender.using(surface) {
Collections.addAll(surface.xAxes, xAxis)
Collections.addAll(surface.yAxes, yAxis)
Collections.addAll(surface.annotations, currentAnnotation)
Collections.addAll(surface.renderableSeries, rSeries)
Collections.addAll(surface.chartModifiers, sciChartBuilder.newModifierGroupWithDefaultModifiers().build())
}
Can someone please help me on this?
- Vo Hoa asked 5 years ago
- last active 5 years ago