图表 - 控制轴间距,间距和可见性 [英] Chart - Controlling axis interval, spacing and visibility

查看:283
本文介绍了图表 - 控制轴间距,间距和可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用图表窗口控件显示:



堆叠列

多个系列,每个系列约70个数据点。让我们说x:0 - 70.次Y轴。



POINT / LINE

显示0-3系列,每系列〜20个数据点。 X值为0-20,因此只覆盖图表的一部分。主Y轴。



我向x轴添加自定义标签。用户可以选择显示24,48或72个数据点。根据数据点的数量,x轴上的间隔会更改。

  24  - >间隔1 
48 - >间隔2
72 - >间隔3

第一个问题

我不想要主Y轴当点/线图不可见时显示。这是工作,但当我添加图表,整个图表移动和调整大小以适应轴。我想让图表保持静止,只是添加轴到该区域。查看图像24_Point和24_NoPoint之间的差异。



第二个问题

轴上的间隔似乎工作,但是数字被缩放并向上/向下移动,虽然似乎没有任何空间问题。有什么办法强制方向,字体和距离,使他们不移动?我看到固定字体的问题是,如果标签是关闭,它们将重叠或消失。在这种情况下,程序将完全控制标签的数量和图表的大小,所以它应该能够控制它。查看图片之间的差异24_Point和48_Point。



相关代码

 图表.ChartAreas [Default]。AxisX.CustomLabels.Clear(); 
if(PlotHours == 24){
interval = 1;
} else if(PlotHours == 48){
interval = 2;
} else {
interval = 3;
}

q = 0;

for(int i = 0; i = 72; i ++){
if(q == 0){
Chart.ChartAreas [Default]。AxisX.CustomLabels .Add((i-0.5,(i + 0.5),AxisLabels [i]);
}
if(q ==(interval-1)){
q = 0;
} else {
q ++;
}
}
Chart.ChartAreas [Default]。AxisX.Interval = interval;
Chart.ChartAreas [Default ] .AxisX.IntervalOffset = 1;

参考图片

原因I



24_Point


24_NoPoint


48_Point

$问题1:我不认为你可以让图表离开左边的空白,而是一个简单的解决方法应该做:显示Y轴,但使标签透明请参阅此处类似的示例!



问题2:我不认为你可以说服他们的标签足够的空间,当图表相信否则。它保留了较大和负值的空间,所以恐怕你必须允许一些额外的空间




  • 缩小字体尺寸或字体宽度

  • 减少标签数量

  • 放大图表区域


Using chart windows forms control to display:

STACKED COLUMN
Several series, ~70 datapoints per series. Let's say x: 0 - 70. Secondary Y-axis.

POINT/LINE
0-3 series displayed, ~20 datapoints per series. X-values are 0-20, so only covering part of the chartarea. Primary Y-axis.

I am adding custom labels to the x-axis. The user can choose to show 24, 48 or 72 datapoints. Depending on the number of datapoints, the interval on the x-axis is changed.

24 -> Interval 1  
48 -> Interval 2  
72 -> Interval 3  

FIRST PROBLEM
I do not want the primary Y-axis to be displayed when the point/line graphs are not visible. This is working, but when I add the graphs, the whole chartarea moves and resizes in order to fit in the axis. I would like the chartarea to remain still, just adding the axis to the area. See difference between images 24_Point and 24_NoPoint.

SECOND PROBLEM
The interval on the axis seems to work, but the numbers are scaled and moved up/down in order to fit in, even though there doesn't seem to be any space issues. Is there any way to force orientation, font and distance so they don't move? A problem I see with fixing the font, is that if the labels are to close, they will overlap or disappear. In this case though, the program will be in full control of the number of labels and size of the chartarea, so it should be able to control it. See difference between images 24_Point and 48_Point.

RELEVANT CODE

Chart.ChartAreas["Default"].AxisX.CustomLabels.Clear();
if (PlotHours == 24){
  interval = 1;
} else if (PlotHours == 48){
  interval = 2;
} else {
  interval = 3;
}

q = 0;

for (int i = 0; i=72; i++){
  if (q==0){
    Chart.ChartAreas["Default"].AxisX.CustomLabels.Add((i-0.5, (i+0.5), AxisLabels[i]);
  }
  if (q == (interval-1)){
    q = 0;
  } else {
    q++;
  }
}
Chart.ChartAreas["Default"].AxisX.Interval = interval;
Chart.ChartAreas["Default"].AxisX.IntervalOffset = 1;

REFERENCED IMAGES
The reason I have not removed the black areas of the pictures, is to keep them in scale.

24_Point
24_NoPoint
48_Point

解决方案

Problem 1: I don't think you can make the chart leave the empty space to the left. Instead a simple workaround should do: Display the Y-Axis but make the labels transparent! See here for a similar example! That will take the space without showing much more than maybe a few unobtrusive tick marks..

Problem 2: I don't think you can convince the labels that they have enough room, when the chart believes otherwise. It reserves the space for larger and for negative values, so I'm afraid you will have to allow for some extra space by

  • reducing font size or font width
  • reducing the number of labels
  • enlarging the chartarea

这篇关于图表 - 控制轴间距,间距和可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆