I'm trying to add a manually created chart to a placeholder but when i look at the output all i get is a blank.. I am getting the data from a dataset datatable that is the last table in the dataset. I only has two colums "Industry" and "industryTheta" any help is much appreciated. I'm not sure whats wrong here
Dim chrt As New Chart
chrt.ID = "dynChart"
chrt.Height = Unit.Pixel(1000)
chrt.Width = Unit.Pixel(1000)
chrt.BackImageWrapMode = ChartImageWrapMode.Scaled
chrt.BorderlineColor = Color.Black
chrt.ImageLocation = "~/TempImages/ChartPic_#SEQ(300,3)"
chrt.BackGradientStyle = GradientStyle.None
Dim ca As New ChartArea
ca.Name = "IndustryTheta"
ca.AlignmentOrientation = AreaAlignmentOrientations.All
ca.AlignmentStyle = AreaAlignmentStyles.All
ca.Area3DStyle.Enable3D = True
ca.Area3DStyle.LightStyle = LightStyle.Realistic
ca.Area3DStyle.Inclination = 30
ca.BackHatchStyle = ChartHatchStyle.None
chrt.ChartAreas.Add(ca)
Dim sers As New Series
sers.Name = "IndustryName"
sers.ChartType = SeriesChartType.Pie
sers.Label = "#VALX, #PERCENT"
sers.LabelAngle = 90
sers.IsXValueIndexed = True
sers.IsValueShownAsLabel = True
sers.XAxisType = AxisType.Primary
sers.YAxisType = AxisType.Primary
sers.YValuesPerPoint = 1
sers.XValueMember = "Industry"
sers.YValueMembers = "IndustryTheta"
chrt.Series.Add(sers)
For Each dr As DataRow In table.Rows
Dim p As New DataPoint
p.SetValueY(Convert.ToInt32(dr.Item("IndustryTheta")))
p.AxisLabel = dr.Item("Industry")
sers.Points.Add(p)
Next
chrt.DataBind()
dynamicGrids.Controls.Add(chrt)
Most likely your problem is with when you are calling your function in the page life cycle. Please refer to this information to learn more about it.
In order to address dynamic controls in asp.net please refer to this for more information on dynamic controls.
Related
Hi I am trying to add two controls into a table cell the code is below. Unfortunately the hyperlink is always outside the table cell, whilst the label is inside. Individually they are working fine but together not so good, could somebody help me please.
Dim iCell As New TableCell
Dim lbl As New Label
lbl.Height = Unit.Pixel(100)
lbl.Width = Unit.Pixel(150)
lbl.Style.Add("padding", "5px")
lbl.Style.Add("border-radius", "10px")
lbl.BorderStyle = BorderStyle.Solid
lbl.BorderWidth = Unit.Pixel(1)
lbl.BorderColor = Color.Black
lbl.Font.Size = 9
lbl.Text = "Event: " & dt.Rows(y).Item("eventname")
lbl.BackColor = ColorTranslator.FromHtml(dt.Rows(y).Item("roomcolor"))
Dim hyp As New HyperLink
hyp.Font.Size = 9
hyp.Text = "Modify"
hyp.NavigateUrl = "modify.aspx"
iCell.Controls.Add(lbl)
iCell.Controls.Add(hyp)
iCell.VerticalAlign = VerticalAlign.Top
tRow.Cells.Add(iCell)
I am trying to add markers on my stacked bar chart programmatically and they do not seem to show up. In reality, I need to show a marker on the average of the datapoint but right now, I cannot even show a simple marker on the chart.
What am I doing wrong ?
Code:
Dim chart As New Chart
chart.ID = DtDistinct.Rows(I)("CourseSisID")
Dim chartareas As New ChartArea
chart.ChartAreas.Add(chartareas)
chart.Series.Clear()
chart.DataBindCrossTable(DtRecords.DefaultView, "Outcomescore", "ShortName", "RecordsPerGroup", "")
chart.ChartAreas(0).AxisY.Interval = 1
chart.ChartAreas(0).AxisY.Enabled = AxisEnabled.False
chart.Palette = ChartColorPalette.None
chart.PaletteCustomColors = New Color() {ColorTranslator.FromHtml("#DF5B59"), ColorTranslator.FromHtml("#E0D773 "), ColorTranslator.FromHtml("#8AAC53"), ColorTranslator.FromHtml("#6A843F")}
chart.ChartAreas(0).AxisX.MajorGrid.Enabled = False
chart.ChartAreas(0).AxisY.MajorGrid.Enabled = False
For Each cs As Series In chart.Series
cs.ChartType = SeriesChartType.StackedBar
cs.Points().FindMaxByValue.MarkerColor = Color.AliceBlue
cs.Points().FindMaxByValue.MarkerSize = 13
cs.Points().FindMaxByValue.MarkerStyle = MarkerStyle.Diamond
Next
pnlcharts.Controls.Add(chart)
Here is an image of what I am trying to do. I know that the above code will not give me the below image but I was trying to find a workaround with the above code, before I realized that markers cannot appear on bar charts.
I would like to see that striped line on the bar chart. The striped line should appear on the calculated average of the points.
So, an another way I could do was to use annotations since markers are not supported by stackedbar charts. I wrote the following code to add an annotation line, but it still does not give me the output I need only because I do not know how to do it for each Y value on the chart.
Here is my code:
Dim chart As New Chart
chart.ID = DtDistinct.Rows(I)("CourseSisID")
Dim chartareas As New ChartArea
chart.ChartAreas.Add(chartareas)
chart.DataBindCrossTable(DtRecords.DefaultView, "OutcomeScore", "ShortName", "RecordsPerGroup", "Label=RecordsPerGroup")
chart.Palette = ChartColorPalette.None
chart.PaletteCustomColors = New Color() {ColorTranslator.FromHtml("#DF5B59"), ColorTranslator.FromHtml("#E0D773 "), ColorTranslator.FromHtml("#8AAC53"), ColorTranslator.FromHtml("#6A843F")}
chart.ChartAreas(0).AxisX.MajorGrid.Enabled = False
chart.ChartAreas(0).AxisY.MajorGrid.Enabled = False
Dim charttitle As New Title
charttitle.Text = DtDistinct.Rows(I)("CourseSisID")
chart.Titles.Add(charttitle)
For Each cs As Series In chart.Series
cs.ChartType = SeriesChartType.StackedBar
Next
Dim ann1 As New VerticalLineAnnotation()
ann1.AxisX = chart.ChartAreas(0).AxisX
ann1.AxisY = chart.ChartAreas(0).AxisY
ann1.IsSizeAlwaysRelative = False
ann1.X = chart.DataManipulator.Statistics.Mean(chart.Series(0).Name)
ann1.IsInfinitive = True
ann1.ClipToChartArea = chart.ChartAreas(0).Name
ann1.LineColor = Color.Coral
ann1.LineWidth = 3
ann1.AnchorX = 1
ann1.AnchorY = 5
chart.Annotations.Add(ann1)
ann1.LineDashStyle = ChartDashStyle.Dash
pnlcharts.Controls.Add(chart)
Here is what I get with the above code:
Here is what I need : Notice how the strip line is at a different value for each bar.
Dim annotation2 As New LineAnnotation()
annotation2.IsSizeAlwaysRelative = False
annotation2.AxisX = chart.ChartAreas(0).AxisX
annotation2.AxisY = chart.ChartAreas(0).AxisY
annotation2.Height = 1
annotation2.Width = 0
annotation2.LineWidth = 1.5
annotation2.StartCap = LineAnchorCapStyle.None
annotation2.EndCap = LineAnchorCapStyle.None
annotation2.AnchorX = AvgVar
annotation2.ToolTip = "Average=" & AvgVar
Select Case row
Case 1
annotation2.AnchorY = 4.5
Case 2
annotation2.AnchorY = 3.5
Case 3
annotation2.AnchorY = 2.5
Case 4
annotation2.AnchorY = 1.5
Case 5
annotation2.AnchorY = 0.5
End Select
' <- your point
annotation2.LineColor = Color.Gray
annotation2.LineDashStyle = ChartDashStyle.Dash
' <- your color
chart.Annotations.Add(annotation2)
I'm using Devexpress Xtragrid TileView module.
Basically I want my code works like this :
user input member ID on the upper left textbox and press load.
If they exists, then a Tile will be appeared.
A tile should contain : Name, Status, member ID and a photo.
If user press load again (either same ID or another ID) a Tile will be added also, and so on. Unless they press Clear & Load, It should be only 1 latest tile left.
So, I'm able to produce up to Step 3.
But I couldn't be able to load the picture.
The picture itself, It's not a byte array. It's a Image path.
e.q : D:/test/1.jpg
So, how do I load the picture?
Protected Overridable Sub InitData()
Try
Dim homesTable = ds.Tables(0)
homesTable.Columns.Add("ImageCol")
For Each row_Renamed As DataRow In homesTable.Rows
Dim img As Image = Image.FromFile(row_Renamed("memberPhoto")) 'I tried this, but didn't work
row_Renamed("ImageCol") = img
Next row_Renamed
GridControl1.DataSource = homesTable
Catch
End Try
End Sub
Private Sub setupTile()
'For i = 0 To j - 1
Try
TileView1.BeginUpdate()
'TileView1.DataSource = ds.Tables(0)
TileView1.OptionsTiles.RowCount = 3
TileView1.OptionsTiles.Padding = New Padding(20)
TileView1.OptionsTiles.ItemPadding = New Padding(10)
TileView1.OptionsTiles.IndentBetweenItems = 20
TileView1.OptionsTiles.ItemSize = New Size(320, 170)
TileView1.Appearance.ItemNormal.ForeColor = Color.White
TileView1.Appearance.ItemNormal.BorderColor = Color.Transparent
'Setup tiles template
Dim leftPanel As New TileViewItemElement()
Dim splitLine As New TileViewItemElement()
Dim nameCaption As New TileViewItemElement()
Dim nameValue As New TileViewItemElement()
Dim statusCaption As New TileViewItemElement()
Dim statusValue As New TileViewItemElement()
Dim RGPCaption As New TileViewItemElement()
Dim RGPvalue As New TileViewItemElement()
Dim imageTile As New TileViewItemElement()
TileView1.TileTemplate.Add(leftPanel)
TileView1.TileTemplate.Add(splitLine)
TileView1.TileTemplate.Add(nameCaption)
TileView1.TileTemplate.Add(nameValue)
TileView1.TileTemplate.Add(statusCaption)
TileView1.TileTemplate.Add(statusValue)
TileView1.TileTemplate.Add(RGPCaption)
TileView1.TileTemplate.Add(RGPvalue)
TileView1.TileTemplate.Add(imageTile)
'
'nameValue.Text = ""
'statusValue.Text = ""
'RGPvalue.Text = ""
'imageTile.Image = Nothing
'
leftPanel.StretchVertical = True
leftPanel.Width = 190
leftPanel.TextLocation = New Point(-10, 0)
leftPanel.Appearance.Normal.BackColor = Color.FromArgb(58, 166, 101)
'
splitLine.StretchVertical = True
splitLine.Width = 3
splitLine.TextAlignment = TileItemContentAlignment.Manual
splitLine.TextLocation = New Point(190, 0)
splitLine.Appearance.Normal.BackColor = Color.White
'
nameCaption.Text = "Name"
nameCaption.TextAlignment = TileItemContentAlignment.TopLeft
nameCaption.Appearance.Normal.FontSizeDelta = -1
'
nameValue.Column = TileView1.Columns("preferredName")
nameValue.AnchorElement = nameCaption
nameValue.AnchorIndent = 2
nameValue.MaxWidth = 200
nameValue.Appearance.Normal.FontStyleDelta = FontStyle.Bold
'nameValue.Text = ds.Tables(0).Rows(i)("preferredName").ToString
'
statusCaption.Text = "Status"
statusCaption.AnchorElement = nameValue
statusCaption.AnchorIndent = 14
statusCaption.Appearance.Normal.FontSizeDelta = -1
'
statusValue.Column = TileView1.Columns("memberStatus")
statusValue.AnchorElement = statusCaption
statusValue.AnchorIndent = 2
statusValue.Appearance.Normal.FontStyleDelta = FontStyle.Bold
'statusValue.Text = ds.Tables(0).Rows(i)("memberStatus").ToString
'
RGPCaption.Text = "RGP"
RGPCaption.AnchorElement = nameValue
RGPCaption.AnchorIndent = 65
'RGPCaption.TextLocation
'RGPCaption.Appearance.Normal.FontSizeDelta = -1
RGPCaption.Appearance.Normal.Font = New Font("Segoe UI Semibold", 12.0F, System.Drawing.FontStyle.Regular)
'
RGPvalue.Column = TileView1.Columns("code")
RGPvalue.AnchorElement = RGPCaption
RGPvalue.AnchorIndent = 1
RGPvalue.TextAlignment = TileItemContentAlignment.BottomLeft
RGPvalue.Appearance.Normal.Font = New Font("Segoe UI Semilight", 25.75F, System.Drawing.FontStyle.Regular)
'RGPvalue.Text = ds.Tables(0).Rows(i)("code").ToString
'
imageTile.Column = TileView1.Columns("ImageCol")
imageTile.ImageSize = New Size(120, 170)
imageTile.ImageAlignment = TileItemContentAlignment.MiddleRight
imageTile.ImageScaleMode = TileItemImageScaleMode.Stretch
imageTile.ImageLocation = New Point(12, 0)
Catch ex As Exception
XtraMessageBox.Show(ex.Message)
Finally
TileView1.EndUpdate()
End Try
'Next
End Sub
Private Sub loadBtn_Click(sender As Object, e As EventArgs) Handles loadBtn.Click
initData()
setupTile()
End Sub
Maybe it's too late but in my case only need to read file from disk and assign to a byte() column.
First of all, table column should be byte array so replace:
homesTable.Columns.Add("ImageCol")
for:
homesTable.Columns.Add(New DataColumn("ImageCol", GetType(Byte)))
Then I'd try to replace:
row_Renamed("ImageCol") = img
for:
row_Renamed("ImageCol") = IO.File.ReadAllBytes(row_Renamed("memberPhoto"))
That would load disk file to byte array and shown in tile. I'd check if file exists to avoid exceptions.
That's what I do to load image from disk.
Hope it helps.
I am binding a datatable to an asp.net chart but want to set the value of the label to a different dataitem (called ResLabelText) than used for the x or y axis. Can this be done? My databinding code is as follows:
chartRes.Series("Month").XValueMember = "MonthName"
chartRes.Series("Month").YValueMembers = "Res"
chartRes.Series("Month").Label = "ResLabelText"
chartRes.Series("Month").ToolTip = "#VALX"
chartRes.DataSource = dt
chartRes.DataBind()
Correct way:
For Each row In dt.Rows
Dim point = New DataPoint()
point.SetValueXY(row.Item("MonthName"), row.Item("Res"))
point.Label = row.Item("LabelRes")
point.ToolTip = row.Item("MonthName")
chartRes.Series("Month").Points.Add(point)
Next
I am trying programatically add a check box column to a grid view. This grid view has multiple other columns but I only want the check box column to be editable. The only examples I have seen require that I add an "Edit" link to each row. I would like for the check box column to be editable by default, without the need for a link. The check box should also support autopost backs. Anyone have any suggestions? Below is what I have so far:
Dim gv As New GridView
With gv
.ID = "gridViewFoundUsers"
.AutoGenerateColumns = False
.DataKeyNames = New String() {"UserId"}
.GridLines = GridLines.Both
.AllowSorting = True
.AllowPaging = True
.PageSize = numRows
.Width = tableWidth
.BorderColor = Drawing.ColorTranslator.FromHtml("#808080")
.AutoGenerateEditButton = True
.HeaderStyle.CssClass = foundUserHeadStyle
.RowStyle.CssClass = foundUserEvenRows
.Columns.Clear()
Dim UserIdTF As New BoundField
With UserIdTF
.DataField = "UserId"
.HeaderText = "UserID"
.SortExpression = "UserId"
.ItemStyle.Wrap = True
.ItemStyle.Width = 100
End With
Dim DomainTF As New BoundField
With DomainTF
.HeaderText = "Domain"
.DataField = "Domain"
.SortExpression = "Domain"
.ItemStyle.Wrap = False
.HeaderStyle.Font.Underline = False
End With
Dim SelectUserTF As New CheckBoxField
With SelectUserTF
.HeaderText = "Select User"
.ItemStyle.Wrap = False
.DataField = "isSelected"
End With
.Columns.Add(UserIdTF)
.Columns.Add(DomainTF)
.Columns.Add(SelectUserTF)
End With
The gridview is part of a composite server control, so there is no client side code pages.
Thanks!