-
Jan 15th, 2021, 12:06 PM
#1
Thread Starter
Addicted Member
[RESOLVED] How to Visualize legend for each ChartArea
Hi all,
I developed a Function that creates a Chart Area inside a chart.
I tried to assign to each Chart Area a legend without success.
A part of this Function is:
Code:
Private Sub _CreateStackedDrawKPI(ByVal MyChart As Chart, ByVal T As DataTable, ByVal titolo As String, ByVal NumChartArea As Integer, ByVal legenda As String)
x = (From p In T.AsEnumerable()
Select p.Field(Of String)("Week") Distinct).ToArray()
' Order By p.Field(Of String)("Week")
y1K = (From p In T.AsEnumerable()
Select p.Field(Of Integer)("Num_CS_RAB_Est_Att")).ToArray()
y2K = (From p In T.AsEnumerable()
Select p.Field(Of Integer)("Num_CS_RAB_Est_Succ")).ToArray()
y3 = (From p In T.AsEnumerable()
Select p.Field(Of Double)("CSSR")).ToArray()
Dim ChartArea1 = New ChartArea()
ChartArea1.Name = titolo
MyChart.ChartAreas.Add(titolo)
Dim Mylegend As New Legend
Mylegend.Name = legenda
MyChart.Legends.Add(legenda)
MyChart.Legends(legenda).DockedToChartArea = titolo
MyChart.Legends(titolo).IsDockedInsideChartArea = False
...
This function is called in this way:
Code:
Dim aa As New MyFunctions
....
If Lista_KPI.Count = 1 Then
ChartKPI = New Chart
ChartKPI.Name = "Chart_KPI"
SplitContainer3.Panel2.Controls.Add(ChartKPI)
aa.CreateStackedDrawKPI(ChartKPI, T_Data1, NomeContatore, Lista_KPI.Count, Titolo)
End If
If Lista_KPI.Count = 2 Then
aa.CreateStackedDrawKPI(ChartKPI, T_Data1, NomeContatore, Lista_KPI.Count, Titolo)
End If
Lista_KPI is a list of string of 2 elements: CSSR and DCR
NomeContatore is a string and it is equal at first step to value "CSSR" and in second Step to "DCR"
Titolo is a string and it is equal at first step to value "CSSR" and in second Step to "DCR".
Titolo is equal to NomeContatore
Each Element of list calls the function above.
Issue s that both legend and also Title are showed always in first Chart Area
Any suggestion?
Thank in advanced
gio
Last edited by giodepa; Jan 16th, 2021 at 03:08 AM.
-
Jan 15th, 2021, 03:50 PM
#2
Re: How to Visualize legend for each Chart Area
As you set the legends outside the chartarea, it is possible that they take both the same default position on the chart.
Try MyChart.Legends(titolo).IsDockedInsideChartArea = true just to verify that
you can change the position of the legend with legend.position : https://docs.microsoft.com/fr-fr/dot...tframework-4.8
Last edited by Delaney; Jan 16th, 2021 at 05:49 AM.
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Jan 16th, 2021, 03:05 AM
#3
Thread Starter
Addicted Member
Re: How to Visualize legend for each Chart Area
Hi Delaney,
link that you provided doesn't work
I already tried legend insideDockArea
This is result:
-
Jan 16th, 2021, 05:49 AM
#4
Re: How to Visualize legend for each ChartArea
I don't know what's happened with the link. I corrected it
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Jan 18th, 2021, 06:05 AM
#5
Thread Starter
Addicted Member
Re: How to Visualize legend for each ChartArea
Hi All,
finally I found issue!!!
Code above is correct but for each series it is necessary to specify legend too:
Code:
series1.Legend = titolo
and result is:
gio
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|