noe*_*cus 5 c# mschart winforms
我有一个描绘人数的条形图.当只有少数人时,Y轴显示值:0.5,1,1.5等......看起来有点傻.
AxisY.LabelStyle.Interval = 1),但是如果有100个人则不起作用AxisY.Maximum = 10,但这不适用于100人AxisY.LabelStyle.Format = {#},但是它会显示[1,1,2,2],因为它会对每个标签进行舍入我意识到我可以根据内容动态地利用前两个选项中的任何一个,但想知道是否有一种自动方式使标签"仅整数"?
您可以使用比例分隔符在同一轴上显示小数字和大数字:
// Enable scale breaks
chart1.ChartAreas["Default"].AxisY.ScaleBreakStyle.Enabled = true;
// Set the scale break type
chart1.ChartAreas["Default"].AxisY.ScaleBreakStyle.BreakLineStyle = BreakLineStyle.Wave;
// Set the spacing gap between the lines of the scale break (as a percentage of y-axis)
chart1.ChartAreas["Default"].AxisY.ScaleBreakStyle.Spacing = 2;
// Set the line width of the scale break
chart1.ChartAreas["Default"].AxisY.ScaleBreakStyle.LineWidth = 2;
// Set the color of the scale break
chart1.ChartAreas["Default"].AxisY.ScaleBreakStyle.LineColor = Color.Red;
// Show scale break if more than 25% of the chart is empty space
chart1.ChartAreas["Default"].AxisY.ScaleBreakStyle.CollapsibleSpaceThreshold = 25;
// If all data points are significantly far from zero,
// the Chart will calculate the scale minimum value
chart1.ChartAreas["Default"].AxisY.ScaleBreakStyle.IsStartedFromZero = AutoBool.Auto;
Run Code Online (Sandbox Code Playgroud)
此代码示例直接从mschart 示例中提取,如果您使用图表控件,则必须下载这些示例。