I am using Amibroker. I would like to make a plot of the array PCT_CLOSE such that the color is red when PCT_CLOSE<=25, yellow when between 25 and 50, Green when PCT_CLOSE>=50.
Right now, due to the IIF function constraint, I can only create a plot with 2 colors. Below is how I did it with 2 colors.
Plot( PCT_CLOSE , "CLOSE", IIf(PCT_CLOSE<=50, colorRed, colorYellow), styleNoTitle | styleLine | styleThick );
I will answer my own question.
Color criteria in question:
color is red when PCT_CLOSE<=25, yellow when between 25 and 50, Green
when PCT_CLOSE>=50
The key is to have nested IIF statements. Put IIF inside IIF.
Here is the corresponding code;
color = IIf(PCT_CLOSE<=25, colorRed, IIf(PCT_CLOSE>50, colorGreen, colorYellow) )
Related
I am trying to get a barchart to render different color based upon the value (meaning if one line is value 8 i need to get it with everything under 6 is red, 6-7 is green and the rest i green).
For example
score 8 == [red color up to 5 | blue color from 6 to 7 | green color from 8 to 10]
score 6 == [red color up to 5 | blue color from 6 to 7 ]
etc...
I spent too much time on this browsing through the examples on highcharts trying out different jsfiddles... I assume that it is an easy fix but something i have overlooked
Any ideas?
Highcharts provide color zones API to render different colors based on values.
JSFiddle
I have provided a plotOption example as below. Based on your requirement the zones would be
plotOptions: {
column: {
zones: [
{
value: 6, // Values up to 6 and not including will have red color
color: 'red' // ... have the color blue.
},
{
value: 8
color: 'blue'
},
{
color: 'green'
}
]
}
}
I am writing a script that colors cells in a Google spreadsheet using the Range.setBackground(color) method. I want to use one of the preset fill colors, but I am having a hard time finding the exact color codes. Hex, RGB, I just want an official list.
#000000 #434343 #666666 #999999 #B7B7B7 #CCCCCC #D9D9D9 #EFEFEF #F3F3F3 #FFFFFF
#980000 #FF0000 #FF9800 #FFFF00 #00FF00 #00FFFF #4A85E8 #0000FF #9900FF #FF00FF
#E6B8AF #F4CCCC #FDE5CD #FFF3CC #D9EBD3 #D1E0E3 #C9DBF8 #CFE2F3 #D9D3E9 #EBD1DC
#DD7D6B #EB9899 #F9CB9C #FFE598 #B6D7A8 #A2C4CA #A4C2F4 #9EC5E9 #B4A7D6 #D5A6BD
#CC4124 #E06665 #F7B16B #FFD966 #92C47D #75A5AF #6D9EEC #6EA8DC #8E7CC3 #C27BA0
#A61B00 #CC0000 #E69038 #F1C231 #6AA84E #44818E #3B77D8 #3C84C6 #674EA7 #A64C79
#841F0B #990000 #B45F04 #BF9000 #38761C #114F5C #0F55CC #095294 #351A75 #741A47
#5B0D00 #660000 #783E02 #7F5F00 #274E11 #0A343C #1B4487 #053762 #1F104C #4C0F2F
I want to draw clickable grid objects inside zoomable scrollview taken datas from remote json data my example remote json file data under below;
Json data explode means;
0 = Empty object not show object in view
1 = Show object with title and background not empty object
[
{
"Base": "A",
"Seats": "A1*0*,A2*1*,A3*1*,A4*1*,A5*0*,A6*0*"
},
{
"Base": "B",
"Seats": "B1*1*,B2*1*,B3*1*,B4*0*,B5*0*,B6*0*,B7*1*"
},
{
"Base": "C",
"Seats": "C1*0*,C2*0*,C3*0*,C4*0*,C5*0*,C6*0*,C7*1*,C8*1*,C9*1*,C10-C11*1*"
}
]
Also i have remote json parsing codes i take json arrays to my under below arrays successfuly ;
var Base = [""]
var Seats = [""]
Will shows in my zoomable scrollview inside that json like under below;
1 2 3 4 5 6 7 8 9 10 11
A A2 A3 A4
B B1 B2 B3 B7
C C7 C8 C9 C10-C11
Not empty objects like an A2,A3,A4 must be square width : 20 height : 20 with green background clickable object. When i click in my view i can change backgroud color it to like red etc..
Also C10-C11 MUST BE double widthx 2 so that seats double seats.you can see comming json value.
How can i do this i try collectionview but dont have zoom feature ? I think i need to do with cgrect somethings ?
Thank you !
Is your json file format fixed or can it be customised ? it does not seems well prepared for what you expect.
You don't need to have A B C section and repeat the Section name in the grid item. As in the Battleship game, the name of each cell is expressed by the column and row title. So if you can format this:
[{ "A":"0","1","1","1","0","0"... },{ "B":"1","1","1","0"...},{"C" : ..."0","1","1","1",**"2"**}]
(NB: this works only if seat can be only doubled horizontally)
Now you create two arrays : One with bases names by getting the dictionary (from the JSON) keys:
let bases = jsonDict.allKeys
and an other with all the data in it: let seats = jsonDict
Now you should loop twice:
First in the base array then in the seats array for each base entry.
Each time you check the value of seats[bases[index in base loop]][index in the seat loop] to get the value. If it is 0 you continue, if it is 1 you create a square view and add it to the scrollview. the same if it 2 with a doubled width square view.
To set the position of the square view (or rectangle if value is 2) you use the loop index. Bases are rows and seats are columns. The anchor point of the square view will be x:0 for index 0 in the seats loop and y:0 for the A base, will be x:20 * loop index of the seats loop and y: 20 * loop index of the bases loop. Width will be value * 20 and height always 20.
And then you manage clicks and colour states in the square view itself by handling touch event on it.
Don't forget to set the contentSize of your scrollview to CGSize(width: base[0].count * 20, height: bases.count * 20
Let me know if it help.
I have a button in the storyboard, I gave it a color magnesium. I am doing some programming on the button which will change its color on certain situations.
I like the original color of the button in the storyboard and I want to return back to that color at some event.
Now the problem is that color I am using doesn't have a text name (yellowcolor, purplecolor) in UIColor and I can't find the RGB values from the storyboard color picker.
Any ideas?
Follow this screen shot. I am on Windows 8 right now so i just edited the picture but it will certainly give you the way to achieve what you want.
(I combined two DIFFERENT images. So don't freak out. Sorry.)
Xcode->Select Object->Attributes Inspector->Text Color->Other->Color Sliders->Dropdown Menu->RGB Sliders
You can do this to get the RBG from UIColor:
CGFloat red = self.btn.backgroundColor.CIColor.red;
CGFloat blue = self.btn.backgroundColor.CIColor.blue;
CGFloat green = self.btn.backgroundColor.CIColor.green;
CGFloat alpha = self.btn.backgroundColor.CIColor.alpha;
What is the best way to achieve a chart with multiple types when it should include a type that has the following kind of visual presentation.
| yellow |blue| gray | yellow | gray |
i.e. a type which is one dimensional (but visually has height), and the color indicates 'y' (which here consists of categories: yellow, blue, gray)
You should also be able to stack those:
| radical | senseless | high tension |
| yellow |blue| gray | yellow | gray |
I can achieve this with having a chart typed column with a series for each category:
http://jsfiddle.net/RCnYV/
But how can I also add another chart type above that, like:
yAxis (only for the line)
^ ___
|------- ___________________________ ____/
| \__________/ \/
| radical | senseless | high tension |
| yellow |blue| gray | yellow | gray |
-----------------------------------------------------------> xAxis (shared)
So the line series should be above (not hovering over) the others. Note that the xAxis is shared between all of the series, i.e. all of the series have exactly as many data points. It is just that some of the series are presented as type 'line', and others with the new type (that I don't know good name for, ribbon?).
Also what other ways are there to create a similar chart? One problem with the above is that I need to create one series for each catalog, that is 2 * series in total, and not just two as would be the case with basic chart.
Are you looking for something like this # http://jsfiddle.net/jugal/cABfL/ ?
You can stack the charts by specifying heights for your yAxis, and manipulating its top so that they stack one over the other
yAxis: [{
top: 300,
lineWidth: 2,
offset: 0,
height: 200,
tooltip: {
enabled: true,
formatter: function() {
return this.series.name + ": " + $wnd.Highcharts.numberFormat(this.y, 2);
}
}
},
{
height: 200,
lineWidth: 2,
offset: 0,
tooltip: {
enabled: true,
formatter: function() {
return this.value + 50;
}
}
}],
Similar stacking example is available # http://www.highcharts.com/stock/demo/candlestick-and-volume
EDIT
To answer to the second part of the question (Also what other ways are there to create a similar chart?). There isn't anything out of the box that highchart seems to bring to the table for such a visualization, so you would need to work yourself around the existing lines and columns to get this visualization.
This is how I went about it.
I tried using the stacked bar chart for each ribbon, hence would need 2 series, 1 for the line and 1 each for both the ribbons. But after giving it a try, turned out the bar chart is nothing but a rotated column chart (at least a sort of), it seems to have the vertical axis as the X and horizontal one as Y, hence it messes up any other chart, i.e. the line chart gets messed up as it wants the horizontal to be the X.
Basically using a bar chart didn't take me much far. I went ahead using the line chart (With a very thick line lineWidth:50) and drew a horizontal (Constant Y for each point) line chart with one series for each section of the ribbon, hence being able to give each section different color. Each ribbon would need a separate Y-axis, with different offset as mentioned above. Also removed all the tooltip, Y-axis labels and grid lines, to make it look as different from a line chart and more like the ribbon. Tooltip may be needed, but line charts give tooltip for points, in our case we want tooltip on section between two points, hence wrote a mouseOver event handler and calculated the length of the section in there. The only part that was hurting now was creating a series for each section of the ribbon, so went ahead and wrote the following utility function that accepted a list of values, basically the x intercepts for each section (you can improvise it to take section length instead) and returned an array of series.
// usage: createSeries([0, 3, 4, 6], 1)
// Creates 4 series and assigns them all to yAxis 1
// you can extend this to take colors etc too, as per requirement
function createSeries(data, yAxisIndex) {
var i;
var series = [];
for (i = 0; i < data.length - 1; i++) { // Node lenghth-1
var start = data[i];
var end = data[i + 1];
series.push({
yAxis: yAxisIndex,
animation: false,
stack: 0,
data: [[start, 0], [end, 0]],
lineWidth: 50,
marker: {
enabled: false
},
tooltip: {
pointFormat: function() {
return "";
}
},
events: {
mouseOver: function() {
alert(this.data[1].x - this.data[0].x);
}
},
showInLegend: false
});
}
return series;
}
All that was needed was to push these series into the existing series and then feed it to the highchart constructor.
Final jsFiddle: http://jsfiddle.net/jugal/cABfL/