visifire 使用备忘
// 图表绑定辅助类
public class ChartValue : INotifyPropertyChanged
{
public ChartValue() { }
public ChartValue(string xlabel, decimal value)
{
Label = xlabel;
_yValue = value;
}
decimal _yValue;
string _label;
public event PropertyChangedEventHandler PropertyChanged;
public String Label
{
get
{
return _label;
}
set
{
_label = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Label"));
}
}
}
public decimal YValue
{
get
{
return _yValue;
}
set
{
_yValue = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("YValue"));
}
}
}
}
//创建DataSeries(1)
public static Visifire.Charts.DataSeries CreateSerie(string title, Visifire.Charts.RenderAs RenderAsType)
{
Visifire.Charts.DataSeries myChartSeries = new Visifire.Charts.DataSeries();
myChartSeries.LegendText = title;
myChartSeries.RenderAs = RenderAsType;
myChartSeries.Cursor = Cursors.Hand;
myChartSeries.MarkerEnabled = true;
myChartSeries.MarkerType = Visifire.Commons.MarkerTypes.Circle;
Visifire.Charts.DataMapping myDataMappingX = new Visifire.Charts.DataMapping();
myDataMappingX.MemberName = "AxisXLabel";
myDataMappingX.Path = "Label";
Visifire.Charts.DataMapping myDataMappingY = new Visifire.Charts.DataMapping();
myDataMappingY.MemberName = "YValue";
myDataMappingY.Path = "YValue";
myChartSeries.DataMappings.Add(myDataMappingX);
myChartSeries.DataMappings.Add(myDataMappingY);
return myChartSeries;
}
//创建DataSeries(2)
<vc:Chart.Series>
<vc:DataSeries LegendText="目标值" RenderAs="Column"
Cursor="Hand" LabelEnabled="true" >
<vc:DataSeries.DataMappings>
<vc:DataMapping MemberName="AxisXLabel" Path="Label"></vc:DataMapping>
<vc:DataMapping MemberName="YValue" Path="YValue"></vc:DataMapping>
</vc:DataSeries.DataMappings>
</vc:DataSeries>
</vc:Chart.Series>
//legend 位置调整
<vc:Chart.Legends>
<vc:Legend VerticalAlignment="Center" HorizontalAlignment="Right"/>
</vc:Chart.Legends>
chart_month.ZoomingEnabled = true;//放大缩小
chart_month.IndicatorEnabled = true;//指示器
chart_month.ScrollEnable = true; //滚动条
Axis
startFromZero