Вопрос

In short, I'm trying to make a bar (using GWT's wrapper for HTML5 canvas) that will show something reasonable for a given value, no matter what the value of the bottom and top of the chart actually are. I'm assuming the best approach is logarithmic, but I'm completely open to any other solution.

Assumptions:

  • Our "bar" vertical, measuring 200 pixels high, 35 pixels wide.

  • We're showing a "site" versus it's parent "region". The units are ones of power (e.g. kW, MW, GW).

  • The "region" has a range of 1 kW to 55.19 GW. The average value is 27.6 MW.

  • Approximately 95% of sites within the region are much closer to 1 W than 55 GW, but the top 5% skew the average significantly.

  • The first site has a value of 12.67 MW. The second site has a value of 192.21 kW.

Obviously the second site wouldn't even register on a linear graph, while the first would register very low.

How can I make this bar more useful? For example, I'd like the top 5% of sites that skew the region's average to represent only a small portion (5%) of the total bar, while the other 95% should represent 95%.

Conceptual Image of Problem

The line in the lower area of the bar is the region average line, while the entire bar represents Minimum (bottom) to Maximum (top).

Current Java code using log10:

// BAR_GRAPH_WIDTH = 36, BAR_GRAPH_HEIGHT = 200
// regionNsp (MW): [min=0.0, max=55192.8, avg=27596.5] 
// siteNsp (MW) = 187.18
DrawingArea canvas = new DrawingArea(BAR_GRAPH_WIDTH, BAR_GRAPH_HEIGHT);
Rectangle bgRect = new Rectangle(1, 0, BAR_GRAPH_WIDTH - 1, BAR_GRAPH_HEIGHT); // backgound bar
bgRect.setFillColor("white");
canvas.add(bgRect);
int graphSize = (int)(BAR_GRAPH_HEIGHT / Math.log10(regionNsp.getMax()));
int siteHeight = (int)Math.log10(siteNsp - regionNsp.getMin()) * graphSize;
Rectangle valueRect = new Rectangle(1, BAR_GRAPH_HEIGHT-siteHeight, 35, siteHeight);
valueRect.setFillColor("lightgreen");
canvas.add(valueRect);

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top