Getting numbers on Y-axis to show up as percentages with code from a Highcharts code generator tool? - css

I'm the founder of a nonprofit news org that is a member of INN (The Institute for Nonprofit News). Some of us members have our wordpress news sites hosted for free through INN and therefore, cannot just install any plugins we want. INN must approve that first.
So the only way I have been able to use Highcharts is through this tool from Builtvisible that is a Highcharts code generator: https://builtvisible.com/highcharts-generator/
I've made a column chart here that is for a newborn screening story and is the Top-10 hospitals with the highest percentage of late samples. So when I hover over each bar I just want the tooltip to display 73%, instead of 73 like it does right now.
Any help would be greatly appreciated. I'm not very knowledgeable with coding and have tried a few things, even contacting the person who built this code generator but I can't figure out how to make it work. For another column chart also I have the same issue but I need it to separate the thousands with a comma instead of a space. So I would like 1,000 to read like that, instead of 1 000.
Here is my code from the generator where I need it to display percentages:
<div id="chart_container"></div><script src="//code.highcharts.com/adapters/standalone-framework.js"></script><script src="//code.highcharts.com/highcharts.js"></script><script>new Highcharts.Chart({"chart":{"backgroundColor":"#fefefe","renderTo":"chart_container","type":"column"},"title":{"text":"Top-10 facilities for lateness"},"colors":["#476974","#3ca1c1","#4ccbf4","#96dff6","#c9e8f6"],"legend":{"enabled":true,"margin":30},"xAxis":{"tickWidth":0,"labels":{"y":20},"categories":["Facilities with the highest overall percentage of late samples"]},"yAxis":{"tickWidth":0,"labels":{"y":-5},"title":{"text":"Percentage (%)"}},"series":[{"name":"NE MT HLTH SERVICES WOLF POINT","data":[73]},{"name":"CLARK FORK VALLEY HOSPITAL","data":[71]},{"name":"MARCUS DALY HOSPITAL","data":[68]},{"name":"ST JOSEPH HOSPITAL","data":[65]},{"name":"SIDNEY HEALTH CENTER","data":[64]},{"name":"THE BIRTH CENTER, MISSOULA","data":[63]},{"name":"GLENDIVE MEDICAL CENTER","data":[59]},{"name":"FRANCES MAHON DEAC HOSPITAL","data":[57]},{"name":"ST LUKE HOSPITAL","data":[55]},{"name":"CABINET PEAKS MEDICAL CENTER","data":[53]}]});</script>
Here is the other column chart where I would like the thousands to be separated by a comma when you hover over each column and it brings up the tool tip. This is also code from the Builtvisible Highcharts code generator:
<div id="chart_container2"></div>
<script src="//code.highcharts.com/adapters/standalone-framework.js"></script><script src="//code.highcharts.com/highcharts.js"></script><script>// <![CDATA[
new Highcharts.Chart({"chart":{"backgroundColor":"#fefefe","renderTo":"chart_container2","type":"column"},"title":{"text":"Wisconsin Lab: On-Time Performance"},"colors":["#6AA121","#2069A1","#A12069","#96dff6","#c9e8f6"],"legend":{"enabled":true,"margin":30},"xAxis":{"tickWidth":0,"labels":{"y":20},"categories":["2011","2012","2013","2014"]},"yAxis":{"tickWidth":0,"labels":{"y":-5},"title":{"text":"Number of samples on-time vs. late"}},"series":[{"name":"On-time","data":[7006,5492,5589,7069]},{"name":"Late","data":[3857,4979,5189,4105]},{"name":"Very Late","data":[701,1075,1074,776]}]});
// ]]></script>

This "tool code" is just regular Highcharts code, and does nothing more than generate it for you.
For the first chart you can use valueSuffix to add a percentage sign after the value. Code:
plotOptions: {
column: {
tooltip: {
valueSuffix: '%'
}
}
}
For the second chart you can use the global thousandSep option to get comma separators. Code:
Highcharts.setOptions({
lang: {
thousandsSep: ','
}
});
See this JSFiddle demonstration of both code segments.

Related

How to avoid word limit in ChatGPT in R?

I registered at this link to get an API for ChatGPT.
And I used the chatgpt package in R.
library(chatgpt)
And set environment:
Sys.setenv(OPENAI_API_KEY = "sk-YOURAPI")
I used this function:
chatgpt::ask_chatgpt("How to make a strawberry pie to donate to my wife? Ingredients, please.")
Sometimes the output is missing words. For example:
*** ChatGPT input:
How to make a strawberry pie to donate to my wife? Ingredients, please.
[1] ... and your wife is"
It does not complete the text after is. Is there any solution for this on R?
Similar question on reddit.
EDIT
I tried increasing the processing time of the function (so that the chat would finish typing all the content, without stopping midway). Like this:
for (i in 35) {
print(chatgpt::ask_chatgpt("How to make a strawberry pie to donate to my wife? Ingredients, please."))
Sys.sleep(i)
}
What you are running into is prompt engineering. GPT is a sophisticated autocomplete engine.
If you are not getting the right response you need to recraft your prompt.
You can always test your prompts in the OpenAI playground:
https://platform.openai.com/playground
I was able to get a list of ingredients and cooking steps by using the following prompt:
How can I make a strawberry pie to donate to my wife? Please provide first a numbered list of ingredients, and secondly a numbered lists of steps.
Here is the output I got in the playground:
Ingredients:
1. 2 ½ cups of fresh or frozen strawberries
2. 1 9-inch pre-made pie crust
3. ¾ cup of granulated sugar
4. 2 tablespoons of cornstarch
5. ¼ teaspoon of salt
6. 1 tablespoon of fresh lemon juice
Steps:
1. Preheat oven to 425 degrees F.
2. Place the pre-made pie crust in a 9-inch pie dish and set aside.
3. In a medium bowl, combine the strawberries, sugar, cornstarch, salt, and lemon juice. Stir until the mixture is combined.
4. Pour the strawberry mixture into the pre-made pie crust.
5. Place the pie dish on a baking sheet and bake for 15 minutes.
6. Reduce the oven temperature to 375 degrees F and bake for an additional 25 minutes.
7. Allow the pie to cool completely before serving.
Another thing to note, per the Github repo for the chatgpt R library it says "The {chatgpt} R package provides a set of features to assist in R coding."
Ref: https://github.com/jcrodriguez1989/chatgpt
I would use the OpenAI APIs directly, this way you will have a lot more control over your response. I am not an R specialist, but this is how the OpenAI Playground showed me how to do it.
library(httr)
response <- GET("https://api.openai.com/v1/completions",
query = list(
prompt = "How can I make a strawberry pie to donate to my wife? Please provide first a numbered list of ingredients, and secondly a numbered lists of steps.",
max_tokens = 200,
model = 'text-davinci-003'
),
add_headers(Authorization = "bearer YOUR_OPENAI_API_KEY")
)
content(response)
Ref: OpenAI playground
Increase max_tokens to get longer answer.

Apexchart option updates not working under vue3

I'm building a multiple series line chart using Apexcharts under Vue3, and running into an issue where chart options are not being updated. The series data updates as expected, but I have yet to see an option update successfully.
I'm using composition api with ref, which overall seems to be working great. But once the chart is assigned via lineChart.value = achart, no changes I make will update the chart. For example, the options file contains colors: ['#FFFF00', '#0000FF'], which is yellow and blue, but updating the ref with new colors changes nothing on the chart. Looking at the data using moustache syntax, I can see the new color values have been updated, but not in the chart. See attached screenshot.
I have followed every guide and post I can find, but still no luck. Does anyone know if this is a common issue, or if there is some special consideration I should be taking? If this is a larger issue I'll work on creating a codepen project.
Thanks
UPDATE: Adding a codesandbox.io project
Use updateOptions insted https://apexcharts.com/docs/methods/#updateOptions
ApexCharts.exec("chartID", "updateOptions", {
series: [
{
data: [1,2,3,2]
}
],
xaxis: {
categories: ['a', 'b', 'c','d'],
},
colors:['#00ff00']
})
I encounter the same problem, since I use async and await the data updates after a seconds but doesnt update the chart itself,
I read the docs and it said that you need to update the whole value of the chart options.
chartOptions.value.xaxis.categories = [2020, 2021, 2022]
instead
chartOptions.value = {
... charts: {}
xaxis: {
...
categories: [2022, 2021, 2022]

Extracting full article text via the newsanchor package [in R]

I am using the newsanchor package in R to try to extract entire article content via NewsAPI. For now I have done the following :
require(newsanchor)
results <- get_everything(query = "Trump +Trade", language = "en")
test <- results$results_df
This give me a dataframe full of info of (maximum) a 100 articles. These however do not containt the entire actual article text. Rather they containt something like the following:
[1] "Tensions between China and the U.S. ratcheted up several notches over the weekend as Washington sent a warship into the disputed waters of the South China Sea. Meanwhile, Google dealt Huaweis smartphone business a crippling blow and an escalating trade war co… [+5173 chars]"
Is there a way to extract the remaining 5173 chars. I have tried to read the documentation but I am not really sure.
I don't think that is possible at least with free plan. If you go through the documentation at https://newsapi.org/docs/endpoints/everything in the Response object section it says :
content - string
The unformatted content of the article, where available. This is truncated to 260 chars for Developer plan users.
So all the content is restricted to only 260 characters. However, test$url has the link of the source article which you can use to scrape the entire content but since it is being aggregated from various sources I don't think there is one automated way to do this.

How to use create-<breeds>-with between two breed turtle agents?

I've been stuck by this issue for a long time. I have two networks in my model, so I want to create different types of links with different breed turtle agentsets.
Let's name the 1st turtle agentset T1 and the 2nd T2, so what I did is the following:
breed [T1s T1]
undirected-link-breed [TL1s TL1]
breed [T2s T2]
undirected-link-breed [TL2s TL2]
;;Got error report
ask T1s [create-TL1s-with other n-of 10 T1s]
The last line gave an error reporting that "You cannot use breeded and unbreeded links in the same world". I'm quite confused about what this means.
And then, I changed the last line to:
ask T1s [create-links-with other n-of 10 T1s]
It worked this time, but if that's the case, how can I define two different types of links, i.e., TL1 and TL2, with different turtle agentsets T1s and T2s?
Can anybody help me out? I really appreciate it!
Thanks
That error means that you've created some links that have no breed (probably with create-link-with) before creating links with a breed, or vice-versa. If you want to use link breeds, you can never use create-link-with, create-link-to, or create-link-from. You must always use create-<breed>-with, create-<breed>-to, and create-<breed>-from.
So, search your code for instances of create-link-with, create-link-to, or create-link-from and either delete them or change them to create-<breed>-with, create-<breed>-to, or create-<breed>-from. If you're still getting the error, call clear-all or clear-links to make sure you've removed all unbreeded links.

Biztalk schema pipe delimited header/detail on same level

I have a flat file below. I'm having trouble with the schema with this layout. I switched it around to have a header and a detail and created an application with no problems, but the customer won't change the layout. This is probably pretty basic, but I'm a beginner. How do I take certain fields from this layout and create a header and a detail? The last date field needs to be in the header so you can see how it's random.
PO207730CO|1271|customer 1|john doe|1|161075|161075|BROOM FLAGGED LOBBY|2|5.62|24-Feb-2014|
PO207730CO|1271|customer 1|john doe|2|167316|167316|CLEANER DISPATCH SPRAY HOSPITAL DISINFECTANT W/BLEACH|1|59.84|24-Feb-2014|
PO207730CO|1271|customer 1|john doe|3|162175|162175|DUST PAN LOBBY|2|6.26|24-Feb-2014|
PO207730CO|1271|customer 1|john doe|4|163325|163325|MOP WET LARGE GENERAL-PURPOSE BLUE WB/LP|1|18.45|24-Feb-2014|
PO207730CO|1271|customer 1|john doe|5|164715|164715|SOAP PROVON MEDICATED TFX|1|32.79|24-Feb-2014|
PO207730CO|1271|customer 1|john doe|6|166338|166338|TOWEL MULTI-FOLD SCOTT WHITE|5|18.91|24-Feb-2014|
PO207814CO|1264|customer 2|jane doe|1|Cups||Bib 20x35 2 Ply Lab (756220)|1|17.47|24-Feb-2014|
PO207814CO|1264|customer 2|jane doe|2|Cups||Cup 9oz Translucent (098219)|1|24-Feb-2014|
PO207814CO|1264|customer 2|jane doe|3|Cups||Cup Foam 16oz (177190)|2|35.1|24-Feb-2014|
PO207814CO|1264|customer 2|jane doe|4|Cups||Lid 16/20 Whte Tab W/Sslot (194088)|2|16.57|24-Feb-2014|
PO207814CO|1264|customer 2|jane doe|5|Cups||Tissue 2-Ply 100-Sht (343227)|3|16.38|24-Feb-2014|
The basic problem here is the Flat File Disassembler does not support the concept of splitting/debatching based on changing values, PO207730CO -> PO207814CO for example.
So, you'll have to regroup by PO number at some following step.
You have a few options:
Use a Custom XSLT Map to group the lines based on the PO Number,
then split, by using a Receive Pipeline on an Orchestration for example.
https://social.technet.microsoft.com/wiki/contents/articles/17985.xslt-muenchian-grouping-biztalk-complex-transformation.aspx
Use an xPath Debatching Pattern in an Orchestration. http://www.biztalkgurus.com/biztalk_server/biztalk_2004/m/biztalk_2004_samples/32438.aspx
Either way, you would parse the flat file as you are now, row by row.
Thanks for the replies.
I went with an SSIS package to preload a table and build the pipe delimited file. I have Biztalk then picking up that file and debatching it the way I need it.

Resources