<UserControl x:Class="Abt.Controls.SciChart.Example.Examples.IWantTo.CreateMultiseriesChart.CandlestickWithLinesView" 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:s="http://schemas.abtsoftware.co.uk/scichart" d:DesignHeight="300" d:DesignWidth="300" Loaded="CandlesticksWithLines_Loaded" mc:Ignorable="d">
<s:SciChartSurface x:Name="sciChart" s:ThemeManager.Theme="Chrome">
<s:SciChartSurface.RenderableSeries>
<!-- Candlestick bodies now support gradients as well as solid colours -->
<s:FastCandlestickRenderableSeries>
<s:FastCandlestickRenderableSeries.UpBodyBrush>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#55002200"/>
<GradientStop Offset="1" Color="#FF00AA00"/>
</LinearGradientBrush>
</s:FastCandlestickRenderableSeries.UpBodyBrush>
<s:FastCandlestickRenderableSeries.DownBodyBrush>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#55441111"/>
<GradientStop Offset="1" Color="#FFFF0000"/>
</LinearGradientBrush>
</s:FastCandlestickRenderableSeries.DownBodyBrush>
</s:FastCandlestickRenderableSeries>
<s:FastLineRenderableSeries SeriesColor="#FF1919"/>
<s:FastLineRenderableSeries SeriesColor="#1964FF"/>
<s:FastLineRenderableSeries SeriesColor="#FF9B27"/>
</s:SciChartSurface.RenderableSeries>
<s:SciChartSurface.XAxis>
<s:CategoryDateTimeAxis GrowBy="0.0, 0.2"/>
</s:SciChartSurface.XAxis>
<s:SciChartSurface.YAxis>
<s:NumericAxis GrowBy="0.1, 0.1"/>
</s:SciChartSurface.YAxis>
<s:SciChartSurface.ChartModifier>
<s:ModifierGroup x:Name="_groupModifier">
<s:ZoomPanModifier XyDirection="XDirection"/>
<s:ZoomExtentsModifier ExecuteOn="MouseDoubleClick"/>
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>
</s:SciChartSurface>
</UserControl>
______
using System;
using System.Windows;
using System.Windows.Controls;
using Abt.Controls.SciChart.Example.Common;
using Abt.Controls.SciChart.Example.Data;
using Abt.Controls.SciChart.Model.DataSeries;
namespace Abt.Controls.SciChart.Example.Examples.IWantTo.CreateMultiseriesChart
{
public partial class CandlestickWithLinesView : UserControl
{
public CandlestickWithLinesView()
{
InitializeComponent();
}
private void CandlesticksWithLines_Loaded(object sender, RoutedEventArgs e)
{
// Create multiple DataSeries to store OHLC candlestick data, and Xy moving average data
var dataSeries0 = new OhlcDataSeries<DateTime, double>();
var dataSeries1 = new XyDataSeries<DateTime, double>();
var dataSeries2 = new XyDataSeries<DateTime, double>();
var dataSeries3 = new XyDataSeries<DateTime, double>();
// Prices are in the format Time, Open, High, Low, Close (all IList)
var prices = DataManager.Instance.GetPriceData(Instrument.Indu.Value, TimeFrame.Daily);
// Append data to series.
// First series is rendered as a Candlestick Chart so we append OHLC data
dataSeries0.Append(prices.TimeData, prices.OpenData, prices.HighData, prices.LowData, prices.CloseData);
// Subsequent series append moving average of the close prices
dataSeries1.Append(prices.TimeData, DataManager.Instance.ComputeMovingAverage(prices.CloseData, 100));
dataSeries2.Append(prices.TimeData, DataManager.Instance.ComputeMovingAverage(prices.CloseData, 50));
dataSeries3.Append(prices.TimeData, DataManager.Instance.ComputeMovingAverage(prices.CloseData, 20));
sciChart.RenderableSeries[0].DataSeries = dataSeries0;
sciChart.RenderableSeries[1].DataSeries = dataSeries1;
sciChart.RenderableSeries[2].DataSeries = dataSeries2;
sciChart.RenderableSeries[3].DataSeries = dataSeries3;
sciChart.ZoomExtents();
}
}
}
scichart by Kline,布布扣,bubuko.com