question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help with the configuration

See original GitHub issue

I am trying to make a chart that will have visible x line as dotted line(that matches the position of the values(ticks?)), to have positive value have green color and fill and negative value to have red color and fill, both with gradient.

Something like this: obrázok

So far I have this:

{
      uplotData: [
        [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],
        [5,-5, 0, 1,5,9,10,15,5,-10,-15,-20,-20,-5,0, 5]
      ],
      uplotOpts: {
        width: 100,
        height: 50,
        cursor: {
          show: false
        },
        select: {
          show: false,
        },
        legend: {
          show: false
        },
        scales: {
          x: {
            time: false
          }
        },
        axes: [
          {
            show: false,
          },
          {
            show: false,
          }
        ],
        series: [
          {},
          {
            stroke: "red",
            width: 1,
            fill: "rgba(255, 0, 0, 0.3)",
          }
        ],
      },

So far that will render me this: obrázok

Since the documentation is non-existent i checked the demos but I really don’t get how that fill works or how to render that x- axis properly. I came from apex charts which could not render small charts without a ton of padding and chartjs documentation is horrible to go through.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
leeoniyacommented, Jan 2, 2022

ok, so there are quite a few ways to approach this, depending on exactly what you want.

since you’re not showing the legend, the easiest thing to do would be to simply render the bars and the shaded area as separate series. for a non-interactive sparkline type of setup you dont need to worry about the awkwardness of displaying and toggling the fill separately from the bars. this way we can re-use the line pathBuilder (which is rather complex) and benefit from uPlot’s native caching.

i just added a couple opts in https://github.com/leeoniya/uPlot/commit/6d266593a0cf0533c520fc3d73861a708f0a6bee so that floating bars can be rendered using the built-in renderer instead of having to write a custom one. that commit also includes this demo: https://leeoniya.github.io/uPlot/demos/sparklines-bars.html. the top version uses a shared gradient fill for all the bars, so any which cross zero are bi-colored. the bottom one uses a disp.fill function to determine each bar’s individual color.

image

1reaction
leeoniyacommented, Dec 29, 2021

if you dont need the fill fade, you can just do this for fill:

        return scaleGradient(u, s.scale, 1, [
          [sc.min,  "rgba(255,0,0,0.2)"],
          [     0,  "rgba(0,255,0,0.2)"],
        ], 1, true);

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Find help for using Configuration Manager - Microsoft Learn
There are several resources that you can use to find help with Configuration Manager. Whether you're just getting started or an experienced ...
Read more >
Learn about the Android Device Configuration Service
The Android Device Configuration Service periodically sends data from Android devices to Google. This data helps Google ensure that your device remains ...
Read more >
What Is Configuration Management and Why Is It Important?
Configuration management (CM) is a systems engineering process for establishing and maintaining consistency of a system's attributes.
Read more >
Configuration management: definition and benefits - Atlassian
Configuration management helps engineering teams build robust and stable systems through the use of tools that automatically manage and monitor updates to ...
Read more >
Configuration Editor for Firefox - Mozilla Support
The Configuration Editor (about:config page) lets you view, change, or reset advanced preference settings in Firefox. Learn more.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found