MPAndroidChart - Change message "No chart data available" - mpandroidchart

Is there any way to change the message "No chart data available" when the chart is not populated?
Edit: Found the answer
chart.setNoDataText("Description that you want");

update answer
chart.setNoDataText("Description that you want");

If you also want to customize look & feel, you can do it through Paint object:
mChart.setNoDataText("Description that you want");
Paint p = mChart.getPaint(Chart.PAINT_INFO);
p.setTextSize(...);
p.setColor(...);
p.setTypeface(...);
...

The Correct answer is here:
pie_chart.setNoDataText("No Data Available");
val paint:Paint = pie_chart.getPaint(Chart.PAINT_INFO)
paint.textSize = 40f
pie_chart.invalidate()
You also set other properties like text color, text typeface etc

#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_firestore__eintraege__heute);
mChart = findViewById(R.id.chartZuckerHeute);
mChart.setNoDataText("PUT IT HERE ON TOP; WORKED FOR ME");

You need put pieChart.invalidate() after setNoDataText():
#Override
public void setDataMessagePieChart() {
pieChart.setNoDataText("... your message ...");
pieChart.invalidate();
}

It's a little bit old thread, but I had the same issue so my solution was to set nodatatext immediately after the initialization of a chart:
PieChart pieChart = findViewById(R.id.chart) //in case of fragment view.findViewById(R.id.chart)
pieChart.setNoDataText("Loading");

If setNoDataText is not working, you have to set it (and after that run an invalidate()) when you are initializing the chart. Don't do it when you are right away to set the data.

Related

How To Use Eclipse Help In a Wizard

I found two ways to allegedly make the help work for an Eclipse wizard.
The first is to set setHelpAvailable(true) on my instance of Wizard and let the WizardPage override the method:
public void performHelp() {
PlatformUI.getWorkbench().getHelpSystem().displayHelp(CONTEXT_ID);
}
It displays a help button without an icon next to the "Back" button, but the method performHelp is never called.
The second way is to set it on the TrayDialog directly like this:
WizardDialog dialog = new WizardDialog(myShell, myWizard);
dialog.create();
WorkbenchHelp.setHelp(dialog.getShell(), CONTEXT_ID);
dialog.setHelpAvailable(true);
dialog.open();
This displays a button with an icon on the bottom left, but nothing happens when I click it.
The help system is set up (quiet a feat with the documentation, if I say so myself), but I can't figure out how to get either of these solutions to work. And I wonder if one of them should preferred over the other?
With the WizardDialog just call
dialog.setHelpAvailable(true);
In the createControl method of each WizardPage call the help system setHelp:
public void createControl(Composite parent)
{
Composite composite = new Composite(parent, SWT.NONE);
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, "help id");
... other code
Just for completeness sake: In my case the problem had nothing to do with the sparsely documented help feature, but with the fact that Eclipse Mars can't Hot Code Replace anymore.

Win 8.1 Metro Hub Navigation

In a Hub view App with subItems Pages, my question is when I navigate to a sub item detail Page and then use command navigate goback, the view always returns to pageroot hub section01.
How can I return the MainHub Page to the original calling section that went to the sub page in the first place?
My research has been fruitless. I don't think snaps are my answer but hey any advice is appreciated.
I apologize if this is a very simple question but...
Thx.
Ok. Thanks for the answers. After looking at this problem for three days I have found a solution but not quite an answer.
this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
By enabling Navigation Caching the page will return to it's sender position. However I still desire to return to the Hub root page to a specific section. If anyone still has info on how to achieve this I would be grateful.
Seasons Greetings.
Well the newbie here has also discovered the MyHub.ScrollToSection(MyHub.Sections[0]);
This allows you to navigate directly to a section thereby bringing it into the current view.
I'm trying to find an answer to the same question. This is what I've found so far. I welcome any better solutions.
Option 1
Enable caching for the page. Note that this must be set in the page constructor or XAML. This will increase memory usage but will improve performance of your app when you navigate back to a cached page.
this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
More information here: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.page.navigationcachemode.aspx
Option 2
Manually save a controls state between page navigations. The example below is using the NavigationHelper class which is added to a new Windows Store project by default.
private void OnNavigationHelperSaveState(obj sender, SaveStateEventArgs e)
{
e.PageState["SelectedSection"] = this.MainHub.SectionsInView;
}
private void OnNavigationHelperLoadState(obj sender, LoadStateEventArgs e)
{
if (e.PageState != null)
{
var sections = e.PageState["SelectedSection"] as IList<HubSection>;
if (sections != null && sections.Any())
{
this.MainHub.ScrollToSection(sections[0]);
}
}
}
More information here: http://msdn.microsoft.com/en-gb/library/windows/apps/hh986968.aspx
you could get the Hub's descendant scrollviewer and register to scrollchanged events, store the scrollOffsets and restore them as soon as the user navigates back to the page by applying the values to the hub's scrollviewer.
I guess you would have to register to the hub's loaded event to get the descending scrollviewer (you can use an Extension method from WinRt XAML Toolkit that allows you to get the descendants by Type (e.g. Scrollviewer)
greetings!
you can delete un back stack with this :
if(this.Frame.CanGoBack)
{
this.Frame.BackStack.RemoveAt(0);
}
Have you tried what i suggested?
Unforunately Hub can't be extended to do this and access it's Scrollviewer so you have to do this with an attached Property or plainly in your page.cs .
First you register an handler for the Loaded event of your hub. In the handler you get the descending scrollviewer (with the help of WINRT XAML Toolkit maybe) and register for it's ViewChanged Event.
You store the paremeters you like somewhere they don't get deleted on page navigation and restore and attach them to the scrollviewer on backwards-navigation.
I can give you example code in the afternoon.
Greetings
It's not a ridiculous request. Try this:
public static class Concurrency
{
public static HubSection GotoSection { get; set; }
}
public class MainPage : Page
{
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (Concurrency.GotoSection != null)
MainHub.ScrollToSection(Concurrency.GotoSection);
Concurrency.GotoSection = null;
base.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
Concurrency.GotoSection = MainHub.SectionsInView.First();
base.OnNavigatedFrom(e);
}
}
The reason this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled; may not be the correct solution is because you might want your hub to be refreshed. If the detail page resulted in an edit (or especially a delete) a back navigation would show stale data, and subject your app to un unexpected state if the user interacts with dead data.
Best of luck!
Enable cache mode on your page at initialization
public MainHubPage()
{
. .......
this.NavigationCacheMode = NavigationCacheMode.Enabled;
.......
}
You need to add Loaded method to Page constructor.
MainHub.Loaded += async (s, e) => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
//here you can scroll
MainHub.ScrollToSection(Loyaltysection);
});

How to enable Slider Windows Phone Ticks property

Here's what i want to do:
<Slider Minimum="1" Maximum="100" IsSnapToTickEnabled="True" Ticks="10,20,50,75,100" />
But here's the message Visual Studio display when on "IsSnapToTickEnable":
"The member IsSnapToTickEnabled is not recognized or is not accesible."
The same for Ticks. Why can't i use this feature in Windows Phone ?
Thanx
private void SliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
//Get The new value
int newValue = (int)e.NewValue;
//Set the new position
SliderAmount.Value = newValue;
}
The slider will go to position set as Value.
(In my example my slider parameters are Minimum="1" Maximum="5" SmallChange="1")
I found my answer:
private void SliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
//Get The new value
int newValue = (int)e.NewValue;
//Set the new position
SliderAmount.Value = newValue;
}
The slider will go to position set as Value.
(In my example my slider parameters are Minimum="1" Maximum="5" SmallChange="1")
thanks for your posting, which I found after many non working solutions. I was surprised that using discrete values this isn't a property of the slider and that a property like Ticks="1,2,3,4,5" won't work in a Windows Phone either. I found that it is important to warp the SliderAmount.Value = line in a Try-Catch because my emulator originally didn't even start the program anymore after adding the code. In the debugger I found that this was a System.NullReferenceException was unhandled by user code error (apparently on first init or something) and the Try/Catch solved that.

Context menu in windows 8 using Popup

Hi I am trying to create a context menu in windows 8 using Popup. On Right click of a button I am calling the following function
private async void UIElement_OnRightTapped(object sender, RightTappedRoutedEventArgs e)
{
PopupMenu popUpMenu = new PopupMenu();
popUpMenu.Commands.Add(new UICommand("File"));
Rect rect = GetRect(sender);
var result= await popUpMenu.ShowForSelectionAsync(rect, Placement.Right);
}
While defination for GetRect method is as follows:-
private Rect GetRect(object sender)
{
FrameworkElement element = sender as FrameworkElement;
GeneralTransform elementTransform = element.TransformToVisual(null);
Point point = elementTransform.TransformPoint(new Point());
Size size = new Size(element.ActualWidth, element.ActualHeight);
Rect rect = new Rect(point, size);
return rect;
}
Though the GetRect is returning correct value, but still i am getting result as null.
Please help
I can't figure out why you have this problems. On the first view, everything looks fine.
Maybe Tim Heuer Callisto package contains an easier approach for exactly what you want. See this example.
It's because you're not clicking on the File command, but instead clicking elsewhere on the page.

Force a view to refresh?

I'm trying to do a loading icon where once you tap on the icon, it will call the following handler:
private void refresh_btn_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
refresh_btn.Visibility = System.Windows.Visibility.Collapsed;
loading_icon.Visibility = System.Windows.Visibility.Visible;
refreshMix();
}
private void refreshMix()
{
...
refresh_btn.Visibility = System.Windows.Visibility.Collapsed;
loading_icon.Visibility = System.Windows.Visibility.Visible;
}
However, the view doesn't seem to auto-reload after I change the icon visibilities before calling refreshMix(). Is there a way to force the page to reload itself?
You are probably doing some lengthy work in refreshMix() in UI thread, right? Do this work in background thread and UI thread will be free to update page.
You need set Collapsed before Visible :
control.Visibility = System.Windows.Visibility.Collapsed;
control.Visibility = System.Windows.Visibility.Visible;
Within Silverlight there is no concept of page or view re-loading. When you change the properties of any visual element, this will be reflected on the screen the next time it is rendered.