Segmented bar chart in Winforms/DevExpress

試著忘記壹切 提交于 2020-01-05 04:06:00

问题


I'm trying to do a segmented bar chart of location and time for people.

The X-axis is time. The people are on the Y-axis, with a single horizontal bar for each person.

Each bar will be broken up into segments, with each segment giving the person's location, specified by color and by text label/annotation. Here's a crude hand-drawn example of what the end result should resemble:

The set of segments for each bar is not the same, which seems to be the root cause of my trouble. Every example of segmented bar chart that I have found uses the same set of segments for each bar, and just varies the size of each segment within the bar. In my example, each bar is pretty much independent of the other bars.

I haven't even been able to determine the exact name for this type of chart, so that has severely limited the googling.

This is for a WinForms app. I have an old version of DevExpress, 12.1, but so far I'm not finding anything in there that does what I need. I'm not wedded to DevExpress. Any freeware/inexpensive tool would be acceptable, as long as it can be shown in a WinForm.

Thanks in advance for any pointers.


回答1:


This is a MSChart ChartType.RangeBar.

I used this function to add the data points:

void addTask(Series s,  int who, DateTime startTime, 
                                 DateTime endTime, Color color, string task)
{
    int pt = s.Points.AddXY(who, startTime, endTime);
    s.Points[pt].AxisLabel = names[who];
    s.Points[pt].Label = task;
    s.Points[pt].Color = color;
}

Also a List<string> names.

Note that only one Series is used! Also that in Bar charts the x- and y-axis are switched!

If you want to use it and run into questions about styling it, feel free to ask.



来源:https://stackoverflow.com/questions/49580398/segmented-bar-chart-in-winforms-devexpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!