I'd start to use Dotnet.HighCharts controls to draw charts on my page in ASP.NET MVC app.
I used Google Charts, but they don't have enough functionality.
The task is to make charts with area ranges, step line and syncronized crosshair on multiple charts. Does DotNet.HighCharts do it?
By this time i did draw only area ranges.
If not, please give me a hint, which controls can do it.
Highcharts chart = new Highcharts("chart")
.InitChart(new Chart())
.SetTitle(new Title { Text = "July temperatures" })
.SetXAxis(new XAxis { Type = AxisTypes.Datetime })
.SetYAxis(new YAxis { Title = new YAxisTitle { Text = string.Empty } })
.SetLegend(new Legend { Enabled = false })
.SetTooltip(new Tooltip
{
Crosshairs = new Crosshairs(true),
Shared = true,
ValueSuffix = "°C"
})
.SetLegend(new Legend())
.SetSeries(new[]
{
new Series
{
Name = "Temperature",
Data = ChartsData.TemperatureVariationAverages,
ZIndex = 1,
Type = ChartTypes.Line,
PlotOptionsLine = new PlotOptionsLine
{
Marker = new PlotOptionsLineMarker
{
FillColor = Color.White,
LineWidth = 2,
LineColor = Color.Black
}
}
},
new Series
{
Name = "Range",
Data = ChartsData.TemperatureVariationRanges,
Type = ChartTypes.Arearange,
ZIndex = 0,
PlotOptionsArearange = new PlotOptionsArearange
{
LineWidth = 0,
LinkedTo = ":previous",
Color = Color.Green,
FillOpacity = 0.1,
}
},
new Series
{
Name = "Range3",
Data = ChartsData.TemperatureVariationRanges1,
Type = ChartTypes.Arearange,
ZIndex = 0,
PlotOptionsArearange = new PlotOptionsArearange
{
LineWidth = 0,
LinkedTo = ":previous",
Color = Color.Red,
FillOpacity = 0.1,
}
},
new Series
{
Name = "Range2",
Data = ChartsData.TemperatureVariationRanges2,
Type = ChartTypes.Arearange,
ZIndex = 0,
PlotOptionsArearange = new PlotOptionsArearange
{
LineWidth = 0,
LinkedTo = ":previous",
Color = Color.Yellow,
FillOpacity = 0.1,
}
}
});
Related
#Composable
fun SliderWithCustomTrackAndThumb() {
var sliderPosition by remember { mutableStateOf(0f) }
val interactionSource = MutableInteractionSource()
val colors = SliderDefaults.colors(thumbColor = Color.Red, activeTrackColor = Color.Red)
Column {
Text(text = sliderPosition.toString())
Slider(
modifier = Modifier.semantics { contentDescription = "Localized Description" },
value = sliderPosition,
onValueChange = { sliderPosition = it },
valueRange = 0f..100f,
onValueChangeFinished = {
// launch some business logic update with the state you hold
// viewModel.updateSelectedSliderValue(sliderPosition)
},
interactionSource = interactionSource,
thumb = {
SliderDefaults.Thumb(
interactionSource = interactionSource,
colors = colors
)
},
track = { sliderPositions ->
SliderDefaults.Track(
colors = colors,
sliderPositions = sliderPositions
)
}
)
}
}
The above composable function creates a sample slider with a custom thumb size. I want to increase the size of the track. how can I do that?
while you can't change the size size of the track set in the SlideDefaults.Track()component, you can always provide your own track implementation by copying the code from the SliderDefaults and change the track size there.
When I am trying to put some composable after RangeSlider, RangeSlider fills all width.
For example:
Row {
Text(text = "Test1")
var range by remember { mutableStateOf(-20f..20f) }
RangeSlider(
values = range, onValueChange = {
range = it
},
colors = SliderDefaults.colors(
thumbColor = MaterialTheme.colorScheme.onSecondaryContainer,
activeTrackColor = MaterialTheme.colorScheme.onSecondaryContainer
),
valueRange = -50f..50f
)
Text(text = "Test2")
}
In this case Text with Test2 is invisible.
When I am trying to force RangeSlider to be with some width, second slider is out of track. Also, Modifier.weigth() does not work.
Using another Layout that wraps RangeSlider solves the issue. Don't know why RangeSlider does not abide Modifier.weigth()
Row {
Text(text = "Test1")
var range by remember { mutableStateOf(-20f..20f) }
Row(
modifier= Modifier.weight(1f),
){
RangeSlider(
values = range, onValueChange = {
range = it
},
valueRange = -50f..50f
)
}
Text(text = "Test2")
}
I am generating a graph using Highcharts framework in one of the iOS projects using Swift language.
The function for generating graph is as follows.
private func createBUGraph()
{
let chartView = HIChartView(frame: self.chartHolderViewOutlet.bounds)
let options = HIOptions()
let title = HITitle()
title.text = "UTS"
options.title = title
let subtitle = HISubtitle()
subtitle.text = "Sales & Margin"
options.subtitle = subtitle
let xAxis = HIXAxis()
xAxis.categories = ["A", "B", "C", "D"]//
options.xAxis = [xAxis]
let yAxis = HIYAxis()
//yAxis.min = 0
yAxis.title = HITitle()
yAxis.title.text = "Sales"
yAxis.lineWidth = 1
let y2Axis = HIYAxis()
y2Axis.title = HITitle()
y2Axis.title.text = "Margin"
y2Axis.lineWidth = 1
y2Axis.tickPositions = [5,10,15,20]
y2Axis.opposite = true
options.yAxis = [yAxis,y2Axis]
let Sales = HIColumn()
Sales.name = "Sales"
Sales.data = [3, 2, 1, 3]
let SalesForecast = HIColumn()
SalesForecast.name = "Sales Forecast"
SalesForecast.data = 2, 3, 5, 7]
let Margin = HISeries()
Margin.name = "Margin"
Margin.data = [2.5, 1.2, 8.5, 5.5]
Margin.marker = HIMarker()
Margin.marker.lineWidth = 2
Margin.marker.symbol = "circle"
let MarginForeast = HISeries()
MarginForeast.name = "Margin Foreast"
MarginForeast.data = [3, 2.67, 3, 6.33] //
MarginForeast.marker = HIMarker()
MarginForeast.marker.lineWidth = 2
MarginForeast.marker.symbol = "circle"
options.series = [Sales, SalesForecast, Margin, MarginForeast]
chartView.options = options
self.chartHolderViewOutlet.addSubview(chartView)
}
While the graph is being loaded, I need to show a loading indicator in the graph. Is there any way to show that?
Or is there any way to know whether the graph has completed loading or not?
Thanks in advance
Add any loader when ever you call Chart method and stop loader when your charts load.
These are library for loader you can use any other or by default loader by apple.
1.https://github.com/ninjaprox/NVActivityIndicatorView
2.https://github.com/relatedcode/ProgressHUD
You may try this
func createBUGraph(completion: (Bool) -> ()) {
// do stuff here
completion(true)
}
createBUGraph(completion: { (success) -> Void in
// add loader
if success {
print("true")
// hide loader
}
})
You might as well use your own loader and show it when the chart is loading.
Then you can hide it using the chartViewDidLoad function from HIChartViewDelegate
API: https://api.highcharts.com/ios/highcharts/Protocols/HIChartViewDelegate.html#//api/name/chartViewDidLoad
I am trying to create a combined graph using HighCharts in a swift iOS project. The function for creating the graph is as follows.
private func createBUGraph()
{
let chartView = HIChartView(frame: self.chartHolderViewOutlet.bounds)
let options = HIOptions()
let title = HITitle()
title.text = "UTS"
options.title = title
let subtitle = HISubtitle()
subtitle.text = "Sales & Margin"
options.subtitle = subtitle
let xAxis = HIXAxis()
xAxis.categories = ["A", "B", "C", "D"]//
options.xAxis = [xAxis]
let yAxis = HIYAxis()
//yAxis.min = 0
yAxis.title = HITitle()
yAxis.title.text = "Sales"
yAxis.lineWidth = 1
let y2Axis = HIYAxis()
y2Axis.title = HITitle()
y2Axis.title.text = "Margin"
y2Axis.lineWidth = 1
y2Axis.tickPositions = [5,10,15,20]
y2Axis.opposite = true
options.yAxis = [yAxis,y2Axis]
let Sales = HIColumn()
Sales.name = "Sales"
Sales.data = [3, 2, 1, 3]
let SalesForecast = HIColumn()
SalesForecast.name = "Sales Forecast"
SalesForecast.data = 2, 3, 5, 7]
let Margin = HISeries()
Margin.name = "Margin"
Margin.data = [2.5, 1.2, 8.5, 5.5]
Margin.marker = HIMarker()
Margin.marker.lineWidth = 2
Margin.marker.symbol = "circle"
let MarginForeast = HISeries()
MarginForeast.name = "Margin Foreast"
MarginForeast.data = [3, 2.67, 3, 6.33] //
MarginForeast.marker = HIMarker()
MarginForeast.marker.lineWidth = 2
MarginForeast.marker.symbol = "circle"
options.series = [Sales, SalesForecast, Margin, MarginForeast]
chartView.options = options
self.chartHolderViewOutlet.addSubview(chartView)
}
The graph is drawing but I am stuck at the following issues
How to set automatic tick intervals in y2Axis according to the data[Opposite axis]?
How to set the series data to the y2Axis?
I tried to look for solution in highcharts documentation but I could not find any which will give me a solution.
Remove y2Axis.tickPositions = [5,10,15,20]
Set series.yAxis = 1 (API)
How to set automatic tick intervals in y2Axis according to the
data[Opposite axis]?
Remove tickPositions and use HIYAxis.linkedTo property.
How to set the series data to the y2Axis?
Use HISeries.yAxis property
API: https://api.highcharts.com/ios/highcharts/
Hi there I'm working with Charts library and I've build some graphs, but I want to do something special with a PieChart and I can't do it yet I don't know which could be the properties to setup my pie graph like y want. Ok then I want to setup a maximum value to 100 for the graph, by setting up this, I guess that my graph will show just the number that I'm trying to show in this case es 50 and the other part of the graph should look empty. I hope yo can help me.
This is what I have now the graph has just one Double value that value is 50
This is the way that the graph should look like
func createPieGraphRedemptions() {
var chart = PieChartView()
chart = PieChartView(frame: CGRect(x: 229, y: 40, width: 165, height: 165))
let yVals: [Double] = [50]
var entries = [ ChartDataEntry]()
for (i, v) in yVals.enumerated() {
let entry = ChartDataEntry()
entry.x = Double( i)
entry.y = v
entries.append( entry)
}
let set = PieChartDataSet( values: entries, label: "Pie Chart")
set.colors = [UIColor.red]
let data = PieChartData( dataSet: set)
//data.setDrawValues(false)
chart.data = data
chart.noDataText = "No hay datos disponibles"
chart.isUserInteractionEnabled = false
chart.legend.enabled = false
chart.chartDescription?.text = ""
chart.highlighter = nil
self.view.addSubview(chart)
}