|
How Do I draw a chart as attached here? |
Posted by Ram on Oct-07-2014 14:17 |
|
Peter
As always, thanks for your support.
How can I draw a chart as I attached here?
Y-axis shows the Orders (service orders)
X-Axis shows the task status of each of the tasks that an order goes through
Coloring: Depending on whether a task is completed or not (for an Order), I need to color them.
Initially, I was thinking of StackedBar Chart. But, notice the colors (if I have to use a dataset for each task). They are not the same. Depending on the status of a task, the color can be different by Order.
Please suggest a solution for this.
thanks
Ram
|
Re: How Do I draw a chart as attached here? |
Posted by Peter Kwan on Oct-08-2014 03:59 |
|
Hi Ram,
If I were you, I would probably draw them as stacked bar layers, with each layer having
one bar. For example, consider the bar for Order 2. It can be drawn as (in Java):
//assume
// 0 = Not started yet = grey
// 1 = In process = yellow
// 2 = Jeopardy = orange
// 3 = Completed = green
// colors for the 4 states
int[] colors = {0xcccccc, 0xffff00, 0xff8800, 0x99ff99}
// names for the 4 states
string[] names = {"Not Started", "In Process", "Jeopardy", "Completed"};
//total 8 orders initialize the Chart.NoValue
double[] barData = new double[8];
for (int i = 0; i < barData.length; ++i)
barData[i] = Chart.NoValue;
// the task status for Order2
int[] tasks = {3, 3, 1, 1, 1, 0, 0}
int barIndex = 1; //the index of Order2 is 1 (the index of Order1 is 0)
BarLayer layer = c.addBarLayer2(Chart.Stack);
int currentTask = 0;
for (int i = 1; i <= tasks.length; ++i) {
if ((i == tasks.Length) || (tasks[i] != tasks[i - 1])) {
barData[barIndex] = i - currentTask;
layer.addDataSet(barData, colors[tasks[i - 1]], name[tasks[i - 1]]);
currentTask = i - 1;
}
}
The above code draws 1 bar for Order2. You can restructure it into a subroutine and
repeatedly call it to draw all the bars.
Hope this can help.
Regards
Peter Kwan |
|