score:7
i haven't used highchart but you can download examples from their codeplex page. it looks like both of your requirements can be achieved easily.
remove the "snittbetyg" button
disable the legend:
.setlegend(new legend { enabled = false });
add colours
for the series data use points instead of just the numbers:
data data = new data(new[]
{
new point { y = 1, color = system.drawing.color.red },
new point { y = 8, color = system.drawing.color.blue },
new point { y = 9, color = system.drawing.color.green },
new point { y = 6, color = system.drawing.color.black }
});
highcharts chart1 = new highcharts("chart1")
.setxaxis(new xaxis { categories = new[] { "ödmjukhet", "engagemang", "kompetens", "lönsamhet" } })
.setyaxis(new yaxis { title = new yaxistitle { text = "betygskalan" } })
.setseries(new series { data = data, name = "snittbetyg" })
.settitle(new title { text = "örebro statistik" })
.initchart(new chart { defaultseriestype = charttypes.column })
.setlegend(new legend { enabled = false });
there doesn't seem to be a built in way to make highchart automatically colour the bar based on the y-value. i believe you would have to pick the colour yourself, e.g:
private system.drawing.color getbarcolour(int value)
{
if (value < 5) return system.drawing.color.red;
if (value > 7) return system.drawing.color.green;
return system.drawing.color.orange;
}
public actionresult officestatistic()
{
{
var dataitems = new[] {1, 8, 9, 6};
data data = new data(
dataitems.select(y => new point {color = getbarcolour(y), y = y}).toarray()
);
highcharts chart1 = new highcharts("chart1")
.setxaxis(new xaxis { categories = new[] { "ödmjukhet", "engagemang", "kompetens", "lönsamhet" } })
.setyaxis(new yaxis { title = new yaxistitle { text = "betygskalan" } })
.setseries(new series { data = data, name = "snittbetyg" })
.settitle(new title { text = "örebro statistik" })
.initchart(new chart { defaultseriestype = charttypes.column })
.setlegend(new legend { enabled = false });
score:1
first, define a tuple list first item is for color and second item point value
list<tuple<string, object>> dataitems = new list<tuple<string, object>>();
i am passing value with swtich it is not neccessary
sqldatareader reader = mycomm.executereader();
if (reader.hasrows) { string colorname =""; while (reader.read()) { switch ((string)reader.getvalue(1)) { case "total employee(s)": colorname = "blue"; break; case "present": colorname = "green"; break; case "late": case"absent": case "during less": case "early going": colorname = "red"; break; case "leave": colorname = "orange"; break; default: colorname = "gray"; break; } dataitems.add(new tuple<string, object>(colorname, reader.getvalue(2))); }
now, finally add data into series object
new series{ name = "employees", data = new data( dataitems.select(y => new point { color = system.drawing.color.fromname(y.item1), y = (int)y.item2 }).toarray() ) }
Source: stackoverflow.com
Related Query
- Change color of bars depending on value in Highchart bar-chart with MVC3
- Adding round corners to Highcharts Bar Chart with stacked bars when value is 0
- Change color code on colum, depending on data value (highchartJS)
- How to change color of bar in column chart with different level of percentage in highcharts
- sort chart bar by color with the correct value from the text file using HIGHCHART,PHP
- Bar chart in High chart for indication of value with two colors in each bar where one color is always kept fixed
- Highcharts - Column Chart Drilldown, how to change the drilldown bar color based on some value
- Change the color of the bar chart based on the value
- Highcharts Change Bar Color Based on Value
- Highcharts dynamically change bar color based on value
- highchart change color of single bar in single category
- highcharts: column chart color change based on value
- Highcharts Change Bar Background Color Based on categories value
- how to change color of line chart in highchart based on a categorical column in r?
- Change color of stacked bar chart
- Setting color options on Highchart bar chart
- Highcharts column chart color by single color but with different brightness level as per respective column value
- How to create chart with highchart in which bar doesn't start from 0 in y axis?
- Multiple different chart types stacked, column type with y value as color
- how to change bar hover color of highchart dynamically?
- Pie chart with two circles need to change background color in inner circle
- highchart line chart last null value is not conected with line
- Change color of a column in highchart with a default color
- Showing a bar chart with expected value and current value for a series
- Using an editable table with HighChart and having the chart refresh with change
- highchart drill down break bar chart after change title
- I want to display bar with minPointLength dynamically when value in null in highchart
- Highchart changing crosshair color depending on value of y-axis
- HighCharts Create gradiance decress color to blur for each value on bar chart
- How can I change the background color of horizontal bar if date value is less than to current date?
More Query from same tag
- Multiple plotLines using options in HighCharts
- highcharts change rendered image source on click
- Hide stacklabel if zero
- highcharts v3.0Beta bubblechart not rendering. Possible bug?
- show highcharts node text from beginning if the text is to long
- Highcharts-Ng and Broken Drilldown
- highcharts legend position wrong when align ='left' or 'right'?
- What are the differences between tickinterval and minTickInterval in HighCharts? Please explain
- Highcharts - add minor ticks on zoom?
- Highcharts Y Axis Tick Marks not setting
- Jarviswidget fullscreen not rendered properly with Highchart
- Is it possible to have an upColor on a Area graph using Highcharts?
- How to set min and max values for an axis?
- highcharts - create a total sumline of an existing serie
- Angular-Highcharts: Cannot read property of 'Apartment' of undefined of an object
- Highcarts function not being recognized
- Highchart value series mapping
- Entire Highchart API calling from JSON file
- Highcharts - DataLabels connector customization {Straight line}
- Updating fontsize with highcharts using zoomtype
- Generate chart from html table : JQuery
- Fill different colors in boxplot chart Highcharts
- Highcharts: redraw chart after changing options
- How to format the following JSON data using Javascript/Jquery?
- HighStock BaseSeries
- How to draw a line between 2 different area charts for same category (x axis) in highcharts?
- Highcharts second series name labeled to 'Series 2'?
- Adding null values to a pandas dataframe
- Style highcharts x and y axis
- Highstock title and subtitle overlap