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
- PHP and Highcharts
- Putting the Z-Coordinate in the Highcharts Tooltip
- How to get work range selector with Highcharts with a function?
- If sentence Highcharts
- Highcharts function not covered with unit tests with Karma + Jasmine
- How to add custom content that spans across multiple ticks in highcharts
- Adding Highchartsevent after creation
- How to set highchart boxplot size
- Set a minimal default range for a column chart in Highcharts
- Highcharts -- Array not assigned without alert message
- Create spline chart from edge to edge of graph
- Update Line Chart (High Charts) after applying filter
- highcharts build map with a set of values and display another set of values as labels
- Set cell size in Heat Map. Highcharts
- how to sum up all values with same keys in an object inside an array and get their average
- How to hide Axes Crosshairs by onclick event in Highcharts
- Convert Culture.DateTimeFormat to HighChart's xDateFormat string
- Semi-circle donut pie chart with labels (data names) and %-ages on the pie ... and data numbers on mousehover
- highcharts remove redundant data points to improve speed
- How to break highchart bars for extreme values
- How to use a different formatter on Highcharts in each curve of the same graphic?
- When using canvg to convert Highchart SVG into PNG, all text appears twice - how to solve?
- Highcharts Highmaps prevent initial zoom effect
- Highchart heatmap: select all cells on click of button or checkbox
- How to add comma in stacked column highchart in indian format?
- How to convert the datetime.date to Date.UTC using python
- Meteor: Display API result data on highcharts
- Highcharts.js - Event when any point is clicked
- How do you insert custom dynamic values to subtitle?
- Create a highchart for every dataset in R