栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

怎么更改坐标轴标题access

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

怎么更改坐标轴标题access

I just can't find a solution for changing the format of the y-axis tick labels.

Now I get labels like 0.03 and 0.035. But I always need three digits behind the decimal point.

The big question is, how to access the label format?

This is my code:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Forms;

using System.Windows.Media;

using LiveCharts;

using LiveCharts.Helpers;

using LiveCharts.Wpf;

using LiveCharts.Wpf.Charts.Base;

using Brushes = System.Windows.Media.Brushes;

using Color = System.Windows.Media.Color;

using MessageBox = System.Windows.Forms.MessageBox;

namespace LiveAnalysis

{

public partial class Form1 : Form

{

List xvals = new List();

List yvals = new List();

private int _amountValues;

private int _startValue;

private List _yvalsRange;

public Form1()

{

InitializeComponent();

// event

cartesianChart2.DataClick += CartesianChart1OnDataClick;

hScrollBar1.ValueChanged += (sender, e) => hScrollBar1_ValueChange(sender, e, hScrollBar1.Value);

// get original data

using (var db = new Analysis.DataClasses1DataContext())

{

var lttResults = db.LttResults;

var par1 = 0.0;

foreach (var data in lttResults)

{

if (data.GatewayEventType == 41)

par1 = data.FloatValue;

if (data.GatewayEventType != 42) continue;

var par2 = data.FloatValue;

var diff = Math.Round(par1 - par2, 3);

yvals.Add(diff);

xvals.Add(data.DateTime);

}

}

// chart settings

ChartSettings();

}

private void ChartSettings()

{

// performance

cartesianChart2.DisableAnimations = true;

cartesianChart2.DataTooltip = null;

cartesianChart2.Hoverable = false;

_startValue = 0;

_amountValues = 400;

_yvalsRange = yvals.GetRange(_startValue, _startValue + _amountValues);

// series setting

ScatterSeries scatterSeries1 = new ScatterSeries("Series1");

cartesianChart2.Series.Add(scatterSeries1);

scatterSeries1.Values = _yvalsRange.AsChartValues();

scatterSeries1.MaxPointShapeDiameter = 10;

scatterSeries1.Title = "Series1";

cartesianChart2.AxisX.Add(new Axis

{

Name = "xAxis",

Title = "DateTime",

FontSize = 22,

Foreground = System.Windows.Media.Brushes.Black,

MinValue = 0,

MaxValue = _amountValues,

});

cartesianChart2.AxisY.Add(new Axis

{

Name = "yAxis",

Title = "Time difference",

FontSize = 22,

Foreground = System.Windows.Media.Brushes.Black,

MinValue = -0.025,

MaxValue = 0.04,

});

}

private void CartesianChart1OnDataClick(object sender, ChartPoint chartPoint)

{

label1.Text = $@"You clicked: {chartPoint.X},{chartPoint.Y}";

}

private void button2_Click_1(object sender, EventArgs e)

{

}

private void hScrollBar1_ValueChange(object sender, EventArgs e, int value)

{

RedrawGraph(value);

}

private void RedrawGraph(int value)

{

_startValue = value * 10;

_yvalsRange = yvals.GetRange(_startValue, _startValue + _amountValues);

cartesianChart2.Series[0].Values = _yvalsRange.AsChartValues();

cartesianChart2.AxisX[0].MinValue = _startValue;

cartesianChart2.AxisX[0].MaxValue = _startValue + _amountValues;

}

}

}

解决方案

The answer is:

Func formatFunc = (x) => string.Format("{0:0.000}", x);

cartesianChart2.AxisY.Add(new Axis

{

LabelFormatter = formatFunc,

});

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/911286.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号